55 |
|
|
56 |
/** |
/** |
57 |
* Change the ship fuel. |
* Change the ship fuel. |
58 |
|
* Post an notification named "updateObject" containing the current game and |
59 |
|
* the current object. |
60 |
*/ |
*/ |
61 |
- (void) setFuel: (unsigned)fuel |
- (void) setFuel: (unsigned)fuel |
62 |
{ |
{ |
|
[[NSNotificationCenter defaultCenter] |
|
|
postNotificationName:@"updateObject" object: [self game]]; |
|
|
|
|
63 |
_fuel = fuel; |
_fuel = fuel; |
64 |
|
|
65 |
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"updateObject" |
66 |
|
object: [self game] |
67 |
|
userInfo: [NSDictionary dictionaryWithObject: self |
68 |
|
forKey: @"HgObject"]]; |
69 |
} |
} |
70 |
|
|
71 |
- (void) updateFuel |
- (void) updateFuel |
83 |
|
|
84 |
/** |
/** |
85 |
* Change the ship fireRate. |
* Change the ship fireRate. |
86 |
|
* Post an notification named "updateObject" containing the current game and |
87 |
|
* the current object. |
88 |
*/ |
*/ |
89 |
- (void) setFireRate: (unsigned)fireRate |
- (void) setFireRate: (unsigned)fireRate |
90 |
{ |
{ |
|
[[NSNotificationCenter defaultCenter] |
|
|
postNotificationName:@"updateObject" object: [self game]]; |
|
|
|
|
91 |
_fireRate = fireRate; |
_fireRate = fireRate; |
92 |
|
|
93 |
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"updateObject" |
94 |
|
object: [self game] |
95 |
|
userInfo: [NSDictionary dictionaryWithObject: self |
96 |
|
forKey: @"HgObject"]]; |
97 |
} |
} |
98 |
|
|
99 |
/** |
/** |
127 |
|
|
128 |
/** |
/** |
129 |
* Add a bonus to the ship. |
* Add a bonus to the ship. |
130 |
|
* Post an notification named "updateObject" containing the current game and |
131 |
|
* the current object. |
132 |
*/ |
*/ |
133 |
- (void) addBonus: (NSMutableArray *)bonus |
- (void) addBonus: (NSMutableArray *)bonus |
134 |
{ |
{ |
135 |
NSParameterAssert (bonus); |
NSParameterAssert (bonus); |
136 |
NSParameterAssert (![_bonuses containsObject: bonus]); |
NSParameterAssert (![_bonuses containsObject: bonus]); |
137 |
|
|
|
[[NSNotificationCenter defaultCenter] |
|
|
postNotificationName:@"updateObject" object: [self game]]; |
|
|
|
|
138 |
[_bonuses addObject: bonus]; |
[_bonuses addObject: bonus]; |
139 |
|
|
140 |
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"updateObject" |
141 |
|
object: [self game] |
142 |
|
userInfo: [NSDictionary dictionaryWithObject: self |
143 |
|
forKey: @"HgObject"]]; |
144 |
} |
} |
145 |
|
|
146 |
/** |
/** |
147 |
* Remove the first bonus of the ship. |
* Remove the first bonus of the ship. |
148 |
* The bonus must exists and be contains in the bonus ship list. |
* The bonus must exists and be contains in the bonus ship list. |
149 |
|
* Post an notification named "updateObject" containing the current game and |
150 |
|
* the current object. |
151 |
*/ |
*/ |
152 |
- (void) removeBonus: (NSMutableArray *)bonus |
- (void) removeBonus: (NSMutableArray *)bonus |
153 |
{ |
{ |
154 |
NSParameterAssert (bonus); |
NSParameterAssert (bonus); |
155 |
NSParameterAssert ([_bonuses containsObject: bonus]); |
NSParameterAssert ([_bonuses containsObject: bonus]); |
156 |
|
|
|
[[NSNotificationCenter defaultCenter] |
|
|
postNotificationName:@"updateObject" object: [self game]]; |
|
|
|
|
157 |
[_bonuses removeObject: bonus]; |
[_bonuses removeObject: bonus]; |
158 |
|
|
159 |
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"updateObject" |
160 |
|
object: [self game] |
161 |
|
userInfo: [NSDictionary dictionaryWithObject: self |
162 |
|
forKey: @"HgObject"]]; |
163 |
} |
} |
164 |
|
|
165 |
/** |
/** |
172 |
|
|
173 |
/** |
/** |
174 |
* Change the ship fireRate. |
* Change the ship fireRate. |
175 |
|
* Post an notification named "updateObject" containing the current game and |
176 |
|
* the current object. |
177 |
*/ |
*/ |
178 |
- (void) setNbAmmo: (unsigned)nbAmmo |
- (void) setNbAmmo: (unsigned)nbAmmo |
179 |
{ |
{ |
|
[[NSNotificationCenter defaultCenter] |
|
|
postNotificationName:@"updateObject" object: [self game]]; |
|
|
|
|
180 |
_ammo = nbAmmo; |
_ammo = nbAmmo; |
181 |
|
|
182 |
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"updateObject" |
183 |
|
object: [self game] |
184 |
|
userInfo: [NSDictionary dictionaryWithObject: self |
185 |
|
forKey: @"HgObject"]]; |
186 |
} |
} |
187 |
|
|
188 |
/** |
/** |
189 |
* Update the ammo quantity when they're used. |
* Update the ammo quantity when they're used. |
190 |
|
* Post an notification named "updateObject" containing the current game and |
191 |
|
* the current object. |
192 |
*/ |
*/ |
193 |
- (void) useAmmos: (unsigned)quantity |
- (void) useAmmos: (unsigned)quantity |
194 |
{ |
{ |
|
[[NSNotificationCenter defaultCenter] |
|
|
postNotificationName:@"updateObject" object: [self game]]; |
|
|
|
|
195 |
_ammo = (_ammo - quantity); |
_ammo = (_ammo - quantity); |
196 |
|
|
197 |
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"updateObject" |
198 |
|
object: [self game] |
199 |
|
userInfo: [NSDictionary dictionaryWithObject: self |
200 |
|
forKey: @"HgObject"]]; |
201 |
} |
} |
202 |
|
|
203 |
/** |
/** |
204 |
* Restore the ammo quantity. |
* Restore the ammo quantity. |
205 |
|
* Post an notification named "updateObject" containing the current game and |
206 |
|
* the current object. |
207 |
*/ |
*/ |
208 |
- (void) addAmmos: (unsigned)quantity |
- (void) addAmmos: (unsigned)quantity |
209 |
{ |
{ |
|
[[NSNotificationCenter defaultCenter] |
|
|
postNotificationName:@"updateObject" object: [self game]]; |
|
|
|
|
210 |
_ammo = (_ammo + quantity); |
_ammo = (_ammo + quantity); |
211 |
|
|
212 |
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"updateObject" |
213 |
|
object: [self game] |
214 |
|
userInfo: [NSDictionary dictionaryWithObject: self |
215 |
|
forKey: @"HgObject"]]; |
216 |
} |
} |
217 |
|
|
218 |
@end |
@end |