Changeset 10024 for code/branches
- Timestamp:
- Apr 10, 2014, 1:15:58 PM (11 years ago)
- Location:
- code/branches/ScriptableController
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ScriptableController/data/levels/levelTry.oxw
r10009 r10024 112 112 113 113 <!-- Object, which orxouts the message "hello Universe!". EVENT NOT WORKING --> 114 < ScriptController_00position="0,0,0">114 <ControllerDirector position="0,0,0"> 115 115 <events> 116 116 <party> … … 120 120 </events> 121 121 122 </ ScriptController_00>122 </ControllerDirector> 123 123 124 124 -
code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.cc
r10016 r10024 1 1 /* 2 First try of a scriptController. Target: An event occurs in the levelTry.oxw file, which is "heard" by an object of the type of this class. It then SHOULD (because it is not working) execute the party function.2 First try of a ControllerDirector. Target: An event occurs in the levelTry.oxw file, which is "heard" by an object of the type of this class. It then SHOULD (because it is not working) execute the party function. 3 3 */ 4 4 5 #include " ScriptController.h"5 #include "ControllerDirector.h" 6 6 #include "core/CoreIncludes.h" 7 8 //#include "network/NetworkFunction.h" 9 10 #include "infos/HumanPlayer.h" 11 #include "interfaces/PlayerTrigger.h" 12 #include "worldentities/pawns/Pawn.h" 7 13 8 14 namespace orxonox 9 15 { 10 RegisterClass( ScriptController);16 RegisterClass(ControllerDirector); 11 17 12 ScriptController::ScriptController(Context* context) : ArtificialController(context)18 ControllerDirector::ControllerDirector(Context* context) : ArtificialController(context) 13 19 { 14 20 //Working 15 RegisterObject( ScriptController);21 RegisterObject(ControllerDirector); 16 22 orxout()<<"hello universe constructor"<< endl; 17 23 18 this->player_=NULL;19 this->entity_=NULL;20 this->pTrigger_=NULL;24 this->player_=NULL; 25 this->entity_=NULL; 26 this->pTrigger_=NULL; 21 27 } 22 28 23 bool ScriptController::party(bool bTriggered, BaseObject* trigger)29 bool ControllerDirector::party(bool bTriggered, BaseObject* trigger) 24 30 { 25 31 //XMLPortEventSink seems not to execute the party function … … 29 35 30 36 31 void ScriptController::XMLPort(Element& xmlelement, XMLPort::Mode mode)37 void ControllerDirector::XMLPort(Element& xmlelement, XMLPort::Mode mode) 32 38 { 33 SUPER( ScriptController, XMLPort, xmlelement, mode);39 SUPER(ControllerDirector, XMLPort, xmlelement, mode); 34 40 35 41 36 XMLPortEventSink(ScriptController, BaseObject, "party", party, xmlelement, mode);37 // Working38 42 orxout()<<"hello universe xmlport"<< endl; 39 43 } 40 44 41 void ScriptController::tick(float dt) 45 void ControllerDirector::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) 46 { 47 SUPER(ControllerDirector, XMLEventPort, xmlelement, mode); 48 49 XMLPortEventSink(ControllerDirector, BaseObject, "party", party, xmlelement, mode); 50 51 } 52 53 54 55 /* void ControllerDirector::tick(float dt) 42 56 { 43 57 … … 50 64 51 65 52 SUPER( ScriptController, tick, dt);66 SUPER(ControllerDirector, tick, dt); 53 67 } 54 68 55 void ScriptController::takeControl(Controller * controller, BaseObject * trigger) {69 */ 56 70 57 preparationToTakeControl(trigger); 58 setNewController(controller); 71 void ControllerDirector::takeControl(Controller * controller, BaseObject * trigger) { 59 72 60 } 73 preparationToTakeControl(trigger); 74 setNewController(controller); 75 76 } 61 77 62 78 63 bool ScriptController::preparationToTakeControl(BaseObject * trigger) {79 bool ControllerDirector::preparationToTakeControl(BaseObject * trigger) { 64 80 65 this->pTrigger_ = orxonox_cast<PlayerTrigger*>(trigger);81 this->pTrigger_ = orxonox_cast<PlayerTrigger*>(trigger); 66 82 this->player_ = NULL; 67 83 84 orxout() << "Preparation to take Control!" << endl; 68 85 // Check whether it is a player trigger and extract pawn from it 69 if( pTrigger!= NULL)86 if(this->pTrigger_ != NULL) 70 87 { 71 if(!pTrigger->isForPlayer()) { // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one. 72 orxout(verbose, context::docking) << "Docking:execute PlayerTrigger was not triggered by a player.." << endl; 73 return false; 74 } 75 player_ = pTrigger->getTriggeringPlayer(); //Get the object which triggered the event. 88 89 player_ = this->pTrigger_->getTriggeringPlayer(); //Get the object which triggered the event. 76 90 } 77 91 else 78 92 { 79 orxout( verbose, context::docking) << "Docking::executeNot a player trigger, can't extract pawn from it.." << endl;93 orxout() << "ControllerDirector::preparationToTakeControl Not a player trigger, can't extract pawn from it.." << endl; 80 94 return false; 81 95 } … … 85 99 assert(this->entity_); 86 100 101 return true; 102 87 103 } 88 104 89 void ScriptController::setNewController(Controller * controller) {105 void ControllerDirector::setNewController(Controller * controller) { 90 106 91 107 92 orxout(verbose) << "New Controller is going to be set!" << endl;108 orxout() << "New Controller is going to be set!" << endl; 93 109 94 this->entity_->setDestroyWhenPlayerLeft(false); 95 this->player_->pauseControl(); 96 this->entity_->setController(controller); 97 this->setControllableEntity(this->entity_); 110 this->entity_->setDestroyWhenPlayerLeft(false); 111 this->player_->pauseControl(); 112 this->entity_->setController(controller); 113 this->setControllableEntity(this->entity_); 114 115 } 98 116 99 117 100 118 101 } 102 103 104 119 } 105 120 106 121 /* Detaillierte Planung … … 134 149 135 150 136 } -
code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.h
r10020 r10024 45 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 46 bool party(bool bTriggered, BaseObject* trigger); 47 void tick(float dt); 47 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 48 49 50 48 51 void takeControl(Controller * controller, BaseObject * trigger); 49 52 bool preparationToTakeControl(BaseObject * trigger); 50 53 void setNewController(Controller * controller); 54 51 55 52 56 … … 55 59 PlayerInfo* player_; 56 60 57 61 ControllableEntity* entity_; 58 62 59 63 PlayerTrigger * pTrigger_;
Note: See TracChangeset
for help on using the changeset viewer.