- Timestamp:
- Oct 31, 2015, 12:20:00 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc
r10725 r10729 33 33 34 34 RegisterClass(SectionController); 35 static const float ACTION_INTERVAL = 1.0f;36 35 37 36 SectionController::SectionController(Context* context) : LeaderController(context) 38 37 { 39 38 RegisterObject(SectionController); 40 39 this->setFormationMode(WALL); 41 40 42 41 bIsDivisionLeader_ = false; … … 44 43 this->myWingman_ = 0; 45 44 this->myDivisionLeader_ = 0; 46 this->desiredRelativePosition_ = 0;47 45 48 46 orxout(internal_error) << this << "Was created" << endl; … … 54 52 55 53 } 56 /*void SectionController::setDesiredPositionOfWingman()54 void SectionController::setTargetPositionOfWingman() 57 55 { 58 56 if (!this->myWingman_) 59 57 return; 60 58 Vector3* targetRelativePositionOfWingman; 61 59 switch (this->formationMode_){ 62 60 case WALL: 63 61 { 64 myWingman_->desiredRelativePosition_ = new Vector3 (-200, 0, 0);62 targetRelativePositionOfWingman = new Vector3 (-400, 0, 0); 65 63 break; 66 64 } … … 78 76 } 79 77 } 78 Quaternion orient = this->getControllableEntity()->getWorldOrientation(); 79 80 Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) + 81 (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman))); 82 83 myWingman_->setTargetOrientation(orient); 84 myWingman_->setTargetPosition(targetAbsolutePositionOfWingman); 80 85 81 86 } 82 */ 87 83 88 LeaderController* SectionController::findNewDivisionLeader() 84 89 { … … 104 109 105 110 106 107 108 109 111 float distance = ((it)->getControllableEntity()->getPosition() - this->getControllableEntity()->getPosition()).length(); 110 112 … … 114 116 minDistance = distance; 115 117 } 116 /* // is pawn in range? 117 if (distance < RADIUS_TO_SEARCH_FOR_LEADER) 118 { 119 120 if ((it)->setFollower(this)) 121 return (*it); 122 }*/ 118 123 119 } 124 120 if (closestLeader) … … 142 138 143 139 } 144 /* setDesiredPositionOfWingman(); 145 */ } 140 setTargetPositionOfWingman(); 141 142 } 146 143 /* 147 144 Wingmen and Leaders attack target_, which is a member variable of their classes. … … 158 155 159 156 */ 160 /* void SectionController::keepDivisionTick() 161 { 162 163 164 if (this->myDivisionLeader_ && this->myDivisionLeader_->getControllableEntity() && desiredRelativePosition_) 165 { 166 167 Vector3 desiredAbsolutePosition = ((this->myDivisionLeader_->getControllableEntity()->getWorldPosition()) + 168 (this->myDivisionLeader_->getControllableEntity()->getWorldOrientation()* (*desiredRelativePosition_))); 169 this->moveToPosition (desiredAbsolutePosition); 170 } 171 }*/ 157 172 158 void SectionController::tick(float dt) 173 159 { 174 175 176 /*177 160 if (!this->isActive()) 178 161 return; 179 162 180 //--------------------------Stay in division-------------------------- 181 this->keepDivisionTick(); 182 */ 183 //If ordered to move -> move to a target Point 184 185 //No orders -> Don't move, but shoot at whatever is close, unless Boss is shooting at it. 186 //(Section shoots same target, Boss's section shoots another target) 187 163 if (this->bHasTargetPosition_) 164 { 165 this->moveToTargetPosition(); 166 } 188 167 189 //orxout(internal_error) << "my Wingman is " << this->myWingman_ << endl;190 168 191 169 SUPER(SectionController, tick, dt);
Note: See TracChangeset
for help on using the changeset viewer.