Changeset 8706 for code/trunk/src/orxonox/controllers
- Timestamp:
- Jun 14, 2011, 8:53:28 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/controllers/ArtificialController.cc
r8351 r8706 381 381 } 382 382 } 383 384 if (distance < 10) 385 { 386 this->positionReached(); 387 } 383 388 } 384 389 … … 387 392 this->moveToPosition(this->targetPosition_); 388 393 } 389 390 394 391 395 /** -
code/trunk/src/orxonox/controllers/ArtificialController.h
r7163 r8706 97 97 void moveToTargetPosition(); 98 98 99 virtual void positionReached() {} 100 99 101 void removeFromFormation(); 100 102 void unregisterSlave(); -
code/trunk/src/orxonox/controllers/Controller.h
r6417 r8706 50 50 { return this->player_; } 51 51 52 virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {}; 52 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {}; 53 54 /* Override needed for different visual effects (e.g. in "NewHumanController.cc") depending on 55 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 */ 53 59 54 60 void setGodMode( bool mode ){ this->bGodMode_ = mode; } -
code/trunk/src/orxonox/controllers/HumanController.cc
r8079 r8706 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"; 44 45 45 46 SetConsoleCommand("HumanController", "moveFrontBack", &HumanController::moveFrontBack ).addShortcut().setAsInputCommand(); … … 51 52 SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold); 52 53 SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut(); 53 SetConsoleCommand("HumanController", "boost", &HumanController::boost).addShortcut().keybindMode(KeybindMode::OnHold);54 SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::keepBoost ).addShortcut().keybindMode(KeybindMode::OnHold); 54 55 SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut(); 55 56 SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut(); … … 66 67 67 68 HumanController* HumanController::localController_s = 0; 69 /*static*/ const float HumanController::BOOSTING_TIME = 0.1f; 68 70 69 71 HumanController::HumanController(BaseObject* creator) : Controller(creator) … … 71 73 RegisterObject(HumanController); 72 74 73 controlPaused_ = false; 75 this->controlPaused_ = false; 76 this->boosting_ = false; 77 this->boosting_ = false; 74 78 75 79 HumanController::localController_s = this; 80 this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this))); 81 this->boostingTimeout_.stopTimer(); 76 82 } 77 83 … … 163 169 } 164 170 165 void HumanController::boost() 166 { 167 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 168 HumanController::localController_s->controllableEntity_->boost(); 171 /** 172 @brief 173 Static method,keeps boosting. 174 */ 175 /*static*/ void HumanController::keepBoost() 176 { 177 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 178 HumanController::localController_s->keepBoosting(); 179 } 180 181 /** 182 @brief 183 Starts, or keeps the boosting mode. 184 Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore). 185 */ 186 void HumanController::keepBoosting(void) 187 { 188 if(this->boostingTimeout_.isActive()) 189 { 190 this->boostingTimeout_.stopTimer(); 191 this->boostingTimeout_.startTimer(); 192 } 193 else 194 { 195 this->boosting_ = true; 196 this->boostingTimeout_.startTimer(); 197 198 this->controllableEntity_->boost(this->boosting_); 199 COUT(4) << "Start boosting" << endl; 200 } 201 } 202 203 /** 204 @brief 205 Terminates the boosting mode. 206 */ 207 void HumanController::terminateBoosting(void) 208 { 209 this->boosting_ = false; 210 this->boostingTimeout_.stopTimer(); 211 212 this->controllableEntity_->boost(this->boosting_); 213 COUT(4) << "Stop boosting" << endl; 169 214 } 170 215 -
code/trunk/src/orxonox/controllers/HumanController.h
r8079 r8706 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "tools/Timer.h" 34 35 #include "tools/interfaces/Tickable.h" 35 36 #include "Controller.h" … … 64 65 static void reload(); 65 66 66 static void boost(); 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 67 77 static void greet(); 68 78 static void switchCamera(); … … 92 102 static HumanController* localController_s; 93 103 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 94 110 }; // tolua_export 95 111 } // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.