Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2971


Ignore:
Timestamp:
May 11, 2009, 5:31:21 PM (15 years ago)
Author:
mockm
Message:

new revision of Gametype UnderAttack: Timerfunction and some color added

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

Legend:

Unmodified
Added
Removed
  • code/branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc

    r2952 r2971  
    3434#include "objects/Teamcolourable.h"
    3535#include "objects/worldentities/TeamSpawnPoint.h"
     36#include "util/Convert.h"
    3637
    3738#include "network/Host.h"
     
    4344    {
    4445        RegisterObject(UnderAttack);
    45         this->gameTime_ = 30;
     46        this->gameTime_ = 90;
    4647        this->teams_ = 2;
    4748        this->destroyer_ = 0;
     
    4950
    5051        this->setConfigValues();
     52        this->timesequence_ = (int) this->gameTime_;
    5153    }
    5254
     
    7072            COUT(0) << message << std::endl;
    7173            Host::Broadcast(message);
     74            this->gameEnded_ = true;
    7275        }
    7376    }
     
    126129        return TeamDeathmatch::allowPawnDeath(victim, originator);
    127130    }
     131
     132
    128133    void UnderAttack::tick(float dt)
    129134    {
    130135        SUPER(UnderAttack, tick, dt);
    131136
    132         if (this->hasStarted())
     137        if (this->hasStarted() && !gameEnded_)
    133138        {
    134139            gameTime_ = gameTime_ - dt;
    135             if (gameTime_<= 0 && !gameEnded_)
     140            if (gameTime_<= 0)
    136141            {
    137                 gameEnded_ = true;
     142                this->gameEnded_ = true;
    138143                this->end();
    139144                std::string message = "Time is up! Team 1 has won!";
     
    141146                Host::Broadcast(message);
    142147            }
     148
     149             //prints gametime
     150            if ( gameTime_ <= timesequence_)
     151            {
     152                std::string message = convertToString(timesequence_) + " sec left!";
     153                COUT(0) << message << std::endl;
     154                Host::Broadcast(message);
     155                if (timesequence_ >= 30 && timesequence_ <= 60)
     156                {
     157                    timesequence_ = timesequence_ - 10;
     158                }
     159                else if (timesequence_ <= 30)
     160                {
     161                    timesequence_ = timesequence_ - 5;
     162                }
     163                else
     164                {
     165                    timesequence_ = timesequence_ - 30;
     166                }
     167            }
    143168        }
    144169    }
  • code/branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h

    r2952 r2971  
    4646
    4747            void setConfigValues();
    48 
    4948            void tick (float dt);
    5049            void addDestroyer(Destroyer* destroyer);
     
    6261            unsigned int teams_;
    6362            float gameTime_;
     63            int timesequence_;
    6464            bool gameEnded_;
    6565    };
Note: See TracChangeset for help on using the changeset viewer.