Changeset 3515 in orxonox.OLD for orxonox/branches
- Timestamp:
- Mar 12, 2005, 3:11:30 AM (20 years ago)
- Location:
- orxonox/branches/trackManager/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/trackManager/src/story_entities/world.cc
r3505 r3515 240 240 241 241 trackManager->setBindSlave(TrackNode::getInstance()); 242 trackManager->condition(3, LEFTRIGHT, myPlayer); 242 243 TrackNode::getInstance()->addChild(myPlayer); 243 244 TrackNode::getInstance()->addChild(localCamera); -
orxonox/branches/trackManager/src/track_manager.cc
r3514 r3515 123 123 int TrackElement::random(void* nothing) 124 124 { 125 if (this->childCount == 0) 125 int i = (int)floor ((float)rand()/(float)RAND_MAX * (float)this->childCount); 126 if (i >= this->childCount) 127 return this->childCount-1; 128 else 129 return i; 130 } 131 132 133 int TrackElement::leftRight(void* node) 134 { 135 PNode* tmpNode = (PNode*)node; 136 137 if (tmpNode->relCoordinate.z < 0) 126 138 return 0; 127 else 128 { 129 int i = (int)floor ((float)rand()/(float)RAND_MAX * (float)this->childCount); 130 if (i >= this->childCount) 131 return this->childCount-1; 132 else 133 return i; 134 } 135 } 139 else 140 return 1; 141 } 142 143 144 // todo 145 int TrackElement::nearest(void* node) 146 { 147 PNode* tmpNode = (PNode*)node; 148 149 Vector nodeRelCoord = tmpNode->relCoordinate; 150 151 if (nodeRelCoord.z < 0) 152 return 0; 153 else 154 return 1; 155 } 156 136 157 137 158 … … 376 397 /** 377 398 \brief decides under what condition a certain Path will be chosen. 399 \param cond the CONDITION of the decision 400 \param subject the Subject that will be decided upon with CONDITION cond. 401 */ 402 void TrackManager::condition(CONDITION cond, void* subject) 403 { 404 this->condition(this->currentTrackElem->ID, cond, subject); 405 } 406 /** 407 \brief decides under what condition a certain Path will be chosen. 378 408 \param groupID the ID on which to choose the preceding move 379 \param cond \todo think about this 380 */ 381 void TrackManager::condition(unsigned int groupID, PathCondition cond) 382 { 409 \param cond the CONDITION of the decision 410 \param subject the Subject that will be decided upon with CONDITION cond. 411 */ 412 void TrackManager::condition(unsigned int groupID, CONDITION cond, void* subject) 413 { 414 TrackElement* tmpElem = this->findTrackElementByID(groupID); 383 415 384 } 416 switch (cond) 417 { 418 case LOWEST: 419 tmpElem->condFunc = &TrackElement::lowest; 420 break; 421 case HIGHEST: 422 tmpElem->condFunc = &TrackElement::highest; 423 break; 424 case RANDOM: 425 tmpElem->condFunc = &TrackElement::random; 426 break; 427 case LEFTRIGHT: 428 tmpElem->condFunc = &TrackElement::leftRight; 429 break; 430 case NEAREST: 431 tmpElem->condFunc = &TrackElement::nearest; 432 break; 433 case ENEMYKILLED: 434 break; 435 default: // same as LOWEST 436 tmpElem->condFunc = &TrackElement::lowest; 437 break; 438 } 439 tmpElem->subject=subject; 440 } 441 385 442 386 443 /** … … 588 645 int TrackManager::choosePath(TrackElement* trackElem) 589 646 { 590 return (trackElem->*(trackElem->condFunc))( NULL);647 return (trackElem->*(trackElem->condFunc))(trackElem->subject); 591 648 } 592 649 -
orxonox/branches/trackManager/src/track_manager.h
r3514 r3515 57 57 TrackElement** children; //!< A TrackElement can have a Tree of following TrackElements. 58 58 59 // CONDITION FUNCTIONS 59 // CONDITION FUNCTIONS and STUFF 60 void* subject; //!< The Subject the Condition should act upon. 60 61 int (TrackElement::*condFunc)(void*); //!< Pointer to the condition function 61 62 … … 63 64 int highest(void* nothing); 64 65 int random(void* nothing); 66 67 int leftRight(void* node); 68 int nearest(void* node); 69 int enemyKilled(void* entity); 65 70 }; 66 71 67 72 enum CONDITION {LOWEST, HIGHEST, RANDOM, LEFTRIGHT, NEAREST, ENEMYKILLED}; 68 73 69 74 //! The TrackManager handles the flow of the Players through the game. … … 134 139 void fork(unsigned int count, ...); 135 140 void forkV(unsigned int count, int* trackIDs); 136 void condition(unsigned int groupID, PathCondition cond); //!< \todo really do this!! 141 void condition(CONDITION cond, void* subject); 142 void condition(unsigned int groupID, CONDITION cond, void* subject); //!< \todo really do this!! 137 143 void join(unsigned int count, ...); 138 144 void joinV(unsigned int count, int* trackIDs);
Note: See TracChangeset
for help on using the changeset viewer.