25 |
#include <Foundation/NSArray.h> |
#include <Foundation/NSArray.h> |
26 |
#include <Foundation/NSException.h> |
#include <Foundation/NSException.h> |
27 |
#include <Foundation/NSCoder.h> |
#include <Foundation/NSCoder.h> |
28 |
|
#include <Foundation/NSNotification.h> |
29 |
|
|
30 |
#include "GameEngine/HgShip.h" |
#include "GameEngine/HgShip.h" |
31 |
#include "GameEngine/HgBonus.h" |
#include "GameEngine/HgBonus.h" |
58 |
*/ |
*/ |
59 |
- (void) setFuel: (unsigned)fuel |
- (void) setFuel: (unsigned)fuel |
60 |
{ |
{ |
61 |
|
[[NSNotificationCenter defaultCenter] |
62 |
|
postNotificationName:@"updateObject" object: [self game]]; |
63 |
|
|
64 |
_fuel = fuel; |
_fuel = fuel; |
65 |
} |
} |
66 |
|
|
82 |
*/ |
*/ |
83 |
- (void) setFireRate: (unsigned)fireRate |
- (void) setFireRate: (unsigned)fireRate |
84 |
{ |
{ |
85 |
|
[[NSNotificationCenter defaultCenter] |
86 |
|
postNotificationName:@"updateObject" object: [self game]]; |
87 |
|
|
88 |
_fireRate = fireRate; |
_fireRate = fireRate; |
89 |
} |
} |
90 |
|
|
125 |
NSParameterAssert (bonus); |
NSParameterAssert (bonus); |
126 |
NSParameterAssert (![_bonuses containsObject: bonus]); |
NSParameterAssert (![_bonuses containsObject: bonus]); |
127 |
|
|
128 |
|
[[NSNotificationCenter defaultCenter] |
129 |
|
postNotificationName:@"updateObject" object: [self game]]; |
130 |
|
|
131 |
[_bonuses addObject: bonus]; |
[_bonuses addObject: bonus]; |
132 |
} |
} |
133 |
|
|
140 |
NSParameterAssert (bonus); |
NSParameterAssert (bonus); |
141 |
NSParameterAssert ([_bonuses containsObject: bonus]); |
NSParameterAssert ([_bonuses containsObject: bonus]); |
142 |
|
|
143 |
|
[[NSNotificationCenter defaultCenter] |
144 |
|
postNotificationName:@"updateObject" object: [self game]]; |
145 |
|
|
146 |
[_bonuses removeObject: bonus]; |
[_bonuses removeObject: bonus]; |
147 |
} |
} |
148 |
|
|
159 |
*/ |
*/ |
160 |
- (void) setNbAmmo: (unsigned)nbAmmo |
- (void) setNbAmmo: (unsigned)nbAmmo |
161 |
{ |
{ |
162 |
|
[[NSNotificationCenter defaultCenter] |
163 |
|
postNotificationName:@"updateObject" object: [self game]]; |
164 |
|
|
165 |
_ammo = nbAmmo; |
_ammo = nbAmmo; |
166 |
} |
} |
167 |
|
|
170 |
*/ |
*/ |
171 |
- (void) useAmmos: (unsigned)quantity |
- (void) useAmmos: (unsigned)quantity |
172 |
{ |
{ |
173 |
|
[[NSNotificationCenter defaultCenter] |
174 |
|
postNotificationName:@"updateObject" object: [self game]]; |
175 |
|
|
176 |
_ammo = (_ammo - quantity); |
_ammo = (_ammo - quantity); |
177 |
} |
} |
178 |
|
|
181 |
*/ |
*/ |
182 |
- (void) addAmmos: (unsigned)quantity |
- (void) addAmmos: (unsigned)quantity |
183 |
{ |
{ |
184 |
|
[[NSNotificationCenter defaultCenter] |
185 |
|
postNotificationName:@"updateObject" object: [self game]]; |
186 |
|
|
187 |
_ammo = (_ammo + quantity); |
_ammo = (_ammo + quantity); |
188 |
} |
} |
189 |
|
|
190 |
|
@end |
191 |
|
|
192 |
|
@implementation HgShip (NSCoding) |
193 |
|
|
194 |
/** |
/** |
195 |
* NSCoding method |
* NSCoding method |
196 |
* to encode and decode objects |
* to encode and decode objects |