Unit Class Reference

This class represents a unit in the game. More...

#include <Unit.h>

Inherits Object.

Inheritance diagram for Unit:

Inheritance graph
[legend]
Collaboration diagram for Unit:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Unit (Player *p_player)
 Standard constructor.
virtual ~Unit ()
 Standard destructor.
int settle (Level *p_level)
 Causes the unit to settle.
int generate (Field *p_field, Level *p_level)
 Causes the unit to generate a new unit.
int mutate (Level *p_level)
 Causes the unit to mutate int a new unit, changing the behavior and the texture.
int load (std::string p_filename)
 Loads all data from the given ressource file, and also loads the texture used.
int render (Vector3d p_pos, Level *p_level, double p_deltasize=1.0)
 Renders the Object at the given position.
int leechEnergy (Field *p_field, Level *p_level)
 Leeches energy from the given Field.
int compute (Field *p_field, Level *p_level)
 Computes everything for the unit the given round.
int getCombatValue (double p_rand)
 Computes the combat value by the given random-number 0.0-1.0.

Public Attributes

int spawnDestination
 Arrow counter to the field on which new units will be spawned.
FieldspawnDestinationField
 Pointer to the field on which new units will be spawned.
bool isSettled
 Flag that shows wheter the unit is settled or not.
std::string name
 Holds the display name of the unit.
Playerplayer
 Holds a pointer to its player.
int move_cost
 Holds the movement costs of the unit in energy.
int move_cooldown
 Holds the movement cooldown of the unit in game-rounds.
int settle_cost
 Holds the settle costs of the unit.
int settle_energy
 Holds the amaount of energy that is generated per cooldown.
int settle_cooldown
 Holds the cooldown for energy generating in Rounds.
int absorb_cost
 Holds the costs for direct absorbing initiation of the unit.
int absorb_cooldown
 Holds the cooldown for direct absorbing initiation of the unit in rounds.
int absorb_cooldown_core
 Holds the cooldown for direct absorbing initiation against enemy cores of the unit in rounds.
std::string generates
 Holds the filename of the unit that will be generated.
int generate_cooldown
 Holds the cooldown for generation of units.
std::string mutates
 Holds the filename of the unit this unit will mutate into after the settlement has been finished.
std::string settleSprite
 Holds the filename of the texture used for rendering, when sttlement is initiated.
int movingCombatValue
 Holds the combat value when this unit is moving.
int movingCombatBonus
 Holds the combat multiplier when this unit is moving.
int movingCombatRandom
 Holds the combat random range when this unit is moving.
int settledCombatValue
 Holds the combat value when this unit is settled.
int settledCombatBonus
 Holds the combat bonus multiplier when this unit is settled.
int settledCombatRandom
 Holds the combat random range when this unit is settled.
bool isBlocked
 Holds the status, if the Unit is blocked.
int bonus
 Holds the selected Bonus.

Static Public Attributes

static int s_selectedID = -1
 Holds the id of the selected object.

Detailed Description

This class represents a unit in the game.

Definition at line 33 of file Unit.h.


Constructor & Destructor Documentation

Unit::Unit ( Player p_player  ) 

Standard constructor.

Definition at line 36 of file Unit.cpp.

References player.

Referenced by generate().

Unit::~Unit (  )  [virtual]

Standard destructor.

Definition at line 41 of file Unit.cpp.


Member Function Documentation

int Unit::settle ( Level p_level  ) 

Causes the unit to settle.

This will change the textur used to render.

Parameters:
p_level Pointer to the level instance.
Returns:
0 for success.

Definition at line 163 of file Unit.cpp.

References Player::color, Player::energy, Level::eventList, isBlocked, isSettled, Texture::loadAndBind(), player, settle_cooldown, settle_cost, settleSprite, Object::size, and TM_Masked_Blue_To_Red.

Referenced by FunctionHandler::settle().

Here is the call graph for this function:

int Unit::generate ( Field p_field,
Level p_level 
)

Causes the unit to generate a new unit.

Parameters:
p_field The Field from which the energy should be absorbed.
p_level Pointer to the level instance.
Returns:
0 for success.

Definition at line 226 of file Unit.cpp.

References Level::eventList, generate_cooldown, generates, isBlocked, isSettled, load(), player, spawnDestination, spawnDestinationField, Unit(), and Field::unit.

Referenced by compute().

Here is the call graph for this function:

