Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 25, 2010, 11:11:04 PM (14 years ago)
Author:
jo
Message:

Changed inheritance. instead of Gametype it's Deathmatch.

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

Legend:

Unmodified
Added
Removed
  • code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc

    r7581 r7583  
    4040    CreateUnloadableFactory(LastManStanding);
    4141
    42     LastManStanding::LastManStanding(BaseObject* creator) : Gametype(creator)
     42    LastManStanding::LastManStanding(BaseObject* creator) : Deathmatch(creator)
    4343    {
    4444        RegisterObject(LastManStanding);
     
    7474            this->timeToAct_[originator->getPlayer()]=timeRemaining;
    7575        }
    76 
    7776        return true;
    7877    }
     
    9392    }
    9493
    95     void LastManStanding::start()
    96     {
    97         Gametype::start();
    98 
    99         std::string message("Try to survive!");
    100         COUT(0) << message << std::endl;
    101         Host::Broadcast(message);
    102     }
    103 
    10494    void LastManStanding::end()
    10595    {
     
    122112        if (!player)// only for safety
    123113            return;
    124         Gametype::playerEntered(player);
     114        Deathmatch::playerEntered(player);
    125115
    126116        playerLives_[player]=lives;
    127117        this->playersAlive++;
    128118        this->timeToAct_[player]=timeRemaining;
    129         const std::string& message = player->getName() + " entered the game";
    130         COUT(0) << message << std::endl;
    131         Host::Broadcast(message);
    132119        //Update: EachPlayer's "Players in Game"-HUD
    133120        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     
    138125            this->gtinfo_->sendStaticMessage(message1,it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
    139126        }
    140        
    141127    }
    142128
    143129    bool LastManStanding::playerLeft(PlayerInfo* player)
    144130    {
    145         bool valid_player = Gametype::playerLeft(player);
    146 
     131        bool valid_player = Deathmatch::playerLeft(player);
    147132        if (valid_player)
    148133        {
    149134            this->playersAlive--;
    150135            //this->playerLives_[player].erase (player); not necessary?
    151             //
    152             const std::string& message = player->getName() + " left the game";
    153             COUT(0) << message << std::endl;
    154             Host::Broadcast(message);
    155136            //Update: EachPlayer's "Players in Game"-HUD
    156137            for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     
    166147    }
    167148
    168     bool LastManStanding::playerChangedName(PlayerInfo* player)
    169     {
    170         bool valid_player = Gametype::playerChangedName(player);
    171 
    172         if (valid_player)
    173         {
    174             const std::string& message = player->getOldName() + " changed name to " + player->getName();
    175             COUT(0) << message << std::endl;
    176             Host::Broadcast(message);
    177         }
    178 
    179         return valid_player;
    180     }
    181 
    182149    void LastManStanding::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)
    183150    {
     
    190157            const std::string& message = "Your Lives: " +multi_cast<std::string>(playerLives_[player]);
    191158            this->gtinfo_->sendFadingMessage(message,it2->first->getClientID());
    192 
    193159        }
    194160    }
     
    204170            this->gtinfo_->sendStaticMessage(message1,it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
    205171        }
    206    
    207     }
    208 
    209     void LastManStanding::pawnKilled(Pawn* victim, Pawn* killer)
    210     {
    211         if (victim && victim->getPlayer())
    212         {
    213             std::string message;
    214             if (killer)
    215             {
    216                 if (killer->getPlayer())
    217                     message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
    218                 else
    219                     message = victim->getPlayer()->getName() + " was killed";
    220             }
    221             else
    222                 message = victim->getPlayer()->getName() + " died";
    223 
    224             COUT(0) << message << std::endl;
    225             Host::Broadcast(message);
    226         }
    227 
    228         Gametype::pawnKilled(victim, killer);
    229172    }
    230173
  • code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h

    r7579 r7583  
    3535
    3636#include "OrxonoxPrereqs.h"
    37 #include "Gametype.h"
     37#include "Deathmatch.h"
    3838#include <map>
    3939#include <vector>
     
    4141namespace orxonox
    4242{
    43     class _OrxonoxExport LastManStanding : public Gametype
     43    class _OrxonoxExport LastManStanding : public Deathmatch
    4444    {
    4545    /**
     
    6565            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each players lives.
    6666
    67             virtual void start(); //!< Sends a start message.
    6867            virtual void end(); //!< Sends an end message.
    6968            virtual void playerEntered(PlayerInfo* player); //!< Initializes values. Manages the gametype's HUD. #Players alive via StaticMessage.
    7069            virtual bool playerLeft(PlayerInfo* player); //!< Manages the gametype's HUD. #Players alive via StaticMessage.
    71             virtual bool playerChangedName(PlayerInfo* player);
    7270            virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn); //!< Manages the gametype's HUD. player's lives via FadingMessage.
    7371            virtual void playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn);  //!< Manages the gametype's HUD. #Players alive via StaticMessage.
    74             virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
    7572
    7673            const int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
Note: See TracChangeset for help on using the changeset viewer.