Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 23, 2010, 11:22:22 PM (14 years ago)
Author:
jo
Message:

Last Man Standing already works basically. All game rules are implemented and seem to work as intended.

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

Legend:

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

    r7481 r7485  
    2626 *
    2727 */
    28 //Haupt-Problem: Wie kann ich Spieler vom Spiel ausschliessen, wenn sie alle Leben verlohren haben? (Kann man respawn unterbinden?)
    29 //Aktuelle Notloesung: Spieler wird unsichtbar und kann keinen Schaden austeilen, aber: setradarinvisibility funktioniert scheinbar nicht
    30 //Lösungsidee2: Spieler werden als passive Drohnen respawned, wenn sie keine Leben mehr haben (noch nicht implementiert)
    31 //
     28
    3229#include "LastManStanding.h"
    3330
     
    4643        RegisterObject(LastManStanding);
    4744        this->bForceSpawn_=true;
    48         this->lives=2;
     45        this->lives=4;
    4946        this->playersAlive=0;
    5047        this->timeRemaining=20.0f;
     
    5350    void LastManStanding::setConfigValues()
    5451    {
    55          SetConfigValue(lives, 2);
    56     }
    57 
    58     bool LastManStanding::allowPawnHit(Pawn* victim, Pawn* originator)
     52        SetConfigValue(lives, 4);
     53        SetConfigValue(timeRemaining, 20.0f);
     54    }
     55
     56    bool LastManStanding::allowPawnDamage(Pawn* victim, Pawn* originator)
    5957    {
    6058        if (originator && originator->getPlayer())// only for safety
    6159        {
    62             if(playerLives_[originator->getPlayer()]< 0) //dead players shouldn't be able to hit any pawn
    63                 return false;
    64         }
    65         return true;
    66     }
    67 
    68     bool LastManStanding::allowPawnDamage(Pawn* victim, Pawn* originator)
    69     {
    70         if (originator && originator->getPlayer())// only for safety
    71         {
    7260            this->timeToAct_[originator->getPlayer()]=timeRemaining;
    73             if(playerLives_[originator->getPlayer()]< 0) //dead players shouldn't be able to damage any pawn
    74                 return false;
    7561        }
    7662
     
    163149    }
    164150
    165     void LastManStanding::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)//makes dead players invisible
    166     {
    167         if (playerLives_[pawn->getPlayer()]<=0)//if player is dead
    168         {
    169             pawn->setVisible(false);
    170             pawn->setRadarVisibility(false);
    171             //removePlayer(pawn->getPlayer());
    172         }
    173     }
    174     void LastManStanding::pawnPostSpawn(Pawn* pawn)
    175     {/*
    176         if (playerLives_[pawn->getPlayer()]<=0)//if player is dead
    177         {
    178             pawn->setVisible(false);  --->Seltsames Verhalten, wenn diese Zeile aktiv ist
    179             pawn->setRadarVisibility(false);
    180         }  */
    181     }
    182 
    183151    void LastManStanding::pawnKilled(Pawn* victim, Pawn* killer)
    184152    {
     
    229197                Host::Broadcast(message);
    230198            }
    231             /*
    232                 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
    233                 if (victim->getCamera())
    234                 {
    235                     entity->setPosition(victim->getCamera()->getWorldPosition());
    236                     entity->setOrientation(victim->getCamera()->getWorldOrientation());
    237                 }
    238                 else
    239                 {
    240                     entity->setPosition(victim->getWorldPosition());
    241                     entity->setOrientation(victim->getWorldOrientation());
    242                 }
    243                 it->first->startControl(entity);*/
    244199        }
    245200    }
     
    267222    }
    268223
    269     /*void LastManStanding::removePlayer(PlayerInfo* player) //----------> Dieser Versuch führt zu einem Programmabsturz
    270     {
    271         std::map<PlayerInfo*, Player>::const_iterator it = this->players_.find(player);
    272         if (it != this->players_.end())
    273         {
    274             if (it->first->getControllableEntity())
    275             {
    276                 ControllableEntity* oldentity = it->first->getControllableEntity();
    277 
    278                 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity);
    279                 if (oldentity->getCamera())
    280                 {
    281                     entity->setPosition(oldentity->getCamera()->getWorldPosition());
    282                     entity->setOrientation(oldentity->getCamera()->getWorldOrientation());
    283                 }
    284                 else
    285                 {
    286                     entity->setPosition(oldentity->getWorldPosition());
    287                     entity->setOrientation(oldentity->getWorldOrientation());
    288                 }
    289 
    290                 it->first->startControl(entity);
    291             }
    292             else
    293                 this->spawnPlayerAsDefaultPawn(it->first);
    294         }
    295 
    296     }*/
     224    void LastManStanding::spawnDeadPlayersIfRequested()
     225    {
     226        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     227            if (it->second.state_ == PlayerState::Dead)
     228            {
     229                bool alive = (0<playerLives_[it->first]);
     230                if (alive&&(it->first->isReadyToSpawn() || this->bForceSpawn_))
     231                    this->spawnPlayer(it->first);
     232             }
     233    }
    297234
    298235}
  • code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h

    r7480 r7485  
    3131*/
    3232/* BY THE WAY
    33 //You have to add bots (or any other further players) before actually starting a match.
     33//!You have to ADD BOTS (or any other further players) BEFORE actually starting a match!
     34//Maybe a warning should be added in the menu, if a player starts a Last Man Standing match alone.
    3435//Whenever there is only on player in the game, this player will be declared as winner.
    35 //How "death" is managed: Death players become invisivle and aren't allowed to damage any player.
    36 //Though they can recieve damage and they are not invisible on the radar-
     36//How "death" is managed: dead players cannot respawn.
    3737*/
    3838#ifndef _LastManStanding_H__
     
    5555    */
    5656        protected:
    57             int lives; //!< Standard amount of lives.
     57            int lives; //!< Standard amount of lives. Each player starts a game with so many lives.
    5858            std::map< PlayerInfo*, int > playerLives_; //!< Each player's lives are stored here.
    5959            int playersAlive; //!< Counter counting players with more than 0 lives.
    6060            float timeRemaining; //!< Each player has a certain time where he or she has to hit an opponent or will be punished.
    6161            std::map<PlayerInfo*, float> timeToAct_; //!< Each player's time till she/he will be punished is stored here.
     62            virtual void spawnDeadPlayersIfRequested();
    6263
    6364        public:
     
    6667            void setConfigValues(); //!< Makes values configurable.
    6768
    68             virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0); //!< Prevents hits by players with no lives.
    69             virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an opponet, his punishment countdown will be resetted. Prevents damage by players with no lives.
     69            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an opponet, his punishment countdown will be resetted.
    7070            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each lives.
    7171
     
    7676            virtual bool playerChangedName(PlayerInfo* player);
    7777
    78             virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);//makes dead players invisible
    79             virtual void pawnPostSpawn(Pawn* pawn); //just for test case
    8078            virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
    8179
    8280            const int playerGetLives(PlayerInfo* player);
    8381            void killPlayer(PlayerInfo* player);
    84             //void removePlayer(PlayerInfo* player);
    8582            void tick (float dt);// used to end the game
    8683    };
Note: See TracChangeset for help on using the changeset viewer.