int Unit::mutate ( Level p_level  ) 

Causes the unit to mutate int a new unit, changing the behavior and the texture.

Parameters:
p_level Pointer to the level instance.
Returns:
0 for success.

Definition at line 249 of file Unit.cpp.

References Level::bindings, isSettled, load(), and mutates.

Referenced by leechEnergy(), and FunctionHandler::terminate().

Here is the call graph for this function:

int Unit::load ( std::string  p_filename  ) 

Loads all data from the given ressource file, and also loads the texture used.

Parameters:
p_filename Filename of the ressource file to load.
Returns:
0 for success.

Definition at line 46 of file Unit.cpp.

References absorb_cooldown, absorb_cooldown_core, absorb_cost, bonus, Player::color, generate_cooldown, generates, isBlocked, isSettled, Texture::loadAndBind(), move_cooldown, move_cost, movingCombatBonus, movingCombatRandom, movingCombatValue, mutates, name, player, Level::roundTime, settle_cooldown, settle_cost, settle_energy, settledCombatBonus, settledCombatRandom, settledCombatValue, settleSprite, Object::size, spawnDestination, splitLine(), and TM_Masked_Blue_To_Red.

Referenced by generate(), and mutate().

Here is the call graph for this function:

int Unit::render ( Vector3d  p_pos,
Level p_level,
double  p_deltasize = 1.0 
)

Renders the Object at the given position.

Parameters:
p_pos Position on the screen where the object should be rendered.
p_level Pointer to the level instance.
p_deltasize Size multiplier. Default = 1.0
Returns:
0 for success.

Definition at line 287 of file Unit.cpp.

References bonus, generate_cooldown, GLInterface::glPrint2d(), isBlocked, isSettled, movingCombatBonus, Texture::render(), s_selectedID, settledCombatBonus, spawnDestination, Vector3d::x, Vector3d::y, and Vector3d::z.

Referenced by Field::renderChild().

Here is the call graph for this function:

int Unit::leechEnergy ( Field p_field,
Level p_level 
)

Leeches energy from the given Field.

Parameters:
p_field The Field from which the energy should be absorbed.
p_level Pointer to the level instance.
Returns:
The amount of Enmergy leeched.

Definition at line 264 of file Unit.cpp.

References Field::energy, mutate(), Field::select(), settle_energy, and Field::textureName.

Referenced by compute().

Here is the call graph for this function:

int Unit::compute ( Field p_field,
Level p_level 
)

Computes everything for the unit the given round.

Parameters:
p_field The Field the unit sits on.
p_level Pointer to the level instance.
Returns:
The amount of Energy leeched.

Definition at line 186 of file Unit.cpp.

References Player::energy, Field::energy, Level::eventList, generate(), generates, isBlocked, isSettled, leechEnergy(), player, settle_cooldown, and settle_energy.

Referenced by EventComputeUnit::compute().

Here is the call graph for this function:

int Unit::getCombatValue ( double  p_rand  ) 

Computes the combat value by the given random-number 0.0-1.0.

Parameters:
p_rand Random number in the range of 0 to 1-
Returns:
The Combatvalue.

Definition at line 366 of file Unit.cpp.

References bonus, isSettled, movingCombatBonus, movingCombatRandom, movingCombatValue, settledCombatBonus, settledCombatRandom, and settledCombatValue.

Referenced by FunctionHandler::standardAction().


Member Data Documentation

int Unit::s_selectedID = -1 [static]

Holds the id of the selected object.

Definition at line 119 of file Unit.h.

Referenced by render(), Interface::render(), FunctionHandler::select(), and FunctionHandler::setSpawnDestination().

int Unit::spawnDestination

Arrow counter to the field on which new units will be spawned.

This counts clockwise, beginning with 0 at the top.

Definition at line 125 of file Unit.h.

Referenced by generate(), load(), render(), and FunctionHandler::setSpawnDestination().

Field* Unit::spawnDestinationField

Pointer to the field on which new units will be spawned.

Definition at line 130 of file Unit.h.

Referenced by generate(), and FunctionHandler::setSpawnDestination().

bool Unit::isSettled

Flag that shows wheter the unit is settled or not.

Definition at line 135 of file Unit.h.

Referenced by compute(), generate(), getCombatValue(), load(), mutate(), render(), FunctionHandler::select(), FunctionHandler::selectBonus(), FunctionHandler::setSpawnDestination(), and settle().

