Changeset 8991 for code/branches/formation/src
- Timestamp:
- Dec 16, 2011, 4:56:15 PM (13 years ago)
- Location:
- code/branches/formation/src/orxonox/controllers
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/formation/src/orxonox/controllers/AIController.cc
r8990 r8991 78 78 } 79 79 80 if (this->state_ == SLAVE && this-> mode_ == ATTACK) //TODO: add botlevel parameter80 if (this->state_ == SLAVE && this->formationMode_ == ATTACK) //TODO: add botlevel parameter 81 81 { 82 82 // search enemy … … 151 151 float maxrand = 100.0f / ACTION_INTERVAL; 152 152 ControllableEntity* controllable = this->getControllableEntity(); 153 154 if (controllable && this->mode_ == NORMAL)// bot is ready to move to a target // mode was DEFAULT in original implementation!153 //DOES: Either move to the waypoint or search for a Point of interest 154 if (controllable && this->mode_ == DEFAULT)// bot is ready to move to a target 155 155 { 156 156 if (this->waypoints_.size() > 0 ) //Waypoint functionality. … … 174 174 } 175 175 176 if (this->mode_ != ROCKET)176 if (this->mode_ == DEFAULT) 177 177 { 178 178 if (this->state_ == MASTER) … … 207 207 } 208 208 209 if (this->state_ == SLAVE && this-> mode_!=ATTACK)209 if (this->state_ == SLAVE && this->formationMode_ != ATTACK) 210 210 { 211 211 if (this->bHasTargetPosition_) … … 213 213 } 214 214 215 if (this->state_ == FREE || (this->state_==SLAVE && this-> mode_==ATTACK) )215 if (this->state_ == FREE || (this->state_==SLAVE && this->formationMode_ == ATTACK) ) 216 216 { 217 217 if (this->target_) -
code/branches/formation/src/orxonox/controllers/ArtificialController.cc
r8990 r8991 50 50 this->setAccuracy(5); 51 51 this->defaultWaypoint_ = NULL; 52 this->mode_ = DEFAULT;//Vector-implementation: mode_.push_back(DEFAULT); 52 53 } 53 54 … … 197 198 void ArtificialController::setPreviousMode() 198 199 { 199 this->mode_ = NORMAL; //Vector-implementation: mode_.pop_back();200 this->mode_ = DEFAULT; //Vector-implementation: mode_.pop_back(); 200 201 } 201 202 -
code/branches/formation/src/orxonox/controllers/ArtificialController.h
r8989 r8991 71 71 //************************************************************************* NEW 72 72 float botlevel_; //<! Makes the level of a bot configurable. 73 enum Mode {DEFAULT, ROCKET, DEFENCE, MOVING};//TODO; implement DEFENCE, MOVING modes 74 Mode mode_; //TODO: replace single value with stack-like implementation: std::vector<Mode> mode_; 73 75 void setPreviousMode(); 74 76 -
code/branches/formation/src/orxonox/controllers/FormationController.cc
r8990 r8991 81 81 82 82 this->state_ = FREE; 83 this-> mode_ = NORMAL;83 this->formationMode_ = NORMAL; 84 84 this->specificMasterAction_ = NONE; 85 85 this->specificMasterActionHoldCount_ = 0; … … 652 652 @brief Sets the new mode. If master, set it for all slaves. 653 653 */ 654 void FormationController::set Mode(Mode val)655 { 656 this-> mode_=val;657 if (this->state_ ==MASTER)654 void FormationController::setFormationMode(FormationMode val) 655 { 656 this->formationMode_ = val; 657 if (this->state_ == MASTER) 658 658 { 659 659 for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++) 660 660 { 661 (*it)-> mode_=val;662 if (val ==ATTACK)661 (*it)->formationMode_ = val; 662 if (val == ATTACK) 663 663 (*it)->forgetTarget(); 664 664 } -
code/branches/formation/src/orxonox/controllers/FormationController.h
r8990 r8991 88 88 Attack-leave formation, attack every target 89 89 */ 90 enum Mode {NORMAL,DEFEND,ATTACK,ROCKET};90 enum FormationMode {NORMAL,DEFEND,ATTACK}; 91 91 92 92 /** 93 93 @brief Sets the new mode. If master, set it for all slaves. 94 94 */ 95 void set Mode(Mode val);96 inline Mode getMode() const97 { return this-> mode_; }95 void setFormationMode(FormationMode val); 96 inline FormationMode getFormationMode() const 97 { return this->formationMode_; } 98 98 99 99 protected: … … 109 109 FormationController* myMaster_; 110 110 111 Mode mode_;111 FormationMode formationMode_; 112 112 113 113 enum SpecificMasterAction {NONE, HOLD, SPIN, TURN180, FOLLOW}; -
code/branches/formation/src/orxonox/controllers/HumanController.cc
r8990 r8991 106 106 if (HumanController::localController_s && HumanController::localController_s->state_==MASTER) 107 107 { 108 if (HumanController::localController_s-> mode_!=ATTACK)108 if (HumanController::localController_s->formationMode_ != ATTACK) 109 109 HumanController::localController_s->commandSlaves(); 110 110 } … … 177 177 HumanController::localController_s->controllableEntity_->fire(firemode); 178 178 //if human fires, set slaves free. See FormationController::forceFreeSlaves() 179 if (HumanController::localController_s->state_==MASTER && HumanController::localController_s-> mode_==NORMAL)179 if (HumanController::localController_s->state_==MASTER && HumanController::localController_s->formationMode_ == NORMAL) 180 180 { 181 181 HumanController::localController_s->forceFreeSlaves(); … … 317 317 if (HumanController::localController_s && HumanController::localController_s->state_==MASTER) 318 318 { 319 switch (HumanController::localController_s->get Mode()) {319 switch (HumanController::localController_s->getFormationMode()) { 320 320 case NORMAL: 321 HumanController::localController_s->set Mode(DEFEND);321 HumanController::localController_s->setFormationMode(DEFEND); 322 322 orxout(message) <<"Mode: DEFEND "<< endl; 323 323 break; 324 324 case DEFEND: 325 HumanController::localController_s->set Mode(ATTACK);325 HumanController::localController_s->setFormationMode(ATTACK); 326 326 orxout(message) <<"Mode: ATTACK "<< endl; 327 327 break; 328 328 case ATTACK: 329 HumanController::localController_s->set Mode(NORMAL);329 HumanController::localController_s->setFormationMode(NORMAL); 330 330 orxout(message) <<"Mode: NORMAL "<< endl; 331 331 break; 332 default: //catch all non-formation related states333 break;334 332 } 335 333 } … … 340 338 void HumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) 341 339 { 342 if (!this->formationFlight_ || this->state_!=MASTER || this-> mode_!=DEFEND) return;340 if (!this->formationFlight_ || this->state_!=MASTER || this->formationMode_!=DEFEND) return; 343 341 this->masterAttacked(originator); 344 342 }
Note: See TracChangeset
for help on using the changeset viewer.