Changeset 8579 for code/branches/presentation/src/orxonox/controllers
- Timestamp:
- May 25, 2011, 9:28:29 PM (14 years ago)
- Location:
- code/branches/presentation/src/orxonox/controllers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/controllers/Controller.h
r8578 r8579 52 52 virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {}; 53 53 54 /* Override needed for different visual effects (e.g. in "NewHumanController.cc") depending on55 the DIFFERENT AMOUNT OF DAMAGE done to the shield and to the health of "victim" (see Projectile.cc, Pawn.cc)56 57 // virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage) {};58 */59 60 54 void setGodMode( bool mode ){ this->bGodMode_ = mode; } 61 55 bool getGodMode(){ return this->bGodMode_; } -
code/branches/presentation/src/orxonox/controllers/HumanController.cc
r8578 r8579 42 42 extern const std::string __CC_fire_name = "fire"; 43 43 extern const std::string __CC_suicide_name = "suicide"; 44 const std::string __CC_boost_name = "boost";45 44 46 45 SetConsoleCommand("HumanController", "moveFrontBack", &HumanController::moveFrontBack ).addShortcut().setAsInputCommand(); … … 52 51 SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold); 53 52 SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut(); 54 SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::keepBoost).addShortcut().keybindMode(KeybindMode::OnHold);53 SetConsoleCommand("HumanController", "boost", &HumanController::boost ).addShortcut().keybindMode(KeybindMode::OnHold); 55 54 SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut(); 56 55 SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut(); … … 67 66 68 67 HumanController* HumanController::localController_s = 0; 69 /*static*/ const float HumanController::BOOSTING_TIME = 0.1f;70 68 71 69 HumanController::HumanController(BaseObject* creator) : Controller(creator) … … 73 71 RegisterObject(HumanController); 74 72 75 this->controlPaused_ = false; 76 this->boosting_ = false; 73 controlPaused_ = false; 77 74 78 75 HumanController::localController_s = this; 79 this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this)));80 this->boostingTimeout_.stopTimer();81 76 } 82 77 … … 168 163 } 169 164 170 /** 171 @brief 172 Static method,keeps boosting. 173 */ 174 /*static*/ void HumanController::keepBoost() 175 { 176 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 177 HumanController::localController_s->keepBoosting(); 178 } 179 180 /** 181 @brief 182 Starts, or keeps the boosting mode. 183 Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore). 184 */ 185 void HumanController::keepBoosting(void) 186 { 187 if(this->boostingTimeout_.isActive()) 188 { 189 this->boostingTimeout_.stopTimer(); 190 this->boostingTimeout_.startTimer(); 191 } 192 else 193 { 194 this->boosting_ = true; 195 this->boostingTimeout_.startTimer(); 196 197 this->controllableEntity_->boost(this->boosting_); 198 COUT(4) << "Start boosting" << endl; 199 } 200 } 201 202 /** 203 @brief 204 Terminates the boosting mode. 205 */ 206 void HumanController::terminateBoosting(void) 207 { 208 this->boosting_ = false; 209 this->boostingTimeout_.stopTimer(); 210 211 this->controllableEntity_->boost(this->boosting_); 212 COUT(4) << "Stop boosting" << endl; 165 void HumanController::boost() 166 { 167 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 168 HumanController::localController_s->controllableEntity_->boost(); 213 169 } 214 170 -
code/branches/presentation/src/orxonox/controllers/HumanController.h
r8578 r8579 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "tools/Timer.h"35 34 #include "tools/interfaces/Tickable.h" 36 35 #include "Controller.h" … … 65 64 static void reload(); 66 65 67 static void keepBoost(); // Static method, keeps boosting. 68 /** 69 @brief Check whether the HumanController is in boosting mode. 70 @return Returns true if it is, false if not. 71 */ 72 inline bool isBoosting(void) 73 { return this->boosting_; } 74 void keepBoosting(void); 75 void terminateBoosting(void); 76 66 static void boost(); 77 67 static void greet(); 78 68 static void switchCamera(); … … 102 92 static HumanController* localController_s; 103 93 bool controlPaused_; 104 105 private:106 bool boosting_; // Whether the HumanController is in boosting mode or not.107 Timer boostingTimeout_; // A timer to check whether the player is no longer boosting.108 static const float BOOSTING_TIME; // The time after it is checked, whether the player is no longer boosting.109 110 94 }; // tolua_export 111 95 } // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.