Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10024 for code/branches


Ignore:
Timestamp:
Apr 10, 2014, 1:15:58 PM (11 years ago)
Author:
mkronig
Message:

changes on controllerDirector project

Location:
code/branches/ScriptableController
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ScriptableController/data/levels/levelTry.oxw

    r10009 r10024  
    112112
    113113<!-- Object, which orxouts the message "hello Universe!". EVENT NOT WORKING  -->
    114     <ScriptController_00 position="0,0,0">
     114    <ControllerDirector position="0,0,0">
    115115        <events>
    116116            <party>
     
    120120        </events>
    121121
    122     </ScriptController_00>
     122    </ControllerDirector>
    123123
    124124
  • code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.cc

    r10016 r10024  
    11/*
    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.
     2First 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.
    33 */
    44
    5 #include "ScriptController.h"
     5#include "ControllerDirector.h"
    66#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"
    713
    814namespace orxonox
    915{
    10     RegisterClass(ScriptController);
     16    RegisterClass(ControllerDirector);
    1117
    12     ScriptController::ScriptController(Context* context) : ArtificialController(context)
     18    ControllerDirector::ControllerDirector(Context* context) : ArtificialController(context)
    1319    {
    1420        //Working
    15         RegisterObject(ScriptController);
     21        RegisterObject(ControllerDirector);
    1622        orxout()<<"hello universe constructor"<< endl;
    1723
    18         this->player_=NULL;
    19         this->entity_=NULL;
    20         this->pTrigger_=NULL;
     24           this->player_=NULL;
     25           this->entity_=NULL;
     26           this->pTrigger_=NULL;
    2127    }
    2228
    23     bool ScriptController::party(bool bTriggered, BaseObject* trigger)
     29    bool ControllerDirector::party(bool bTriggered, BaseObject* trigger)
    2430       {
    2531           //XMLPortEventSink seems not to execute the party function
     
    2935
    3036
    31     void ScriptController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     37    void ControllerDirector::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    3238    {
    33         SUPER(ScriptController, XMLPort, xmlelement, mode);
     39        SUPER(ControllerDirector, XMLPort, xmlelement, mode);
    3440
    3541       
    36         XMLPortEventSink(ScriptController, BaseObject, "party", party, xmlelement, mode);
    37         // Working
    3842        orxout()<<"hello universe xmlport"<< endl;
    3943    }
    4044
    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)
    4256    {
    4357
     
    5064       
    5165
    52         SUPER(ScriptController, tick, dt);
     66        SUPER(ControllerDirector, tick, dt);
    5367    }
    5468
    55     void ScriptController::takeControl(Controller * controller, BaseObject * trigger) {
     69    */
    5670
    57         preparationToTakeControl(trigger);
    58         setNewController(controller);
     71    void ControllerDirector::takeControl(Controller * controller, BaseObject * trigger) {
    5972
    60     }
     73        preparationToTakeControl(trigger);
     74        setNewController(controller);
     75
     76    }
    6177
    6278       
    63     bool ScriptController::preparationToTakeControl(BaseObject * trigger) {
     79    bool ControllerDirector::preparationToTakeControl(BaseObject * trigger) {
    6480
    65         this->pTrigger_ = orxonox_cast<PlayerTrigger*>(trigger);
     81            this->pTrigger_ = orxonox_cast<PlayerTrigger*>(trigger);
    6682        this->player_ = NULL;
    6783
     84        orxout() << "Preparation to take Control!" << endl;
    6885        // Check whether it is a player trigger and extract pawn from it
    69         if(pTrigger != NULL)
     86        if(this->pTrigger_ != NULL)
    7087        {
    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.
    7690        }
    7791        else
    7892        {
    79             orxout(verbose, context::docking) << "Docking::execute Not 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;
    8094            return false;
    8195        }
     
    8599        assert(this->entity_);
    86100
     101    return true;
     102
    87103    }
    88104
    89     void ScriptController::setNewController(Controller * controller) {
     105    void ControllerDirector::setNewController(Controller * controller) {
    90106
    91107
    92             orxout(verbose) << "New Controller is going to be set!" << endl;
     108        orxout() << "New Controller is going to be set!" << endl;
    93109
    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    }
    98116       
    99117   
    100118
    101     }
    102 
    103  
    104 
     119}
    105120
    106121/* Detaillierte Planung
     
    134149
    135150
    136 }
  • code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.h

    r10020 r10024  
    4545            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4646            bool party(bool bTriggered, BaseObject* trigger);
    47             void tick(float dt);
     47            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
     48       
     49       
     50       
    4851            void takeControl(Controller * controller, BaseObject * trigger);
    4952            bool preparationToTakeControl(BaseObject * trigger);
    5053            void setNewController(Controller * controller);
     54       
    5155
    5256
     
    5559           PlayerInfo* player_;
    5660
    57            ControllableEntity* entity_;
     61           ControllableEntity* entity_;
    5862
    5963           PlayerTrigger * pTrigger_;
Note: See TracChangeset for help on using the changeset viewer.