Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6697


Ignore:
Timestamp:
Apr 12, 2010, 5:04:07 PM (14 years ago)
Author:
jo
Message:

boost feature added

Location:
code/branches/dynamicmatch/src/orxonox/gametypes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.cc

    r6692 r6697  
    3434#include "infos/PlayerInfo.h"
    3535#include "worldentities/pawns/Pawn.h"
     36#include "worldentities/pawns/SpaceShip.h"
    3637#include "core/ConfigValueIncludes.h"
    3738#include "interfaces/TeamColourable.h"
    38 //#include "Engine.h"
    39 //timer mit new erstellen
     39#include "items/Engine.h"
     40#include "tools/Timer.h"
     41
    4042namespace orxonox
    4143{
     
    5557    }
    5658
     59    void Dynamicmatch::setConfigValues()
     60    {
     61        SetConfigValue(gameTime_, 180);//just for test cases
     62        SetConfigValue(friendlyfire, true);
     63        static ColourValue colours[] =
     64        {
     65            ColourValue(0.3f, 0.3f, 1.0f),
     66            ColourValue(1.0f, 0.3f, 0.3f)
     67           
     68        };
     69        static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue));
     70
     71        SetConfigValue(partyColours_, defaultcolours);
     72    }
     73
    5774void Dynamicmatch::setPlayerColour(PlayerInfo* player) // not sure if this is the right place - helper function
    5875{
     
    8198}
    8299
    83 
    84 
    85 void Dynamicmatch::setConfigValues()
    86     {
    87         SetConfigValue(gameTime_, 180);//just for test cases
    88         SetConfigValue(friendlyfire, true);
    89         static ColourValue colours[] =
    90         {
    91             ColourValue(0.3f, 0.3f, 1.0f),
    92             ColourValue(1.0f, 0.3f, 0.3f)
    93            
    94         };
    95         static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue));
    96 
    97         SetConfigValue(partyColours_, defaultcolours);
    98     }
    99100
    100101bool Dynamicmatch::allowPawnDamage(Pawn* victim, Pawn* originator)//tested - works fine
     
    120121                        COUT(0) << messageVictim << std::endl;
    121122                        Host::Broadcast(messageVictim);
    122                 //party switch -> colour switch
    123                
    124                 setPlayerColour(victim->getPlayer()); //victim colour
    125                 setPlayerColour(originator->getPlayer());//orginator colour
     123
     124                        //party switch -> colour switch         
     125                        setPlayerColour(victim->getPlayer()); //victim colour
     126                        setPlayerColour(originator->getPlayer());//orginator colour
     127
     128                        //Give new pig boost
     129                        SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
     130                        if (spaceship && spaceship->getEngine())
     131                        {
     132                                spaceship->getEngine()->setSpeedFactor(5);
     133                                WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
     134                                new Timer(10, false, &createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this))->setDefaultValue(0, ptr), true);
     135                        }
     136
    126137                }
    127138                //Case 3: there are only chasers -> new piggy is needed
     
    131142                        onlyChasers=false;
    132143                        setPlayerColour(victim->getPlayer()); //victim colour
    133                 //victim - Boost ueber setBoostFactor(float factor) //vermutlich muss victim gecastet werden
    134                 // timer aufrufen - nach 5 Sekunden wieder auf normalgeschwindigkeit setzen
     144
     145                        //Give new pig boost
     146                        SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
     147                        if (spaceship && spaceship->getEngine())
     148                        {
     149                                spaceship->getEngine()->setSpeedFactor(5);
     150                                WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
     151                                new Timer(10, false, &createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this))->setDefaultValue(0, ptr), true);
     152                        }
     153
     154
    135155                std::string message("First victim.");
    136156                COUT(0) << message << std::endl;
     
    150170    }
    151171
    152        
    153    
     172void Dynamicmatch::resetSpeedFactor(WeakPtr<Engine>* ptr)
     173{
     174        if (*ptr)
     175        {
     176                (*ptr)->setSpeedFactor(1.0f);
     177        }
     178        delete ptr;
     179}
    154180
    155181bool Dynamicmatch::allowPawnDeath(Pawn* victim, Pawn* originator)//
     
    192218        if (!player)
    193219            return;
    194         playerParty_[player]=chaser;//playerparty
    195         // Set the playercolour
    196         Dynamicmatch::setPlayerColour(player);
     220        playerParty_[player]=chaser;//playerparty       
     221        Dynamicmatch::setPlayerColour(player); //Set playercolour
    197222    }
    198223
  • code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.h

    r6686 r6697  
    5858            virtual bool playerLeft(PlayerInfo* player);//ToDo: extract the player's party record - done?
    5959            virtual bool playerChangedName(PlayerInfo* player);//unchanged
     60
     61                void resetSpeedFactor(WeakPtr<Engine>* ptr);
    6062       
    6163           
Note: See TracChangeset for help on using the changeset viewer.