Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6921


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

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

Location:
code/branches/dynamicmatch/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/dynamicmatch/src/modules/overlays/hud/CMakeLists.txt

    r5781 r6921  
    1313  UnderAttackHealthBar.cc
    1414  TeamBaseMatchScore.cc
     15  GametypeStaticMessage.cc
     16  GametypeFadingMessage.cc
    1517)
  • 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    {
  • code/branches/dynamicmatch/src/orxonox/gametypes/Dynamicmatch.h

    r6848 r6921  
    4747            bool notEnoughKillers;
    4848            bool notEnoughChasers;
     49
     50            //three different parties   
     51            int chaser;
     52            int piggy;
     53            int killer;
     54
    4955            virtual void evaluatePlayerParties();
    5056            int getParty(PlayerInfo* player);
    5157            void setPlayerColour(PlayerInfo* player);//own function
    5258            void setConfigValues();//done
     59           
     60            bool friendlyfire; //goal: player can switch it on/off
     61            bool tutorial; //goal: new players recieve messages how the new gametype works - later it can be switched off.
     62           
    5363            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //ok - score function and management of parties
    5464            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //ok - simple
     
    5969            virtual bool playerLeft(PlayerInfo* player);
    6070            virtual bool playerChangedName(PlayerInfo* player);//unchanged
    61             virtual void instructions();
    62             virtual void furtherInstructions();
     71           
     72            /*virtual void instructions();
     73            virtual void furtherInstructions();*/
    6374            virtual void rewardPig();
    6475            void resetSpeedFactor(WeakPtr<Engine>* ptr); 
    6576            void tick (float dt);// used to end the game
    6677            SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
    67             //three different parties   
    68             int chaser;
    69             int piggy;
    70             int killer;
    71                
    72             bool friendlyfire; //goal: player can switch it on/off
    73             bool tutorial; //goal: new players recieve messages how the new gametype works - later it can be switched off.
     78           
    7479        protected:
    75                  
    76                  
     80
    7781            std::map< PlayerInfo*, int > playerParty_; //player's parties are recorded here
    7882            std::vector<ColourValue> partyColours_; //aus TeamDeathmatch
     
    8286            bool gameEnded_; // true if game is over
    8387            int timesequence_; //used for countdown
    84             Timer callInstructions_;
     88            //Timer callInstructions_;
    8589    };
    8690}
  • code/branches/dynamicmatch/src/orxonox/infos/GametypeInfo.cc

    r5781 r6921  
    4242    registerMemberNetworkFunction(GametypeInfo, dispatchKillMessage);
    4343    registerMemberNetworkFunction(GametypeInfo, dispatchDeathMessage);
     44    registerMemberNetworkFunction(GametypeInfo, dispatchStaticMessage);
     45    registerMemberNetworkFunction(GametypeInfo, dispatchFadingMessage);
    4446
    4547    GametypeInfo::GametypeInfo(BaseObject* creator) : Info(creator)
     
    110112    }
    111113
     114    void GametypeInfo::sendStaticMessage(const std::string& message, unsigned int clientID)
     115    {
     116        if (GameMode::isMaster())
     117        {
     118            if (clientID == CLIENTID_SERVER)
     119                this->dispatchStaticMessage(message);
     120            else
     121                callMemberNetworkFunction(GametypeInfo, dispatchStaticMessage, this->getObjectID(), clientID, message);
     122        }
     123    }
     124
     125    void GametypeInfo::sendFadingMessage(const std::string& message, unsigned int clientID)
     126    {
     127        if (GameMode::isMaster())
     128        {
     129            if (clientID == CLIENTID_SERVER)
     130                this->dispatchFadingMessage(message);
     131            else
     132                callMemberNetworkFunction(GametypeInfo, dispatchFadingMessage, this->getObjectID(), clientID, message);
     133        }
     134    }
     135
    112136    void GametypeInfo::dispatchAnnounceMessage(const std::string& message)
    113137    {
     
    127151            it->deathmessage(this, message);
    128152    }
     153
     154     void GametypeInfo::dispatchStaticMessage(const std::string& message)
     155    {
     156        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     157            it->staticmessage(this, message);
     158    }
     159   
     160     void GametypeInfo::dispatchFadingMessage(const std::string& message)
     161    {
     162        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     163            it->fadingmessage(this, message);
     164    }
    129165}
  • code/branches/dynamicmatch/src/orxonox/infos/GametypeInfo.h

    r5781 r6921  
    6464            void sendKillMessage(const std::string& message, unsigned int clientID);
    6565            void sendDeathMessage(const std::string& message, unsigned int clientID);
     66            void sendStaticMessage(const std::string& message, unsigned int clientID);
     67            void sendFadingMessage(const std::string& message, unsigned int clientID);
    6668
    6769            void dispatchAnnounceMessage(const std::string& message);
    6870            void dispatchKillMessage(const std::string& message);
    6971            void dispatchDeathMessage(const std::string& message);
     72            void dispatchStaticMessage(const std::string& message);
     73            void dispatchFadingMessage(const std::string& message);
    7074
    7175        private:
  • code/branches/dynamicmatch/src/orxonox/interfaces/GametypeMessageListener.h

    r5781 r6921  
    4444            virtual void killmessage(const GametypeInfo* gtinfo, const std::string& message) {}
    4545            virtual void deathmessage(const GametypeInfo* gtinfo, const std::string& message) {}
     46            virtual void staticmessage(const GametypeInfo* gtinfo, const std::string& message) {}
     47            virtual void fadingmessage(const GametypeInfo* gtinfo, const std::string& message) {}
    4648    };
    4749}
Note: See TracChangeset for help on using the changeset viewer.