24 |
#include <Foundation/NSException.h> |
#include <Foundation/NSException.h> |
25 |
#include <Foundation/NSCoder.h> |
#include <Foundation/NSCoder.h> |
26 |
#include <Foundation/NSValue.h> |
#include <Foundation/NSValue.h> |
27 |
|
#include <Foundation/NSNotification.h> |
28 |
|
|
29 |
#include "GameEngine/HgObject.h" |
#include "GameEngine/HgObject.h" |
30 |
#include "GameEngine/HgGame.h" |
#include "GameEngine/HgGame.h" |
31 |
|
|
32 |
|
|
33 |
/** |
/** |
34 |
* HgObject stores all principal caracteritic wich belongs to the |
* HgObject stores all principal caracteritic wich belongs to the |
35 |
* current object. This class is abstract and must be redefined |
* current object. This class is abstract and must be redefined |
38 |
@implementation HgObject |
@implementation HgObject |
39 |
|
|
40 |
/** |
/** |
41 |
* Initialyse an object which will be contained in game. |
* Initialise an object which will be contained in game. |
42 |
* The position must be contained in the game map. |
* The position must be contained in the game map. |
43 |
*/ |
*/ |
44 |
- (id) initWithGame: (HgGame *)game |
- (id) initWithGame: (HgGame *)game |
101 |
/** |
/** |
102 |
* Set the current position of the object. |
* Set the current position of the object. |
103 |
* The position must be contained in the map. |
* The position must be contained in the map. |
104 |
|
* Post an notification named "updateObject" containing the current object. |
105 |
*/ |
*/ |
106 |
- (void) setPosition: (coord_t)position |
- (void) setPosition: (coord_t)position |
107 |
{ |
{ |
110 |
*/ |
*/ |
111 |
//[_position mapContainsPosition: position] |
//[_position mapContainsPosition: position] |
112 |
|
|
113 |
|
[[NSNotificationCenter defaultCenter] |
114 |
|
postNotificationName:@"updateObject" object:self]; |
115 |
|
|
116 |
_position = position; |
_position = position; |
117 |
} |
} |
118 |
|
|
126 |
|
|
127 |
/** |
/** |
128 |
* Set the orientation of the object. |
* Set the orientation of the object. |
129 |
|
* Post an notification named "updateObject" containing the current object. |
130 |
*/ |
*/ |
131 |
- (void) setOrientation: (coord_t)orientation |
- (void) setOrientation: (coord_t)orientation |
132 |
{ |
{ |
133 |
|
[[NSNotificationCenter defaultCenter] |
134 |
|
postNotificationName:@"updateObject" object:self]; |
135 |
|
|
136 |
_orientation = orientation; |
_orientation = orientation; |
137 |
} |
} |
138 |
|
|
182 |
NSNumber *numIdent = [NSNumber numberWithInt: _identifier]; |
NSNumber *numIdent = [NSNumber numberWithInt: _identifier]; |
183 |
|
|
184 |
HgGame *current = [HgGame currentGame]; |
HgGame *current = [HgGame currentGame]; |
185 |
HgObject *object = [[current players] objectForKey: numIdent]; |
HgObject *object = [[current objects] objectForKey: numIdent]; |
186 |
|
|
187 |
if (object != nil) |
if (object != nil) |
188 |
{ |
{ |