Changeset 2459 for GTP/trunk/App/Demos/Illum/Ogre/src/Common/include
- Timestamp:
- 06/24/07 11:00:20 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/FPSPlayer.h
r2418 r2459 2 2 3 3 #include "Ogre.h" 4 #include "OgreBillboardParticleRenderer.h" 5 #include "OgreIlluminationManager.h" 4 6 #include "NXOgre.h" 5 7 … … 16 18 PLAYERANIMSTATE_PAIN, 17 19 PLAYERANIMSTATE_DEATH, 18 PLAYERANIMSTATE_URN 19 }; 20 20 PLAYERANIMSTATE_TURN 21 }; 22 23 class PlayerCharacter; 24 class FireBall; 21 25 class MyCharMoveController; 22 26 27 class CharacterManager 28 { 29 public: 30 static CharacterManager& getSingleton() 31 { 32 if(mSingleton == 0) 33 mSingleton = new CharacterManager(); 34 return *mSingleton; 35 } 36 PlayerCharacter* getTrigger(NxOgre::Actor* a) 37 { 38 if(triggers.find(a)== triggers.end()) 39 return 0; 40 return triggers[a]; 41 } 42 PlayerCharacter* getTarget(NxOgre::Actor* a) 43 { 44 if(targets.find(a)== targets.end()) 45 return 0; 46 return targets[a]; 47 } 48 49 void addTrigger(NxOgre::Actor* a, PlayerCharacter* c){triggers[a] = c;} 50 void addTarget(NxOgre::Actor* a, PlayerCharacter* c){targets[a] = c;} 51 52 void levelUP(); 53 54 SceneManager* mSceneManager; 55 Scene* mScene; 56 57 protected: 58 CharacterManager(){} 59 static CharacterManager* mSingleton; 60 std::map<NxOgre::Actor*, PlayerCharacter*> triggers; 61 std::map<NxOgre::Actor*, PlayerCharacter*> targets; 62 63 }; 64 65 23 66 class PlayerCharacter : public FrameListener 24 67 { … … 28 71 29 72 virtual void addPlayerMesh(String meshname, float meshscale, bool rotateModel); 30 bool frameStarted(const FrameEvent& evt);73 virtual bool frameStarted(const FrameEvent& evt); 31 74 virtual void addWeaponModel(String meshname, String attachBoneName); 32 void doAction(float dt); 33 75 virtual void doAction(float dt){} 76 virtual float getHit(){return 0;} 77 virtual void addHit(float hit){mHealth -= hit; if(mHealth < 0) mHealth = 0;} 78 34 79 static unsigned int frameListenerPriority; 35 80 … … 58 103 Vector3 mPlayerDimensions; 59 104 bool mRunning; 105 bool isAlive; 60 106 61 107 SceneNode* mWeaponNode2; 62 108 bool mDebug; 63 109 110 float mHealth; 111 112 float getAnimSpeed(){return 1.2;} 64 113 virtual String getAnimStateName(PlayerAnimState as, int option = 0){return "stand";} 65 virtual void setAnimState(PlayerAnimState as) 66 { 67 if(mCurrentAnimState != PLAYERANIMSTATE_WALK) 68 { 69 mCharacterMesh_AnimState = mCharacterMeshEntity->getAnimationState(getAnimStateName(as)); 70 mCharacterMesh_AnimState->setLoop(true); 71 mCharacterMesh_AnimState->setEnabled(true); 72 } 73 } 114 virtual void setAnimState(PlayerAnimState as){} 115 116 }; 117 118 class TrollCharacter : public PlayerCharacter 119 { 120 public: 121 TrollCharacter(String name, Scene* scene, SceneManager* sceneManager, Vector3 dimensions, Vector3 startPosition, bool debug = false); 122 ~TrollCharacter(){} 123 124 void doAction(float dt); 125 float getHit(){ if(mCurrentAnimState == PLAYERANIMSTATE_ATTACK) return 20; else return 0;} 126 void addHit(float hit); 127 128 bool frameStarted(const FrameEvent& evt) 129 { 130 /* OverlayElement* healthUI = OverlayManager::getSingleton().getOverlayElement("MannaColumn"); 131 float relHealth = mHealth / MaxHealth; 132 healthUI->setHeight(0.29 * relHealth); 133 healthUI->setTop(0.005 + (1.0 - relHealth) * 0.29);*/ 134 135 return PlayerCharacter::frameStarted(evt); 136 } 137 protected: 138 String getAnimStateName(PlayerAnimState as, int option = 0); 139 void setAnimState(PlayerAnimState as); 140 141 static float MaxHealth; 74 142 }; 75 143 … … 87 155 Vector3 getPosition(){return mPlayerNode->getWorldPosition(); 88 156 return mPlayerCharacter->getGlobalPosition();} 157 Vector3 getDirection() 158 { 159 Vector3 dir = mCamera->getDerivedDirection(); 160 dir.normalise(); 161 return dir; 162 } 89 163 // Vector3 getOrienation(){return mPlayerCharacter->getGlobalOrientation();} 164 float getHit() 165 { 166 if(mCurrentAnimState == PLAYERANIMSTATE_ATTACK){ 167 if(mWeapon) return 20; 168 else return 15; 169 }else return 0; 170 } 171 void addHit(float hit) 172 { 173 if(isAlive) 174 { 175 PlayerCharacter::addHit(hit); 176 if(mHealth <= 0)//death 177 { 178 static deaths = 0; 179 deaths++; 180 isAlive = false; 181 OverlayElement* deathsTextBox = OverlayManager::getSingleton().getOverlayElement("Deaths"); 182 deathsTextBox->setCaption("Deaths: "+StringConverter::toString(deaths)); 183 } 184 } 185 } 186 187 void levelUp(){mMaxHealth += 30; mHealth = mMaxHealth;} 90 188 91 189 static FPSPlayer* thePlayer; 92 190 static FPSPlayer* getPlayer(){return thePlayer;} 191 void addCharacterInRange(PlayerCharacter* c){mCharactersInRange.insert(c);} 192 void removeCharacterInRange(PlayerCharacter* c){mCharactersInRange.erase(c);} 93 193 94 194 protected: 95 195 96 196 Camera* mCamera; 97 float mCameraHeight; 197 float mCameraHeight; 198 float mStrength; 199 float mMaxStrength; 200 float mManna; 201 float mMaxManna; 202 float mMaxHealth; 203 FireBall* mFireBall; 204 205 std::set<PlayerCharacter*> mCharactersInRange; 98 206 99 207 String getAnimStateName(PlayerAnimState as, int option = 0);
Note: See TracChangeset
for help on using the changeset viewer.