Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2768


Ignore:
Timestamp:
Mar 9, 2009, 3:21:12 AM (15 years ago)
Author:
landauf
Message:

added TeamGametype

Location:
code/branches/miniprojects/src/orxonox
Files:
6 added
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/miniprojects/src/orxonox/gamestates/GSLevel.cc

    r2710 r2768  
    4949namespace orxonox
    5050{
    51     SetCommandLineArgument(level, "presentation.oxw").shortcut("l");
     51    SetCommandLineArgument(level, "presentation_dm.oxw").shortcut("l");
    5252
    5353    GSLevel::GSLevel()
  • code/branches/miniprojects/src/orxonox/objects/CMakeLists.txt

    r2710 r2768  
    88  RadarListener.cc
    99  RadarViewable.cc
     10  Teamcolourable.cc
    1011  Tickable.cc
    1112  Test.cc
  • code/branches/miniprojects/src/orxonox/objects/Level.cc

    r2710 r2768  
    105105    {
    106106        Identifier* identifier = ClassByString(gametype);
    107         if (identifier && identifier->isA(Class(Gametype)))
     107
     108        if (!identifier || !identifier->isA(Class(Gametype)))
    108109        {
     110            COUT(0) << "Error: \"" << gametype << "\" is not a valid gametype." << std::endl;
     111            identifier = Class(Gametype);
     112            this->gametype_ = "Gametype";
     113        }
     114        else
    109115            this->gametype_ = gametype;
    110116
    111             Gametype* rootgametype = dynamic_cast<Gametype*>(identifier->fabricate(this));
    112             this->setGametype(rootgametype);
     117std::cout << "Load Gametype: " << this->gametype_ << std::endl;
    113118
    114             for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
    115                 (*it)->setGametype(rootgametype);
     119        Gametype* rootgametype = dynamic_cast<Gametype*>(identifier->fabricate(this));
     120        this->setGametype(rootgametype);
    116121
    117             if (LevelManager::getInstancePtr())
    118                 LevelManager::getInstance().requestActivity(this);
    119         }
     122std::cout << "root gametype: " << rootgametype->getIdentifier()->getName() << std::endl;
     123
     124        for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
     125            (*it)->setGametype(rootgametype);
     126
     127        if (LevelManager::getInstancePtr())
     128            LevelManager::getInstance().requestActivity(this);
    120129    }
    121130
  • code/branches/miniprojects/src/orxonox/objects/gametypes/CMakeLists.txt

    r2710 r2768  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    22  Gametype.cc
     3  TeamGametype.cc
    34)
  • code/branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc

    r2710 r2768  
    6666        this->setConfigValues();
    6767
    68         this->addBots(this->numberOfBots_);
    69 
    7068        // load the corresponding score board
    7169        if (Core::showsGraphics() && this->scoreboardTemplate_ != "")
     
    105103    void Gametype::start()
    106104    {
     105        this->addBots(this->numberOfBots_);
     106
    107107        COUT(0) << "game started" << std::endl;
    108108        this->gtinfo_.bStarted_ = true;
     
    166166    void Gametype::pawnPostSpawn(Pawn* pawn)
    167167    {
     168    }
     169
     170    void Gametype::playerPreSpawn(PlayerInfo* player)
     171    {
     172    }
     173
     174    void Gametype::playerPostSpawn(PlayerInfo* player)
     175    {
     176    }
     177
     178    bool Gametype::allowPawnHit(Pawn* victim, Pawn* originator)
     179    {
     180        return true;
     181    }
     182
     183    bool Gametype::allowPawnDamage(Pawn* victim, Pawn* originator)
     184    {
     185        return true;
     186    }
     187
     188    bool Gametype::allowPawnDeath(Pawn* victim, Pawn* originator)
     189    {
     190        return true;
    168191    }
    169192
     
    336359        if (spawnpoint)
    337360        {
     361            this->playerPreSpawn(player);
    338362            player->startControl(spawnpoint->spawn());
    339363            this->players_[player].state_ = PlayerState::Alive;
     364            this->playerPostSpawn(player);
    340365        }
    341366        else
  • code/branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h

    r2662 r2768  
    9191            virtual void playerScored(Player& player);
    9292
     93            virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
     94            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);
     95            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
     96
    9397            virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
    9498            virtual void pawnPreSpawn(Pawn* pawn);
    9599            virtual void pawnPostSpawn(Pawn* pawn);
     100            virtual void playerPreSpawn(PlayerInfo* player);
     101            virtual void playerPostSpawn(PlayerInfo* player);
    96102
    97103            inline const std::map<PlayerInfo*, Player>& getPlayers() const
     
    112118                { return this->players_.size(); }
    113119
    114         private:
     120        protected:
    115121            virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
    116122
  • code/branches/miniprojects/src/orxonox/objects/worldentities/Billboard.h

    r2662 r2768  
    3434#include "util/Math.h"
    3535#include "tools/BillboardSet.h"
     36#include "objects/Teamcolourable.h"
    3637
    3738namespace orxonox
    3839{
    39     class _OrxonoxExport Billboard : public StaticEntity
     40    class _OrxonoxExport Billboard : public StaticEntity, public Teamcolourable
    4041    {
    4142        public:
     
    6162                { return this->colour_; }
    6263
     64            virtual void setTeamColour(const ColourValue& colour)
     65                { this->setColour(colour); }
     66
    6367        protected:
    6468            inline BillboardSet& getBillboardSet()
  • code/branches/miniprojects/src/orxonox/objects/worldentities/CMakeLists.txt

    r2710 r2768  
    1919  Planet.cc
    2020  SpawnPoint.cc
     21  TeamSpawnPoint.cc
    2122)
    2223
  • code/branches/miniprojects/src/orxonox/objects/worldentities/Light.h

    r2662 r2768  
    3737
    3838#include "util/Math.h"
     39#include "objects/Teamcolourable.h"
    3940
    4041namespace orxonox
    4142{
    42     class _OrxonoxExport Light : public StaticEntity
     43    class _OrxonoxExport Light : public StaticEntity, public Teamcolourable
    4344    {
    4445        public:
     
    6869            inline const ColourValue& getSpecularColour() const
    6970                { return this->specular_; }
     71
     72            virtual void setTeamColour(const ColourValue& colour)
     73                { this->setDiffuseColour(colour); this->setSpecularColour(colour); }
    7074
    7175            /**
  • code/branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2662 r2768  
    140140    void Pawn::damage(float damage, Pawn* originator)
    141141    {
    142         this->setHealth(this->health_ - damage);
    143         this->lastHitOriginator_ = originator;
    144 
    145         // play damage effect
     142        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
     143        {
     144            this->setHealth(this->health_ - damage);
     145            this->lastHitOriginator_ = originator;
     146
     147            // play damage effect
     148        }
    146149    }
    147150
    148151    void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
    149152    {
    150         this->damage(damage, originator);
    151         this->setVelocity(this->getVelocity() + force);
    152 
    153         // play hit effect
     153        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))
     154        {
     155            this->damage(damage, originator);
     156            this->setVelocity(this->getVelocity() + force);
     157
     158            // play hit effect
     159        }
    154160    }
    155161
     
    176182    void Pawn::death()
    177183    {
    178         // Set bAlive_ to false and wait for PawnManager to do the destruction
    179         this->bAlive_ = false;
    180 
    181         this->setDestroyWhenPlayerLeft(false);
    182 
    183         if (this->getGametype())
    184             this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
    185 
    186         if (this->getPlayer())
    187             this->getPlayer()->stopControl(this);
    188 
    189         if (Core::isMaster())
    190             this->deatheffect();
     184        if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
     185        {
     186            // Set bAlive_ to false and wait for PawnManager to do the destruction
     187            this->bAlive_ = false;
     188
     189            this->setDestroyWhenPlayerLeft(false);
     190
     191            if (this->getGametype())
     192                this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
     193
     194            if (this->getPlayer())
     195                this->getPlayer()->stopControl(this);
     196
     197            if (Core::isMaster())
     198                this->deatheffect();
     199        }
     200        else
     201            this->setHealth(1);
    191202    }
    192203
Note: See TracChangeset for help on using the changeset viewer.