#include <ColonyCell.h>
Public Member Functions | |
ColonyCell (Colony *colony, unsigned int i, unsigned int j) | |
Constructor. | |
virtual | ~ColonyCell () |
Empty Destructor. | |
unsigned int | getHeight () |
Return the z position of the Cell in the World. | |
unsigned int | getWidth () |
Return the x position of the Cell in the World. | |
Colony * | getColony () |
Return the Colony associated with that Cell. | |
virtual bool | reachable (Worshiper *w) |
Is the Cell reachable ? | |
virtual Cell * | makeActions () |
Make the actions needed by the Cell for one iteration. | |
Protected Member Functions | |
virtual void | getColors (GLubyte &red, GLubyte &green, GLubyte &blue) |
Return the color the Cell has to be display with. | |
Protected Attributes | |
Colony * | _colony |
unsigned int | _i |
unsigned int | _j |
Definition at line 38 of file ColonyCell.h.
ColonyCell::ColonyCell | ( | Colony * | colony, | |
unsigned int | i, | |||
unsigned int | j | |||
) |
Constructor.
colony | the colony of the ColonyCell | |
i | the z position of the Cell in the World | |
j | the x position of the Cell in the World |
Definition at line 42 of file ColonyCell.cpp.
References _colony, and Colony::addCell().
00042 : 00043 ReachableCell(), _colony(colony), _i(i), _j(j) { 00044 _colony->addCell(this); 00045 }
void ColonyCell::getColors | ( | GLubyte & | red, | |
GLubyte & | green, | |||
GLubyte & | blue | |||
) | [protected, virtual] |
Return the color the Cell has to be display with.
red | the red part of the display color | |
green | the green part of the display color | |
blue | the blue part of the display color |
Reimplemented from Cell.
Definition at line 33 of file ColonyCell.cpp.
References _colony, and Colony::getColor().
00033 { 00034 GLubyte *colors; 00035 00036 colors = _colony->getColor(); 00037 red = colors[0]; 00038 green = colors[1]; 00039 blue = colors[2]; 00040 }
unsigned int ColonyCell::getHeight | ( | ) |
unsigned int ColonyCell::getWidth | ( | ) |
Colony * ColonyCell::getColony | ( | ) |
Return the Colony associated with that Cell.
Definition at line 59 of file ColonyCell.cpp.
References _colony.
Referenced by World::fight().
00059 { 00060 return _colony; 00061 }
bool ColonyCell::reachable | ( | Worshiper * | w | ) | [virtual] |
Is the Cell reachable ?
Reimplemented from ReachableCell.
Definition at line 63 of file ColonyCell.cpp.
References _colony, and Worshiper::getColony().
Cell * ColonyCell::makeActions | ( | ) | [virtual] |
Make the actions needed by the Cell for one iteration.
Reimplemented from ReachableCell.
Definition at line 67 of file ColonyCell.cpp.
References _colony, Colony::addSurvivor(), ReachableCell::getPeople(), ReachableCell::makeActions(), and ReachableCell::removeWorshiper().
00067 { 00068 std::list<Worshiper*>* worshipers; 00069 std::list<Worshiper*>::iterator it, end; 00070 00071 ReachableCell::makeActions(); 00072 00073 worshipers = getPeople(); 00074 end = worshipers->end(); 00075 for(it = worshipers->begin(); it != end; ++it) { 00076 if((*it)->getColony() == _colony) { 00077 _colony->addSurvivor(*it); 00078 removeWorshiper(*it); 00079 --it; 00080 } 00081 } 00082 00083 return this; 00084 }
Colony* ColonyCell::_colony [protected] |
The colony associated with that ColonyCell
Definition at line 43 of file ColonyCell.h.
Referenced by ColonyCell(), getColony(), getColors(), makeActions(), and reachable().
unsigned int ColonyCell::_i [protected] |
z position of the ColonyCell in the World
Definition at line 46 of file ColonyCell.h.
Referenced by getHeight().
unsigned int ColonyCell::_j [protected] |
x position of the ColonyCell in the World
Definition at line 48 of file ColonyCell.h.
Referenced by getWidth().