Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3033


Ignore:
Timestamp:
May 23, 2009, 9:57:52 PM (15 years ago)
Author:
landauf
Message:

merged gametypes branch back to trunk

Location:
code/trunk
Files:
23 edited
16 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r2911 r3033  
    138138    class MovableEntity;
    139139    class Sublevel;
     140    class ForceField;
    140141
    141142    class Model;
     
    162163    class Pawn;
    163164    class SpaceShip;
     165    class TeamBaseMatchBase;
     166    class Destroyer;
    164167
    165168    class Item;
     
    172175    class EventTrigger;
    173176    class PlayerTrigger;
     177    class CheckPoint;
    174178
    175179    class WeaponSystem;
     
    204208    class Deathmatch;
    205209    class TeamDeathmatch;
     210    class Asteroids;
     211    class TeamBaseMatch;
     212    class UnderAttack;
    206213    class Pong;
    207214
     
    236243    class HUDSpeedBar;
    237244    class HUDHealthBar;
     245    class HUDTimer;
    238246    class InGameConsole;
    239247    class Notification;
  • code/trunk/src/orxonox/objects/gametypes/CMakeLists.txt

    r2826 r3033  
    33  Deathmatch.cc
    44  TeamDeathmatch.cc
     5  TeamBaseMatch.cc
    56  Pong.cc
     7  UnderAttack.cc
     8  Asteroids.cc
    69)
  • code/trunk/src/orxonox/objects/gametypes/Gametype.cc

    r2896 r3033  
    6060        this->numberOfBots_ = 0;
    6161
     62        this->timeLimit_ = 0;
     63        this->time_ = 0;
     64        this->timerIsActive_ = false;
     65
    6266        this->initialStartCountdown_ = 3;
    6367
     
    8892        SUPER(Gametype, tick, dt);
    8993
     94        //count timer
     95        if (timerIsActive_)
     96        {
     97            if (this->timeLimit_ == 0)
     98                this->time_ += dt;
     99            else
     100                this->time_ -= dt;
     101        }
     102
    90103        if (this->gtinfo_.bStartCountdownRunning_ && !this->gtinfo_.bStarted_)
    91104            this->gtinfo_.startCountdown_ -= dt;
     
    93106        if (!this->gtinfo_.bStarted_)
    94107            this->checkStart();
    95         else
     108        else if (!this->gtinfo_.bEnded_)
    96109            this->spawnDeadPlayersIfRequested();
    97110
     
    111124    {
    112125        this->gtinfo_.bEnded_ = true;
     126
     127        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     128        {
     129            if (it->first->getControllableEntity())
     130            {
     131                ControllableEntity* oldentity = it->first->getControllableEntity();
     132       
     133                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getCreator());
     134                if (oldentity->getCamera())
     135                {
     136                    entity->setPosition(oldentity->getCamera()->getWorldPosition());
     137                    entity->setOrientation(oldentity->getCamera()->getWorldOrientation());
     138                }
     139                else
     140                {
     141                    entity->setPosition(oldentity->getWorldPosition());
     142                    entity->setOrientation(oldentity->getWorldOrientation());
     143                }
     144
     145                it->first->stopControl(oldentity, true);
     146                it->first->startControl(entity);
     147            }
     148            else
     149                this->spawnPlayerAsDefaultPawn(it->first);
     150        }
    113151    }
    114152
     
    267305                if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_)
    268306                {
    269                     SpawnPoint* spawn = this->getBestSpawnPoint(it->first);
    270                     if (spawn)
    271                     {
    272                         // force spawn at spawnpoint with default pawn
    273                         ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
    274                         spawn->spawn(entity);
    275                         it->first->startControl(entity);
    276                         it->second.state_ = PlayerState::Dead;
    277                     }
    278                     else
    279                     {
    280                         COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
    281                         abort();
    282                     }
     307                    this->spawnPlayerAsDefaultPawn(it->first);
     308                    it->second.state_ = PlayerState::Dead;
    283309                }
    284310            }
     
    358384    }
    359385
     386    void Gametype::spawnPlayerAsDefaultPawn(PlayerInfo* player)
     387    {
     388        SpawnPoint* spawn = this->getBestSpawnPoint(player);
     389        if (spawn)
     390        {
     391            // force spawn at spawnpoint with default pawn
     392            ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
     393            spawn->spawn(entity);
     394            player->startControl(entity);
     395        }
     396        else
     397        {
     398            COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
     399            abort();
     400        }
     401    }
     402
    360403    void Gametype::addBots(unsigned int amount)
    361404    {
     
    376419        }
    377420    }
     421
     422    void Gametype::addTime(float t)
     423    {
     424        if (this->timeLimit_ == 0)
     425          this->time_ -= t;
     426        else
     427          this->time_ += t;
     428    }
     429
     430    void Gametype::removeTime(float t)
     431    {
     432        if (this->timeLimit_ == 0)
     433          this->time_ += t;
     434        else
     435          this->time_ -= t;
     436    }
     437
     438    void Gametype::resetTimer()
     439    {
     440        this->resetTimer(timeLimit_);
     441    }
     442
     443    void Gametype::resetTimer(float t)
     444    {
     445        this->timeLimit_ = t;
     446        this->time_ = t;
     447    }
    378448}
  • code/trunk/src/orxonox/objects/gametypes/Gametype.h

    r2890 r3033  
    128128                { return this->players_.size(); }
    129129
     130            virtual void addTime(float t);
     131            virtual void removeTime(float t);
     132
     133            inline  void startTimer()
     134            {
     135                this->time_ = this->timeLimit_;
     136                this->timerIsActive_ = true;
     137            }
     138
     139            inline void stopTimer()
     140              { this->timerIsActive_ = false; }
     141
     142            inline float getTime()
     143              { return this->time_; }
     144
     145            inline bool getTimerIsActive()
     146              { return timerIsActive_; }
     147
     148            inline void setTimeLimit(float t)
     149              { this->timeLimit_ = t; }
     150
     151            virtual void resetTimer();
     152            virtual void resetTimer(float t);
     153
    130154        protected:
    131155            virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
     
    134158            virtual void checkStart();
    135159            virtual void spawnPlayer(PlayerInfo* player);
     160            virtual void spawnPlayerAsDefaultPawn(PlayerInfo* player);
    136161            virtual void spawnPlayersIfRequested();
    137162            virtual void spawnDeadPlayersIfRequested();
     
    141166            bool bAutoStart_;
    142167            bool bForceSpawn_;
     168
     169            float time_;
     170            float timeLimit_;
     171            bool timerIsActive_;
    143172
    144173            float initialStartCountdown_;
  • code/trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc

    r3032 r3033  
    125125    void TeamBaseMatch::showPoints()
    126126    {
    127 
    128         COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl;
    129         if(pointsTeam1_ >=1700) COUT(0) << "Team 1 is near victory!" << std::endl;
    130         if(pointsTeam2_ >=1700) COUT(0) << "Team 2 is near victory!" << std::endl;
     127        COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl;
     128        if(pointsTeam1_ >=1700) COUT(0) << "Team 1 is near victory!" << std::endl;
     129        if(pointsTeam2_ >=1700) COUT(0) << "Team 2 is near victory!" << std::endl;
    131130    }
    132131
     
    135134    void TeamBaseMatch::winPoints()
    136135    {
    137         int amountControlled = 0;
    138         int amountControlled2 = 0;
     136        int amountControlled = 0;
     137        int amountControlled2 = 0;
    139138
    140139        for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)
    141140        {
    142             if((*it)->getState() == BaseState::controlTeam1)
    143             {
    144                 amountControlled++;
    145             }
    146             if((*it)->getState() == BaseState::controlTeam2)
    147             {
    148                 amountControlled2++;
    149             }
     141            if((*it)->getState() == BaseState::controlTeam1)
     142            {
     143                amountControlled++;
     144            }
     145            if((*it)->getState() == BaseState::controlTeam2)
     146            {
     147                amountControlled2++;
     148            }
    150149        }
    151150
  • code/trunk/src/orxonox/objects/gametypes/TeamDeathmatch.cc

    r3028 r3033  
    127127            {
    128128                TeamSpawnPoint* tsp = dynamic_cast<TeamSpawnPoint*>(*it);
    129                 if (tsp && tsp->getTeamNumber() != desiredTeamNr)
     129                if (tsp && (int)tsp->getTeamNumber() != desiredTeamNr)
    130130                {
    131131                    teamSpawnPoints.erase(it++);
     
    189189        return false;
    190190    }
     191
     192    int TeamDeathmatch::getTeam(PlayerInfo* player)
     193    {
     194        std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
     195        if (it_player != this->teamnumbers_.end())
     196            return it_player->second;
     197        else
     198            return -1;
     199    }
    191200}
  • code/trunk/src/orxonox/objects/gametypes/TeamDeathmatch.h

    r3028 r3033  
    5555            virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
    5656
     57            inline const ColourValue& getTeamColour(int teamnr) const
     58                { return this->teamcolours_[teamnr]; }
     59
    5760        protected:
    5861            virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
    5962            bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2);
     63            int getTeam(PlayerInfo* player);
    6064
    6165            std::map<PlayerInfo*, int> teamnumbers_;
  • code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc

    r2911 r3033  
    4141
    4242#include "orxonox/objects/infos/PlayerInfo.h"
    43 #include "orxonox/objects/worldentities/ControllableEntity.h"
     43#include "orxonox/objects/worldentities/pawns/Pawn.h"
    4444#include "orxonox/objects/worldentities/triggers/PlayerTrigger.h"
    4545#include "QuestEffect.h"
     
    120120
    121121        //! Extracting the ControllableEntity form the PlayerTrigger.
    122         ControllableEntity* entity = trigger->getTriggeringPlayer();
    123 
    124         if(entity == NULL)
    125         {
    126             COUT(2) << "The QuestEffectBeacon was triggered by an entity other than a ControllableEntity." << std::endl;
     122        Pawn* pawn = trigger->getTriggeringPlayer();
     123
     124        if(pawn == NULL)
     125        {
     126            COUT(2) << "The QuestEffectBeacon was triggered by an entity other than a Pawn." << std::endl;
    127127            return false;
    128128        }
    129129       
    130130        //! Extract the PlayerInfo from the ControllableEntity.
    131         PlayerInfo* player = entity->getPlayer();
     131        PlayerInfo* player = pawn->getPlayer();
    132132       
    133133        if(player == NULL)
  • code/trunk/src/orxonox/objects/worldentities/CMakeLists.txt

    r2826 r3033  
    2323  PongBall.cc
    2424  PongBat.cc
     25  ForceField.cc
    2526)
    2627
  • code/trunk/src/orxonox/objects/worldentities/MobileEntity.cc

    r3028 r3033  
    166166    }
    167167
     168    void MobileEntity::applyCentralForce(const Vector3& force)
     169    {
     170        if (this->isDynamic())
     171            this->physicalBody_->applyCentralForce(btVector3(force.x * this->getMass(), force.y * this->getMass(), force.z * this->getMass()));
     172    }
     173
    168174    bool MobileEntity::isCollisionTypeLegal(WorldEntity::CollisionType type) const
    169175    {
  • code/trunk/src/orxonox/objects/worldentities/MobileEntity.h

    r3028 r3033  
    7575                { return this->angularAcceleration_; }
    7676
     77            void applyCentralForce(const Vector3& force);
     78            inline void applyCentralForce(float x, float y, float z)
     79                { this->applyCentralForce(Vector3(x, y, z)); }
     80
    7781            inline void setRotationRate(Degree rate)
    7882                { this->setAngularVelocity(this->getAngularVelocity().normalisedCopy() * rate.valueRadians()); }
  • code/trunk/src/orxonox/objects/worldentities/MovableEntity.cc

    r2896 r3033  
    3535#include "core/Executor.h"
    3636#include "core/GameMode.h"
     37#include "objects/worldentities/pawns/Pawn.h"
    3738
    3839namespace orxonox
     
    6768    {
    6869        SUPER(MovableEntity, XMLPort, xmlelement, mode);
     70
     71        XMLPortParam(MovableEntity, "enablecollisiondamage", setEnableCollisionDamage, getEnableCollisionDamage, xmlelement, mode).defaultValues(false);
     72        XMLPortParam(MovableEntity, "collisiondamage", setCollisionDamage, getCollisionDamage, xmlelement, mode).defaultValues(1);
    6973    }
     74
     75    bool MovableEntity::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     76    {
     77        if (GameMode::isMaster() && enableCollisionDamage_)
     78        {
     79            Pawn* victim = dynamic_cast<Pawn*>(otherObject);
     80            if (victim)
     81            {
     82                victim->damage(this->collisionDamage_ * victim->getVelocity().dotProduct(this->getVelocity()));
     83            }
     84        }
     85
     86        return false;
     87    }
     88
    7089
    7190    void MovableEntity::registerVariables()
  • code/trunk/src/orxonox/objects/worldentities/MovableEntity.h

    r2662 r3033  
    4646
    4747            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     48            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    4849            void registerVariables();
    4950
     
    5556            inline void setOrientation(const Quaternion& orientation)
    5657                { MobileEntity::setOrientation(orientation); this->overwrite_orientation_ = this->getOrientation(); }
     58
     59            inline void setOwner(Pawn* owner)
     60                { this->owner_ = owner; }
     61            inline Pawn* getOwner() const
     62                { return this->owner_; }
     63
     64            inline void setCollisionDamage(float c)
     65                { this->collisionDamage_ = c; }
     66
     67            inline float getCollisionDamage()
     68                { return this->collisionDamage_; }
     69
     70            inline void setEnableCollisionDamage(bool c)
     71            {
     72                this->enableCollisionDamage_ = c;
     73                this->enableCollisionCallback();
     74            }
     75
     76            inline bool getEnableCollisionDamage()
     77                { return this->enableCollisionDamage_; }
    5778
    5879        private:
     
    7697            Timer<MovableEntity> resynchronizeTimer_;
    7798            Timer<MovableEntity>* continuousResynchroTimer_;
     99
     100            Pawn* owner_;
     101            float collisionDamage_;
     102            bool enableCollisionDamage_;
    78103    };
    79104}
  • code/trunk/src/orxonox/objects/worldentities/SpawnPoint.cc

    r2662 r3033  
    9595    void SpawnPoint::spawn(ControllableEntity* entity)
    9696    {
    97         entity->setPosition(this->getPosition());
    98         entity->setOrientation(this->getOrientation());
     97        entity->setPosition(this->getWorldPosition());
     98        entity->setOrientation(this->getWorldOrientation());
    9999    }
    100100}
  • code/trunk/src/orxonox/objects/worldentities/pawns/CMakeLists.txt

    r2710 r3033  
    33  Pawn.cc
    44  SpaceShip.cc
     5  TeamBaseMatchBase.cc
     6  Destroyer.cc
    57)
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2904 r3033  
    198198    void Pawn::death()
    199199    {
     200        this->setHealth(1);
    200201        if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
    201202        {
     
    214215                this->deatheffect();
    215216        }
    216         else
    217             this->setHealth(1);
    218217    }
    219218
  • code/trunk/src/orxonox/objects/worldentities/triggers/CMakeLists.txt

    r2710 r3033  
    44  EventTrigger.cc
    55  PlayerTrigger.cc
     6  CheckPoint.cc
    67)
  • code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

    r3028 r3033  
    3535#include "core/XMLPort.h"
    3636
    37 #include "orxonox/objects/worldentities/ControllableEntity.h"
     37#include "orxonox/objects/worldentities/pawns/Pawn.h"
    3838
    3939namespace orxonox
     
    109109    WEMask.include(Class(WorldEntity));
    110110    this->targetMask_ *= WEMask;
     111
     112    this->notifyMaskUpdate();
    111113  }
    112114
     
    133135        if(this->isForPlayer())
    134136        {
    135           ControllableEntity* player = dynamic_cast<ControllableEntity*>(entity);
     137          Pawn* player = dynamic_cast<Pawn*>(entity);
    136138          this->setTriggeringPlayer(player);
    137139        }
  • code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h

    r3028 r3033  
    6363    protected:
    6464      virtual bool isTriggered(TriggerMode mode);
     65      virtual void notifyMaskUpdate() {}
     66
     67      ClassTreeMask targetMask_;
    6568
    6669    private:
    67       ClassTreeMask targetMask_;
    6870      std::set<Ogre::Node*> targetSet_;
    6971      float distance_;
  • code/trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h

    r2662 r3033  
    6060        @return Returns a pointer to the ControllableEntity that triggered the PlayerTrigger.
    6161        */
    62         inline ControllableEntity* getTriggeringPlayer(void) const
     62        inline Pawn* getTriggeringPlayer(void) const
    6363            { return this->player_; }
    6464       
     
    7777        @param player A pointer to the ControllableEntity that triggered the PlayerTrigger.
    7878        */
    79         inline void setTriggeringPlayer(ControllableEntity* player)
     79        inline void setTriggeringPlayer(Pawn* player)
    8080           { this->player_ = player; }
    8181
     
    8888       
    8989    private:
    90         ControllableEntity* player_; //!< The player that triggered the PlayerTrigger.
     90        Pawn* player_; //!< The player that triggered the PlayerTrigger.
    9191        bool isForPlayer_; //!< Is true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities.
    9292   
  • code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc

    r3028 r3033  
    102102    {
    103103      this->bFirstTick_ = false;
    104       this->fireEvent(false);
     104      this->triggered(false);
    105105    }
    106106
     
    144144      this->bTriggered_ = (newState & 0x1);
    145145      this->bActive_ = newState & 2;
    146       this->fireEvent(this->bActive_);
     146      this->triggered(this->bActive_);
    147147      this->stateChanges_.pop();
    148148      if (this->stateChanges_.size() != 0)
     
    160160    else
    161161      this->setBillboardColour(ColourValue(1.0, 0.0, 0.0));
     162  }
     163
     164  void Trigger::triggered(bool bIsTriggered)
     165  {
     166    this->fireEvent(bIsTriggered);
    162167  }
    163168
  • code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h

    r3028 r3033  
    8989        { return this->remainingActivations_; }
    9090
     91      inline void setVisible(bool visibility)
     92        { this->debugBillboard_.setVisible(visibility); }
     93
    9194      void setDelay(float delay);
    9295      inline float getDelay() const
     
    101104      inline bool isTriggered() { return this->isTriggered(this->mode_); }
    102105      virtual bool isTriggered(TriggerMode mode);
     106      virtual void triggered(bool bIsTriggered);
    103107
    104108    private:
  • code/trunk/src/orxonox/overlays/hud/CMakeLists.txt

    r2890 r3033  
    55  HUDSpeedBar.cc
    66  HUDHealthBar.cc
     7  HUDTimer.cc
    78  ChatOverlay.cc
    89  GametypeStatus.cc
Note: See TracChangeset for help on using the changeset viewer.