home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 9 / Example 9.1 / unit.h < prev   
Encoding:
C/C++ Source or Header  |  2006-07-15  |  1.4 KB  |  48 lines

  1. #ifndef _RTS_UNIT_
  2. #define _RTS_UNIT_
  3.  
  4. #include "skinnedmesh.h"
  5. #include "mapObject.h"
  6.  
  7. void LoadUnitResources(IDirect3DDevice9* Device);
  8. void UnloadUnitResources();
  9.  
  10. class UNIT : public MAPOBJECT
  11. {
  12.     friend class APPLICATION;
  13.     public:
  14.         UNIT(int _type, int _team, INTPOINT mp, TERRAIN *_terrain, IDirect3DDevice9* Dev);
  15.         ~UNIT();
  16.  
  17.         //Abstract functions declared in MAPOBJECT
  18.         void Render();
  19.         void Update(float deltaTime);
  20.         BBOX GetBoundingBox();
  21.         D3DXMATRIX GetWorldMatrix();
  22.  
  23.         //Specific UNIT functions
  24.         void Goto(INTPOINT mp);    //Order unit to mp
  25.         void MoveUnit(INTPOINT to);
  26.         bool CheckCollision(INTPOINT mp);
  27.         D3DXVECTOR3 GetDirection(INTPOINT p1, INTPOINT p2);
  28.         void SetAnimation(char name[]);
  29.         void SetAnimation(int index);
  30.  
  31.     private:
  32.  
  33.         //Animation variables
  34.         float m_time;                    //This units animation time
  35.         float m_speed;                    //Movement & animation speed
  36.         int m_animation;                //Current animation, Run, Still, attack etc.
  37.         D3DXVECTOR3 m_rotation, m_scale;//Used to build the world matrix
  38.         ID3DXAnimationController* m_pAnimControl;    //Animation control
  39.  
  40.         //Movement variables
  41.         std::vector<INTPOINT> m_path;    //The active path 
  42.         D3DXVECTOR3 m_lastWP, m_nextWP;    //last & next waypoint
  43.         int m_activeWP;                //active waypoint
  44.         bool m_moving;
  45.         float m_movePrc;                // 0.0 - 1.0, used to interpolate between m_lastWP & m_nextWP
  46. };
  47.  
  48. #endif