home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 11 / Example 11.1 / unit.h < prev   
Encoding:
C/C++ Source or Header  |  2006-07-15  |  1.5 KB  |  52 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 PLAYER;
  13.     friend class APPLICATION;
  14.     public:
  15.         UNIT(int _type, int _team, INTPOINT mp, TERRAIN *_terrain, IDirect3DDevice9* Dev);
  16.         ~UNIT();
  17.  
  18.         //Abstract functions declared in MAPOBJECT
  19.         void Render();
  20.         void Update(float deltaTime);
  21.         BBOX GetBoundingBox();
  22.         D3DXMATRIX GetWorldMatrix();
  23.  
  24.         //Specific UNIT functions
  25.         void Goto(INTPOINT mp, bool considerUnits, bool _finalGoal);    //Order unit to mp
  26.         void MoveUnit(INTPOINT to);
  27.         D3DXVECTOR3 GetDirection(INTPOINT p1, INTPOINT p2);
  28.         void SetAnimation(char name[]);
  29.         void SetAnimation(int index);
  30.         bool CheckCollision(INTPOINT mp);
  31.         void Pause(float time);        
  32.  
  33.     private:
  34.  
  35.         //Animation variables
  36.         float m_time;                    //This units animation time
  37.         float m_speed;                    //Movement & animation speed
  38.         float m_pauseTime;                //Time to pause
  39.         int m_animation;                    //Current animation, Run, Still, attack etc.
  40.         D3DXVECTOR3 m_rotation, m_scale;    //Used to build the world matrix
  41.         ID3DXAnimationController* m_pAnimControl;    //Animation control
  42.  
  43.         //Movement variables
  44.         INTPOINT m_finalGoal;
  45.         std::vector<INTPOINT> m_path;        //The active path 
  46.         D3DXVECTOR3 m_lastWP, m_nextWP;        //last & next waypoint
  47.         int m_activeWP;                    //active waypoint
  48.         bool m_moving;
  49.         float m_movePrc;                    // 0.0 - 1.0, used to interpolate between lastWP & nextWP
  50. };
  51.  
  52. #endif