Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7636


Ignore:
Timestamp:
Nov 11, 2010, 1:35:49 AM (14 years ago)
Author:
landauf
Message:

compiles and works

Location:
code/branches/lastmanstanding
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/lastmanstanding/data/overlays/lastmanstandinghud.oxo

    r7635 r7636  
    2020     align    = "center"
    2121    />
    22     <!--LastManStandingInfos
     22    <LastManStandingInfos
    2323     position  = "0.63, 0.05"
    2424     pickpoint = "0.0, 0.0"
     
    3030     showlives     = true
    3131     showplayers     = false
    32     /-->
     32    />
    3333
    3434    <OverlayText
  • code/branches/lastmanstanding/src/modules/overlays/OverlaysPrereqs.h

    r7163 r7636  
    8888    class HUDTimer;
    8989    class KillMessage;
     90    class LastManStandingInfos;
    9091    class TeamBaseMatchScore;
    9192    class UnderAttackHealthBar;
  • code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.cc

    r7635 r7636  
    4343        RegisterObject(LastManStandingInfos);
    4444
    45         this->owner_ = 0;
     45        this->lms_ = 0;
     46        this->player_ = 0;
    4647        this->bShowLives_ = false;
    4748        this->bShowPlayers_ = false;
     
    6465        SUPER(LastManStandingInfos, tick, dt);
    6566
    66         if (this->owner_)
     67        if (this->player_ && this->lms_)
    6768        {
    68 
    69             Pawn* pawn = dynamic_cast<Pawn*>(this->getOwner()->getControllableEntity());
    70             /*LastManStanding* */ owner_ = dynamic_cast<LastManStanding*>(this->getOwner()->getGametype());
    71             int iLives = this->owner_->pawnGetLives(pawn);
    72             const std::string& lives = multi_cast<std::string>(iLives);
    73 
    74             const std::string& players = multi_cast<std::string>(this->owner_->playersAlive);
    75 
    7669            if (this->bShowLives_)
    7770            {
     71                const std::string& lives = multi_cast<std::string>(this->lms_->playerGetLives(this->player_));
    7872                this->setCaption(lives);
    7973            }
    8074            else if(this->bShowPlayers_)
    8175            {
     76                const std::string& players = multi_cast<std::string>(this->lms_->getNumPlayersAlive());
    8277                this->setCaption(players);
    8378            }
    8479        }
    8580    }
     81
     82    void LastManStandingInfos::changedOwner()
     83    {
     84        SUPER(LastManStandingInfos, changedOwner);
     85
     86        if (this->getOwner() && this->getOwner()->getGametype())
     87        {
     88            this->player_ = orxonox_cast<PlayerInfo*>(this->getOwner());
     89            this->lms_ = orxonox_cast<LastManStanding*>(this->getOwner()->getGametype().get());
     90        }
     91        else
     92        {
     93            this->player_ = 0;
     94            this->lms_ = 0;
     95        }
     96    }
    8697}
  • code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.h

    r7635 r7636  
    4545            virtual void tick(float dt);
    4646            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     47            virtual void changedOwner();
    4748
    4849            inline void setShowLives(bool value)
     
    5758
    5859        private:
    59             LastManStanding* owner_;
     60            LastManStanding* lms_;
     61            PlayerInfo* player_;
    6062            bool bShowLives_;
    6163            bool bShowPlayers_;
  • code/branches/lastmanstanding/src/orxonox/OrxonoxPrereqs.h

    r7163 r7636  
    9393    class Dynamicmatch;
    9494    class Gametype;
     95    class LastManStanding;
    9596    class TeamBaseMatch;
    9697    class TeamDeathmatch;
  • code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc

    r7635 r7636  
    147147    }
    148148
    149     int LastManStanding::pawnGetLives(Pawn* pawn)
    150     {
    151         if(!pawn)
    152             return -1;
    153         PlayerInfo* player= dynamic_cast<PlayerInfo*>(pawn);
    154         if(!player)
    155             return -2;
    156         return playerLives_[player];
    157     }
    158 
    159     const int LastManStanding::playerGetLives(PlayerInfo* player)
     149    int LastManStanding::playerGetLives(PlayerInfo* player)
    160150    {
    161151        if (player)
     
    163153        else
    164154            return 0;
     155    }
     156   
     157    int LastManStanding::getNumPlayersAlive() const
     158    {
     159        return this->playersAlive;
    165160    }
    166161
  • code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h

    r7635 r7636  
    7373
    7474            virtual void end(); //!< Sends an end message.
    75             virtual int pawnGetLives(Pawn* pawn); //!< Returns amount of Lives of a certain player.
    76             const int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
     75            int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
     76            int getNumPlayersAlive() const; //!< Returns the number of players that are still alive.
    7777            virtual void playerEntered(PlayerInfo* player); //!< Initializes values. Manages the gametype's HUD. #Players alive via StaticMessage.
    7878            virtual bool playerLeft(PlayerInfo* player); //!< Manages the gametype's HUD. #Players alive via StaticMessage.
Note: See TracChangeset for help on using the changeset viewer.