Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2012, 11:08:17 PM (12 years ago)
Author:
landauf
Message:

merged branch presentation2012merge back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gametypes/Dynamicmatch.cc

    r8858 r9348  
    3131//Low; Codeoptimierung und Dokumentation
    3232
    33 /*
    34 short gaming manual:
    35 There are three different parties a player can belong to: victim, chaser or killer
    36 Every player starts as chaser. As long as there are not enough victims and killers, you can change your and other player's parties by shooting them.
    37 In order to win you have to earn as much points as possible:
    38 - as victim by escaping the chasers
    39 - as chaser by shooting the victim
    40 - as killer by killing the chasers
    41 
    42 
    43 What you shouldn't do is shooting at players of your own party. By doing so your score will decrease.
    44 P.S: If you don't want to be a victim: Get rid of your part by shooting a chaser.
     33/**
     34@brief
     35    Short Gaming Manual:
     36    There are three different parties a player can belong to: victim, chaser or killer
     37    Every player starts as chaser. As long as there are not enough victims and killers, you can change your and other player's parties by shooting them.
     38    In order to win you have to earn as much points as possible:
     39    - as victim by escaping the chasers
     40    - as chaser by shooting the victim
     41    - as killer by killing the chasers
     42
     43
     44    What you shouldn't do is shooting at players of your own party. By doing so your score will decrease.
     45    P.S: If you don't want to be a victim: Get rid of your part by shooting a chaser.
    4546*/
    4647#include "Dynamicmatch.h"
     
    8182        this->numberOf[killer]=0;
    8283        this->tutorial=true;
    83         this->pointsPerTime=0.0f;
     84        this->pointsPerTime=1.0f;
    8485        this->setHUDTemplate("DynamicmatchHUD");
    8586    }
     
    9596            ColourValue(0.3f, 0.3f, 1.0f),  //piggycolour
    9697            ColourValue(0.3f, 1.0f, 0.3f)   //killercolour  what about black: 0.0f, 0.0f, 0.0f
    97 
    9898        };
    9999        static std::vector<ColourValue> defaultcolours(colours, colours + sizeof(colours) / sizeof(ColourValue));
     
    111111        if (victim && victim->getPlayer()) //&& originator && originator->getPlayer() ??
    112112        {
    113         int target= playerParty_[victim->getPlayer()];
    114         int source= playerParty_[originator->getPlayer()];
     113            int target = playerParty_[victim->getPlayer()];
     114            int source = playerParty_[originator->getPlayer()];
    115115
    116116            //Case: Not Enough Pigs: party change (= party management)
     
    151151
    152152                //Give new pig boost
    153                 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
     153                SpaceShip* spaceship = orxonox_cast<SpaceShip*>(victim);
    154154                this->grantPigBoost(spaceship);
    155155            }
     
    245245                }
    246246                //Give new pig boost
    247                 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
     247                SpaceShip* spaceship = orxonox_cast<SpaceShip*>(victim);
    248248                this->grantPigBoost(spaceship);
    249249            }
     
    276276            else if (friendlyfire && (source == target))
    277277            {
    278                 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer());
    279                 if (it != this->players_.end())
    280                     {
    281                         it->second.frags_--;
    282                     }
    283             }
    284         }// from far far away not to be removed!
     278                    this->playerScored(originator->getPlayer(), -1);
     279            }
     280        }
    285281        return false; //default: no damage
    286282    }
     
    296292            if (playerParty_[originator->getPlayer()] == killer) //reward the killer
    297293            {
    298                 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer());
    299                 if (it != this->players_.end())
    300                 {
    301                     it->second.frags_+=20; //value must be tested
    302                 }
    303             }
    304         return true;
     294                    this->playerScored(originator->getPlayer(), 25);
     295            }
     296            return true;
    305297        }
    306298        else return false;
     
    309301    /**
    310302    @brief
    311         Grant the piggy a boost.
     303        Grant the victim a boost.
    312304    @param spaceship
    313305        The SpaceShip to give the boost.
     
    315307    void Dynamicmatch::grantPigBoost(SpaceShip* spaceship)
    316308    {
    317         // Give pig boost
     309        // Give victim boost
    318310        if (spaceship)
    319311        {
     312            WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);
     313            if(ptr == NULL)
     314                return;
    320315            spaceship->addSpeedFactor(5);
    321             WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);
    322316            ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
    323317            executor->setDefaultValue(0, ptr);
     
    374368
    375369        if (this->hasStarted() && !gameEnded_)
    376         {   pointsPerTime =pointsPerTime + dt;
    377             gameTime_ = gameTime_ - dt;
    378             if (pointsPerTime > 2.0f)//hard coded!! should be changed
    379             {
    380                 pointsPerTime=0.0f;
     370        {
     371            pointsPerTime = pointsPerTime + dt; //increase points
     372            gameTime_ = gameTime_ - dt; // decrease game time
     373            if (pointsPerTime > 2.0f) //hard coded points for victim! should be changed
     374            {
     375                pointsPerTime = 0.0f;
    381376                rewardPig();
    382377            }
     
    408403    }
    409404
     405/**
     406    @brief The reward function is called every 2 seconds via the tick function and makes the victim score points.
     407*/
    410408    void Dynamicmatch::rewardPig()
    411409    {
    412410        for (std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden
    413411        {
    414             if (it->second==piggy)
    415             {
    416                  //Spieler mit der Pig-party frags++
    417                  std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(it->first);// still not sure if right syntax
    418                  if (it2 != this->players_.end())
    419                  {
    420                      it2->second.frags_++;
    421                  }
     412            if (it->second==piggy)//Spieler mit der Pig-party frags++
     413            {
     414                 this->playerScored(it->first);
    422415            }
    423416        }
     
    426419    {
    427420        std::map<PlayerInfo*, int>::const_iterator it_player = this->playerParty_.find(player);
    428         Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());
     421        Pawn* pawn = orxonox_cast<Pawn*>(player->getControllableEntity());
    429422            if (pawn)
    430423            {
     
    446439    {
    447440        //pigs: 1 + every 6th player is a pig
    448         if ( (1+this->getNumberOfPlayers()/6) > numberOf[piggy])
     441        if ( (1 + getPlayerCount()/6) > numberOf[piggy])
    449442        {
    450443            notEnoughPigs=true;
     
    495488        }
    496489        //killers: every 4th player is a killer
    497         if (getNumberOfPlayers()/4 > numberOf[killer])
     490        if ( static_cast<unsigned int>(getPlayerCount()/4) > numberOf[killer])
    498491        {
    499492            notEnoughKillers=true;
Note: See TracChangeset for help on using the changeset viewer.