std::string Unit::name

Holds the display name of the unit.

Definition at line 140 of file Unit.h.

Referenced by load().

Player* Unit::player

Holds a pointer to its player.

Definition at line 145 of file Unit.h.

Referenced by compute(), generate(), load(), FunctionHandler::selectBonus(), FunctionHandler::setSpawnDestination(), settle(), FunctionHandler::standardAction(), and Unit().

int Unit::move_cost

Holds the movement costs of the unit in energy.

Definition at line 150 of file Unit.h.

Referenced by load(), and FunctionHandler::standardAction().

int Unit::move_cooldown

Holds the movement cooldown of the unit in game-rounds.

Definition at line 155 of file Unit.h.

Referenced by load(), and FunctionHandler::standardAction().

int Unit::settle_cost

Holds the settle costs of the unit.

Definition at line 160 of file Unit.h.

Referenced by load(), and settle().

int Unit::settle_energy

Holds the amaount of energy that is generated per cooldown.

Definition at line 165 of file Unit.h.

Referenced by compute(), leechEnergy(), and load().

int Unit::settle_cooldown

Holds the cooldown for energy generating in Rounds.

Definition at line 170 of file Unit.h.

Referenced by compute(), load(), settle(), and FunctionHandler::settle().

int Unit::absorb_cost

Holds the costs for direct absorbing initiation of the unit.

Definition at line 175 of file Unit.h.

Referenced by load(), and FunctionHandler::standardAction().

int Unit::absorb_cooldown

Holds the cooldown for direct absorbing initiation of the unit in rounds.

Definition at line 180 of file Unit.h.

Referenced by load(), and FunctionHandler::standardAction().

int Unit::absorb_cooldown_core

Holds the cooldown for direct absorbing initiation against enemy cores of the unit in rounds.

Definition at line 185 of file Unit.h.

Referenced by load(), and FunctionHandler::standardAction().

std::string Unit::generates

Holds the filename of the unit that will be generated.

Definition at line 190 of file Unit.h.

Referenced by compute(), generate(), load(), FunctionHandler::select(), and FunctionHandler::settle().

int Unit::generate_cooldown

Holds the cooldown for generation of units.

Definition at line 195 of file Unit.h.

Referenced by generate(), load(), and render().

std::string Unit::mutates

Holds the filename of the unit this unit will mutate into after the settlement has been finished.

Definition at line 200 of file Unit.h.

Referenced by load(), mutate(), and FunctionHandler::terminate().

std::string Unit::settleSprite

Holds the filename of the texture used for rendering, when sttlement is initiated.

Definition at line 205 of file Unit.h.

Referenced by load(), and settle().

int Unit::movingCombatValue

Holds the combat value when this unit is moving.

Definition at line 210 of file Unit.h.

Referenced by getCombatValue(), and load().

int Unit::movingCombatBonus

Holds the combat multiplier when this unit is moving.

Definition at line 215 of file Unit.h.

Referenced by getCombatValue(), load(), render(), and FunctionHandler::selectBonus().

int Unit::movingCombatRandom

Holds the combat random range when this unit is moving.

Definition at line 220 of file Unit.h.

Referenced by getCombatValue(), and load().

int Unit::settledCombatValue

Holds the combat value when this unit is settled.

Definition at line 225 of file Unit.h.

Referenced by getCombatValue(), load(), and FunctionHandler::setSpawnDestination().

int Unit::settledCombatBonus

Holds the combat bonus multiplier when this unit is settled.

Definition at line 230 of file Unit.h.

Referenced by getCombatValue(), load(), render(), and FunctionHandler::selectBonus().

int Unit::settledCombatRandom

Holds the combat random range when this unit is settled.

Definition at line 235 of file Unit.h.

Referenced by getCombatValue(), and load().

bool Unit::isBlocked

Holds the status, if the Unit is blocked.

Definition at line 240 of file Unit.h.

Referenced by compute(), EventUnblockUnit::compute(), generate(), load(), render(), settle(), FunctionHandler::settle(), and FunctionHandler::standardAction().

int Unit::bonus

Holds the selected Bonus.

Definition at line 245 of file Unit.h.

Referenced by getCombatValue(), load(), render(), and FunctionHandler::selectBonus().


The documentation for this class was generated from the following files:
Generated on Tue Jul 17 22:02:23 2007 for C0re by  doxygen 1.5.2