Untitled

By Innocent Leopard, 11 Years ago, written in C++, viewed 650 times.
URL http://pb.stoleyour.com/view/cf7003ec Embed
Download Paste or View RawExpand paste to full width of browser
  1. #ifndef UNIT_H
  2. #define UNIT_H
  3.  
  4. #include "../resource.h"
  5. #include "../types.h"
  6.  
  7. class Team;
  8.  
  9. class Unit
  10. {
  11. public:
  12.     int id; //unit id
  13.     int team; //the team the unit is on
  14.     Point position; //the units team
  15.     int health; //the current health amount
  16.     int iElement; //units element, fire/water etc.
  17.     int attackDamage;//damage that the unit deals per hit
  18.     int attackRange; //distance that the unit can successfully attack
  19.     int attackSpeed; //the speed which the attack counter has to hit in order to initiate an attack
  20.     int perception;  //distance that the unit can aquire a target
  21.     int attackCount; //counter between unit attacks
  22.     Unit *pTarget;
  23.    
  24.     bool            isAlive() { return health > 0; } //incase creep get hits more than its remaining health
  25.     virtual void    Attack(void);
  26.     virtual void    Update(Team&);
  27.     void            setTarget(Unit &newTarget) { pTarget = &newTarget; }
  28.     float           Rotate(Point);
  29.     void            setDamage(int newDamage) { attackDamage = newDamage;  }
  30.     void            setRange(int newRange) { attackRange = newRange; }
  31.     bool            inRange(Point, Point, int);
  32.     virtual void    CheckTarget(void);
  33.     virtual void    FindTarget(Team* team); // MAKE IMPL
  34.     bool            hasWeakness(int, int);
  35.     bool            hasStrength(int, int);
  36.     Point           getPos() { return position; }
  37.  
  38.     std::string serializeUnit();
  39.        
  40.     Unit(int uid, Point pos, int hp, int atkdmg, int atkrng,
  41.          int atkspd, int percep, int atkcnt);    
  42.  
  43.     Unit(int uid, int side, Point pos, int hp=100, int atkdmg=0, int atkrng=0,
  44.          int atkspd=0, int percep=0, int atkcnt=0);
  45.    
  46.     virtual UnitType getType() const = 0;
  47.     virtual size_t getSize() const { return sizeof(unit_t); };
  48. private:  
  49. };
  50. #endif
  51.  

Reply to "Untitled"

Here you can reply to the paste above