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.3 / unit.h < prev   
Encoding:
C/C++ Source or Header  |  2006-07-15  |  1.5 KB  |  51 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, bool considerUnits, bool _finalGoal);    //Order unit to mp
  25.         void MoveUnit(INTPOINT to);
  26.         D3DXVECTOR3 GetDirection(INTPOINT p1, INTPOINT p2);
  27.         void SetAnimation(char name[]);
  28.         void SetAnimation(int index);
  29.         bool CheckCollision(INTPOINT mp);
  30.         void Pause(float time);        
  31.  
  32.     private:
  33.  
  34.         //Animation variables
  35.         float m_time;                    //This units animation time
  36.         float m_speed;                    //Movement & animation speed
  37.         float m_pauseTime;                //Time to pause
  38.         int m_animation;                    //Current animation, Run, Still, attack etc.
  39.         D3DXVECTOR3 m_rotation, m_scale;    //Used to build the world matrix
  40.         ID3DXAnimationController* m_pAnimControl;    //Animation control
  41.  
  42.         //Movement variables
  43.         INTPOINT m_finalGoal;
  44.         std::vector<INTPOINT> m_path;        //The active path 
  45.         D3DXVECTOR3 m_lastWP, m_nextWP;        //last & next waypoint
  46.         int m_activeWP;                    //active waypoint
  47.         bool m_moving;
  48.         float m_movePrc;                    // 0.0 - 1.0, used to interpolate between lastWP & nextWP
  49. };
  50.  
  51. #endif