Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 30, 2011, 4:09:25 PM (12 years ago)
Author:
willis
Message:

added different Modes, debugging

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/formation/src/orxonox/controllers/HumanController.cc

    r8948 r8953  
    5151    SetConsoleCommand("HumanController", "rotateRoll",             &HumanController::rotateRoll    ).addShortcut().setAsInputCommand();
    5252    SetConsoleCommand("HumanController", "toggleFormationFlight",  &HumanController::toggleFormationFlight).addShortcut().keybindMode(KeybindMode::OnPress);
     53    SetConsoleCommand("HumanController", "FFChangeMode",  &HumanController::FFChangeMode).addShortcut().keybindMode(KeybindMode::OnPress);
    5354    SetConsoleCommand("HumanController", __CC_fire_name,           &HumanController::fire          ).addShortcut().keybindMode(KeybindMode::OnHold);
    5455    SetConsoleCommand("HumanController", "reload",                 &HumanController::reload        ).addShortcut();
     
    105106        if (HumanController::localController_s && HumanController::localController_s->state_==MASTER)
    106107        {
    107             HumanController::localController_s->commandSlaves();
     108            if (HumanController::localController_s->mode_!=ATTACK)
     109                HumanController::localController_s->commandSlaves();
    108110        }
    109111    }
     
    274276    }
    275277
     278    /**
     279    @brief
     280       toggle the formation. Not usable, if formationflight is disabled generally (formationFlight_)
     281    */
    276282    void HumanController::toggleFormationFlight()
    277283    {
    278        
    279         if (HumanController::localController_s)
    280         {
     284        if (HumanController::localController_s)
     285        {
     286            if (!HumanController::localController_s->formationFlight_)
     287            {
     288                return; //dont use when formationFlight is disabled
     289            }
    281290            if (HumanController::localController_s->state_==MASTER)
    282291            {
    283                 HumanController::localController_s->freeSlaves();
    284                 HumanController::localController_s->state_=FREE;
     292                HumanController::localController_s->loseMasterState();
    285293                orxout(message) <<"FormationFlight disabled "<< endl;
    286294            } else //SLAVE or FREE
     
    294302    }
    295303
     304    /**
     305    @brief
     306       Switch through the different Modes of formationflight. You must be a master of a formation to use.
     307    */
     308    void HumanController::FFChangeMode()
     309    {
     310        if (HumanController::localController_s && HumanController::localController_s->state_==MASTER)
     311        {
     312            switch (HumanController::localController_s->getMode()) {
     313              case NORMAL:
     314                HumanController::localController_s->setMode(DEFEND);
     315                orxout(message) <<"Mode: DEFEND "<< endl;
     316                break;
     317              case DEFEND:
     318                HumanController::localController_s->setMode(ATTACK);
     319                orxout(message) <<"Mode: ATTACK "<< endl;
     320                break;
     321              case ATTACK:
     322                HumanController::localController_s->setMode(NORMAL);
     323                orxout(message) <<"Mode: NORMAL "<< endl;
     324                break;
     325            }
     326            changedMode();
     327        }
     328    }
     329
     330    void HumanController::changedMode()
     331    {
     332
     333    }
     334   
    296335    void HumanController::addBots(unsigned int amount)
    297336    {
Note: See TracChangeset for help on using the changeset viewer.