Changeset 9979
- Timestamp:
- Jan 4, 2014, 9:53:50 PM (11 years ago)
- Location:
- code/trunk/src/orxonox/controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/controllers/HumanController.cc
r9667 r9979 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(); … … 51 50 SetConsoleCommand("HumanController", "rotateRoll", &HumanController::rotateRoll ).addShortcut().setAsInputCommand(); 52 51 SetConsoleCommand("HumanController", "toggleFormationFlight", &HumanController::toggleFormationFlight).addShortcut().keybindMode(KeybindMode::OnPress); 53 SetConsoleCommand("HumanController", "FFChangeMode", &HumanController::FFChangeMode).addShortcut().keybindMode(KeybindMode::OnPress);52 SetConsoleCommand("HumanController", "FFChangeMode", &HumanController::FFChangeMode).addShortcut().keybindMode(KeybindMode::OnPress); 54 53 SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold); 55 54 SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut(); 56 SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::keepBoost ).addShortcut().keybindMode(KeybindMode::OnHold);55 SetConsoleCommand("HumanController", "boost", &HumanController::boost ).addShortcut().setAsInputCommand().keybindMode(KeybindMode::OnPressAndRelease); 57 56 SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut(); 58 57 SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut(); … … 69 68 70 69 HumanController* HumanController::localController_s = 0; 71 /*static*/ const float HumanController::BOOSTING_TIME = 0.1f;72 70 73 71 HumanController::HumanController(Context* context) : FormationController(context) … … 76 74 77 75 this->controlPaused_ = false; 78 this->boosting_ = false;79 this->boosting_ = false;80 76 HumanController::localController_s = this; 81 this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this)));82 this->boostingTimeout_.stopTimer();83 77 } 84 78 … … 190 184 /** 191 185 @brief 192 Static method,keeps boosting. 193 */ 194 /*static*/ void HumanController::keepBoost() 195 { 196 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 197 HumanController::localController_s->keepBoosting(); 198 } 199 200 /** 201 @brief 202 Starts, or keeps the boosting mode. 186 Static method, controls boosting. 187 */ 188 /*static*/ void HumanController::boost(const Vector2& value) 189 { 190 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 191 { 192 float abs = value.x; 193 if (abs > 0) 194 HumanController::localController_s->startBoosting(); 195 else 196 HumanController::localController_s->stopBoosting(); 197 } 198 } 199 200 /** 201 @brief 202 Starts the boosting mode. 203 203 Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore). 204 204 */ 205 void HumanController::keepBoosting(void) 206 { 207 if(this->boostingTimeout_.isActive()) 208 { 209 this->boostingTimeout_.stopTimer(); 210 this->boostingTimeout_.startTimer(); 211 } 212 else 213 { 214 this->boosting_ = true; 215 this->boostingTimeout_.startTimer(); 216 if(this->controllableEntity_) 217 this->controllableEntity_->boost(this->boosting_); 218 // orxout() << "Start boosting" << endl; 219 } 220 } 221 222 /** 223 @brief 224 Terminates the boosting mode. 225 */ 226 void HumanController::terminateBoosting(void) 227 { 228 this->boosting_ = false; 229 this->boostingTimeout_.stopTimer(); 205 void HumanController::startBoosting(void) 206 { 230 207 if(this->controllableEntity_) 231 this->controllableEntity_->boost(this->boosting_); 232 // orxout() << "Stop boosting" << endl; 208 this->controllableEntity_->boost(true); 209 } 210 211 /** 212 @brief 213 Stops the boosting mode. 214 */ 215 void HumanController::stopBoosting(void) 216 { 217 if(this->controllableEntity_) 218 this->controllableEntity_->boost(false); 233 219 } 234 220 -
code/trunk/src/orxonox/controllers/HumanController.h
r9667 r9979 65 65 static void reload(); 66 66 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); 67 static void boost(const Vector2& value); // Static method, controls boosting. 68 void startBoosting(void); 69 void stopBoosting(void); 76 70 77 71 … … 107 101 bool controlPaused_; 108 102 109 private:110 bool boosting_; // Whether the HumanController is in boosting mode or not.111 Timer boostingTimeout_; // A timer to check whether the player is no longer boosting.112 static const float BOOSTING_TIME; // The time after it is checked, whether the player is no longer boosting.113 114 103 }; // tolua_export 115 104 } // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.