Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 17, 2010, 5:01:54 PM (14 years ago)
Author:
jo
Message:

With additional tutorial messages in order to explain how the gametype works

File:
1 edited

Legend:

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

    r6848 r6921  
    2626 *
    2727 */
    28 //TODO: killers integrieren ; ArtificialController anpassen);
     28//TODO:
    2929//pig punkte vergeben pro Zeit!
    3030//killerfarbe schwarz; evtl. eigenes Raumfahrzeug;
     
    8181        this->tutorial=true;
    8282        this->pointsPerTime=0.0f;
     83        this->setHUDTemplate("DynamicmatchHUD");
     84
    8385    }
    8486
     
    101103
    102104    bool Dynamicmatch::allowPawnDamage(Pawn* victim, Pawn* originator)
    103     {   
     105    {   //TODO: static and fading message for the "human" player's
    104106        if (!originator||!victim)
    105         {return false;}
     107            return false;
     108        if (!!originator->getPlayer()||!victim->getPlayer())
     109            return false;
    106110        if (victim && victim->getPlayer()) //&& originator && originator->getPlayer() ??
    107111        {
     
    112116            if (notEnoughPigs)
    113117            {
    114                        
    115118                numberOf[target]--;                             //decrease numberof victims's party
    116119                playerParty_[victim->getPlayer()]=piggy;        //victim's new party: pig
    117120                setPlayerColour(victim->getPlayer());           //victim's new colour
    118121                numberOf[piggy]++;                              //party switch: number of players is not affected (decrease and increase)
     122                    if(tutorial)                                //announce party switch
     123                    {
     124                         std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(victim->getPlayer());
     125                         if (it2 != this->players_.end())
     126                         {
     127                              this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it2->first->getClientID());
     128                         }
     129                    }
    119130                    if (notEnoughKillers)                       //reward the originator
    120131                    {
     
    123134                        setPlayerColour(originator->getPlayer());               //originator's new colour
    124135                        numberOf[killer]++;
     136                        if(tutorial)                            //announce party switch
     137                        {
     138                             std::map<PlayerInfo*, Player>::iterator it3 = this->players_.find(originator->getPlayer());
     139                             if (it3 != this->players_.end())
     140                             {
     141                                  this->gtinfo_->sendStaticMessage("Take the chasers down.",it3->first->getClientID());
     142                             }
     143                        }
    125144                    }
    126145                evaluatePlayerParties();                        //check if the party change has to trigger futher party changes
     
    143162                setPlayerColour(victim->getPlayer());           //victim colour
    144163                numberOf[killer]++;                             //party switch: number of players is not affected (decrease and increase)
     164                if(tutorial)                            //announce party switch
     165                {
     166                     std::map<PlayerInfo*, Player>::iterator it3 = this->players_.find(originator->getPlayer());
     167                     if (it3 != this->players_.end())
     168                     {
     169                          this->gtinfo_->sendStaticMessage("Take the chasers down.",it3->first->getClientID());
     170                     }
     171                }
    145172                evaluatePlayerParties();                        //check if the party change has to trigger futher party changes
    146173            }
     
    152179                setPlayerColour(victim->getPlayer());           //victim colour
    153180                numberOf[chaser]++;                             //party switch: number of players is not affected (decrease and increase)
     181                if(tutorial)                                    //announce party switch
     182                {
     183                     std::map<PlayerInfo*, Player>::iterator it3 = this->players_.find(originator->getPlayer());
     184                     if (it3 != this->players_.end())
     185                     {
     186                          if (numberOf[killer]>0)
     187                              this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it3->first->getClientID());
     188                          else
     189                              this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it3->first->getClientID());
     190                     }
     191                }
    154192                evaluatePlayerParties();                        //check if the party change has to trigger futher party changes
    155193            }
     
    180218                setPlayerColour(victim->getPlayer()); //victim colour
    181219                setPlayerColour(originator->getPlayer());//originator colour
    182 
     220               
     221                //Announce pary switch
     222                if(tutorial)
     223                {
     224                     std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer());
     225                     if (it != this->players_.end())
     226                     {   
     227                          if (numberOf[killer]>0)
     228                              this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID());
     229                          else
     230                              this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID());
     231                     }
     232                     std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(victim->getPlayer());
     233                     if (it2 != this->players_.end())
     234                     {
     235                          this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it2->first->getClientID());
     236                     }
     237                }
    183238                //Give new pig boost
    184239                SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
     
    199254            setPlayerColour(victim->getPlayer());               //victim colour
    200255            setPlayerColour(originator->getPlayer());           //originator colour
     256             
     257            if(tutorial) //Announce pary switch
     258            {
     259                 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer());
     260                 if (it != this->players_.end())
     261                 {
     262                      this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID());
     263                 }
     264                 std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(victim->getPlayer());
     265                 if (it2 != this->players_.end())
     266                 {
     267                      this->gtinfo_->sendStaticMessage("Take the chasers down.",it2->first->getClientID());
     268                 }
     269                }
    201270            }
    202271            //Case: friendly fire
     
    286355        {   pointsPerTime =pointsPerTime + dt;
    287356            gameTime_ = gameTime_ - dt;
    288             if (pointsPerTime > 5)
     357            if (pointsPerTime > 3.0f)//hard coded!! should be changed
    289358            {
    290359                pointsPerTime=0.0f;
    291                
     360                rewardPig();
    292361            }
    293362            if (gameTime_<= 0)
     
    320389    void Dynamicmatch::rewardPig()
    321390    {
    322         //durch alle Spieler iterieren
    323         /*std::string message("Game started!");
    324             COUT(0) << message << std::endl;
    325             Host::Broadcast(message);*/
    326         // allen Spielern mit der Pig-party frags++
    327         ;
     391        for (std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden
     392        {
     393            if (it->second==piggy)
     394            {
     395                 //Spieler mit der Pig-party frags++
     396                 std::map<PlayerInfo*, Player>::iterator it2 = this->players_.find(it->first);// still not sure if right syntax
     397                 if (it2 != this->players_.end())
     398                 {
     399                     it2->second.frags_++;
     400                 }
     401            }
     402        }
    328403    }
    329404    void Dynamicmatch::setPlayerColour(PlayerInfo* player) // sets a players colour
     
    333408            if (pawn)
    334409            {
    335                 pawn->setRadarObjectColour(this->partyColours_[it_player->second]); //does this work? //what about playerParty_[it_player] instead of it_player->second
     410                pawn->setRadarObjectColour(this->partyColours_[it_player->second]);
    336411
    337412                std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
     
    350425    {
    351426        //pigs: 1 + every 6th player is a pig
    352         if ( (1+this->getNumberOfPlayers()/6) > numberOf[piggy]) {notEnoughPigs=true;}
    353         else {notEnoughPigs=false;}
     427        if ( (1+this->getNumberOfPlayers()/6) > numberOf[piggy])
     428        {
     429            notEnoughPigs=true;
     430            if (tutorial) // Announce selectionphase
     431            {
     432             for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     433                {
     434                    if (!it->first)//in order to catch nullpointer
     435                        continue;
     436                    if (it->first->getClientID() == CLIENTID_UNKNOWN)
     437                        continue;
     438                    this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID());
     439                }
     440            }
     441        }
     442        else
     443        {
     444             notEnoughPigs=false;
     445             if(tutorial&&(!notEnoughKillers)&&(!notEnoughChasers)) //Selection phase over
     446             {
     447                  for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     448                  {
     449                       if (!it->first)//in order to catch nullpointer
     450                           continue;
     451                       if (it->first->getClientID() == CLIENTID_UNKNOWN)
     452                           continue;
     453                       else if (it->second==chaser)
     454                       {
     455                           if (numberOf[killer]>0)
     456                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID());
     457                           else
     458                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID());
     459                       }
     460                       else if (it->second==piggy)
     461                           this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID());
     462                       else if (it->second==killer)
     463                           this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID());
     464                  }
     465                 
     466             }
     467        }
    354468        //killers: every 4th player is a killer
    355         if (getNumberOfPlayers()/4 > numberOf[killer]) {notEnoughKillers=true;}
    356         else {notEnoughKillers=false;}
     469        if (getNumberOfPlayers()/4 > numberOf[killer])
     470        {
     471            notEnoughKillers=true;
     472            if (tutorial) // Announce selectionphase
     473            {
     474             for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     475                {
     476                    if (!it->first)//in order to catch nullpointer
     477                        continue;
     478                    if (it->first->getClientID() == CLIENTID_UNKNOWN)
     479                        continue;
     480                    this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID());
     481                }
     482            }
     483        }
     484        else
     485        {
     486            notEnoughKillers=false;
     487            if(tutorial&&(!notEnoughPigs)&&(!notEnoughChasers)) //Selection phase over
     488             {
     489                  for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     490                  {
     491                       if (!it->first)
     492                           continue;
     493                       if (it->first->getClientID() == CLIENTID_UNKNOWN)
     494                           continue;
     495                       else if (it->second==chaser)
     496                       {
     497                           if (numberOf[killer]>0)
     498                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID());
     499                           else
     500                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID());
     501                       }
     502                       else if (it->second==piggy)
     503                           this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID());
     504                       else if (it->second==killer)
     505                           this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID());
     506                  }
     507                 
     508             }
     509           
     510        }
    357511        //chasers: there are more chasers than killers + pigs
    358         if (numberOf[piggy]+numberOf[killer] > numberOf[chaser]) {notEnoughChasers=true;}
    359         else {notEnoughChasers=false;} 
     512        if (numberOf[piggy]+numberOf[killer] > numberOf[chaser])
     513        {
     514            notEnoughChasers=true;
     515            if (tutorial) // Announce selectionphase
     516            {
     517             for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     518                {
     519                    if (!it->first)//in order to catch nullpointer
     520                        continue;
     521                    if (it->first->getClientID() == CLIENTID_UNKNOWN)
     522                        continue;
     523                    this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID());
     524                }
     525            }
     526        }
     527        else
     528        {
     529             notEnoughChasers=false;
     530             if(tutorial&&(!notEnoughPigs)&&(!notEnoughKillers)) //Selection phase over
     531             {
     532                  for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     533                  {
     534                       if (!it->first)
     535                           continue;
     536                       if (it->first->getClientID() == CLIENTID_UNKNOWN)
     537                           continue;
     538                       else if (it->second==chaser)
     539                       {
     540                           if (numberOf[killer]>0)
     541                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID());
     542                           else
     543                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID());
     544                       }
     545                       else if (it->second==piggy)
     546                           this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID());
     547                       else if (it->second==killer)
     548                           this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID());
     549                  }
     550                 
     551             }
     552        }       
    360553    }
    361554
     
    392585        if(!tutorial)
    393586        {
    394             std::string message("Game started!");
     587            std::string message("Dynamicmatch started!");
    395588            COUT(0) << message << std::endl;
    396589            Host::Broadcast(message);
    397590        }
    398         else if(tutorial) //in order to explain how this gametype works briefly
    399         {
    400             std::string tutotrialmessage("Shoot at other players as long as every player is red.\n\nIf you are fast enough you're spaceship will become green.\n\nIf you are hit you'll become blue.");
    401             COUT(0) << tutotrialmessage << std::endl;
    402             Host::Broadcast(tutotrialmessage);
    403             callInstructions_.setTimer(10, false, createExecutor(createFunctor(&Dynamicmatch::instructions, this)));
     591        else if(tutorial) // Announce selectionphase
     592        {
     593            for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     594            {
     595                if (it->first->getClientID() == CLIENTID_UNKNOWN)
     596                    continue;
     597                this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID());
     598            }
    404599        }
    405600    }   
    406601
    407     void Dynamicmatch::instructions()
     602    /*void Dynamicmatch::instructions()
    408603    {
    409604        std::string message("Earn points:\n\n\n\tIf you're red: Chase the blue player!\n\n\tIf you're blue shoot at a red player or hide.\n\n\tIf you're green: You've got the licence to kill red players!");
     
    418613        COUT(0) << message << std::endl;
    419614        Host::Broadcast(message);
    420     }
     615    }*/
    421616    void Dynamicmatch::end()
    422617    {
Note: See TracChangeset for help on using the changeset viewer.