#include <RobotObject.h>
Inheritance diagram for RobotObject:
Public Member Functions | |
RobotObject (Robot &) | |
virtual | ~RobotObject () |
virtual void | Tick (long usec) |
virtual long | get_property (int)=0 |
virtual void | set_property (int, long)=0 |
virtual long | call_method (int, stack_v &)=0 |
int | GetMaxLife () |
void | SetMaxLife (int x) |
int | GetLife () |
void | SetLife (int x) |
int | GetDamage () |
bool | Ok () |
void | SetRepairRate (int x) |
int | GetRepairRate () |
Robot & | GetRobot () |
Private Attributes | |
Robot & | m_robot |
int | m_max_life |
double | m_life |
int | m_repair_rate |
Definition at line 10 of file RobotObject.h.
RobotObject::RobotObject | ( | Robot & | ) |
Definition at line 9 of file RobotObject.cpp.
00009 : m_robot(r) 00010 ,m_max_life(100) 00011 ,m_life(100) 00012 ,m_repair_rate(10) // % of max power/sec 00013 { 00014 }
RobotObject::~RobotObject | ( | ) | [virtual] |
void RobotObject::Tick | ( | long | usec | ) | [virtual] |
Reimplemented in Gun, Life, Radar, Shields, and Turret.
Definition at line 22 of file RobotObject.cpp.
References Robot::GetMaxPowerLevel(), GetRobot(), m_life, m_max_life, and m_repair_rate.
Referenced by Turret::Tick(), Shields::Tick(), Radar::Tick(), and Gun::Tick().
00023 { 00024 if (m_life < m_max_life) 00025 { 00026 double repair_units_per_sec = (m_repair_rate * GetRobot().GetMaxPowerLevel()) / 100; 00027 double power_units = (repair_units_per_sec * usec) / 1000000; 00028 if (GetRobot().UsePower(power_units)) 00029 { 00030 m_life += power_units / 100; 00031 if (m_life > m_max_life) 00032 m_life = m_max_life; 00033 } 00034 } 00035 }
virtual long RobotObject::get_property | ( | int | ) | [pure virtual] |
virtual void RobotObject::set_property | ( | int | , | |
long | ||||
) | [pure virtual] |
virtual long RobotObject::call_method | ( | int | , | |
stack_v & | ||||
) | [pure virtual] |
int RobotObject::GetMaxLife | ( | ) | [inline] |
void RobotObject::SetMaxLife | ( | int | x | ) | [inline] |
int RobotObject::GetLife | ( | ) | [inline] |
void RobotObject::SetLife | ( | int | x | ) | [inline] |
int RobotObject::GetDamage | ( | ) | [inline] |
Definition at line 26 of file RobotObject.h.
References m_life, and m_max_life.
Referenced by Turret::get_property(), Shields::get_property(), Robot::get_property(), Radar::get_property(), Gun::get_property(), and Ok().
00026 { return (int)((m_life * 100) / m_max_life); }
bool RobotObject::Ok | ( | ) | [inline] |
Definition at line 27 of file RobotObject.h.
References GetDamage().
Referenced by Turret::get_property(), Shields::get_property(), Robot::get_property(), Radar::get_property(), and Gun::get_property().
00027 { return GetDamage() > 0; }
void RobotObject::SetRepairRate | ( | int | x | ) | [inline] |
Definition at line 28 of file RobotObject.h.
References m_repair_rate.
Referenced by Turret::set_property(), Shields::set_property(), Robot::set_property(), Radar::set_property(), and Gun::set_property().
00028 { m_repair_rate = x; }
int RobotObject::GetRepairRate | ( | ) | [inline] |
Definition at line 29 of file RobotObject.h.
References m_repair_rate.
Referenced by Turret::get_property(), Shields::get_property(), Robot::get_property(), Radar::get_property(), and Gun::get_property().
00029 { return m_repair_rate; }
Robot& RobotObject::GetRobot | ( | ) | [inline] |
Definition at line 31 of file RobotObject.h.
References m_robot.
Referenced by Tick().
00031 { return m_robot; }
Robot& RobotObject::m_robot [private] |
int RobotObject::m_max_life [private] |
Definition at line 35 of file RobotObject.h.
Referenced by GetDamage(), GetMaxLife(), SetMaxLife(), and Tick().
double RobotObject::m_life [private] |
Definition at line 36 of file RobotObject.h.
Referenced by GetDamage(), GetLife(), SetLife(), and Tick().
int RobotObject::m_repair_rate [private] |
Definition at line 37 of file RobotObject.h.
Referenced by GetRepairRate(), SetRepairRate(), and Tick().