Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11841


Ignore:
Timestamp:
Mar 29, 2018, 4:02:41 PM (6 years ago)
Author:
andera
Message:

added countdown

Location:
code/branches/RacingBots_FS18/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/RacingBots_FS18/src/libraries/tools/Timer.cc

    r11840 r11841  
    200200    }
    201201
    202     /*void Timer::setTimer(float interval, bool bKillAfterCall)
    203     {
    204          this->setInterval(interval);
    205          this->bActive_ = true;
    206          this->time_ = this->interval_;
    207         this->bKillAfterCall_ = bKillAfterCall;
    208     }
    209     */
    210202
    211203    /**
  • code/branches/RacingBots_FS18/src/libraries/tools/Timer.h

    r11071 r11841  
    113113            void run();
    114114
     115
    115116            /// Re-starts the timer: The executor will be called after @a interval seconds.
    116117            inline void startTimer()
  • code/branches/RacingBots_FS18/src/modules/gametypes/SpaceRace.cc

    r11840 r11841  
    7070#include "items/Engine.h"
    7171#include <vector>
     72#include <iostream>
     73#include <string>
     74
    7275
    7376namespace orxonox
     
    100103        startpos[4] =-40;
    101104        startpos[5] =100;
    102        
     105         
    103106        startpos[6] =100;
    104107        startpos[7] =-40;
     
    137140        }
    138141
    139 
    140         std::string message("Use headphones to hear the countdown!");
     142        std::string message("Use headphones to hear the countdown! It is useful to start with a boost!");
     143
    141144        this->getGametypeInfo()->sendAnnounceMessage(message);
    142145        ChatManager::message(message);
    143 
     146       
     147       
     148        /*for(int i=10; i>0;i=i-1){
     149            startmessage(i);
     150        }*/
    144151
    145152
    146153        //after 11 seconds , countdownFinished function is called to activate bots` engines
    147         Timer* countdownTimer = new Timer();
    148         countdownTimer->setTimer(11, false, createExecutor(createFunctor(&SpaceRace::countdownFinished, this)));
    149        
    150     }
    151 
     154        //Timer* countdownTimer = new Timer();
     155        //countdownTimer->setTimer(11, false, createExecutor(createFunctor(&SpaceRace::countdownFinished, this)));
     156
     157        /*
     158        while(countdownTimer->getRemainingTime()!=0){
     159            if(countdownTimer->getRemainingTime()==1){
     160                startmessage(1);
     161            }
     162        }*/
     163       
     164
     165
     166
     167       
     168
     169       
     170        /*unsigned long long float time_notification=countdownTimer.getRealMicroSeconds();
     171        while(this->bTimeIsUp_==false){
     172
     173        std::ostream stream;
     174        stream<<time_notification;
     175        std::string chat_notification(stream.str());
     176        this->getGametypeInfo()->sendAnnounceMessage(chat_notification);
     177        ChatManager::message(chat_notification);
     178
     179        }*/
     180
     181       
     182    }
     183
     184   
     185
     186    void SpaceRace::tick(float dt) {
     187        SUPER(SpaceRace, tick, dt);
     188        this->time_passed -= dt;
     189
     190        if (countdown_mode) {
     191
     192            //orxout() << "time: " <<(int) time_passed << "s" << endl;
     193            std::string message=std::to_string((int)time_passed);
     194            this->getGametypeInfo()->sendAnnounceMessage(message);
     195            if (time_passed <= 1) {
     196                this->countdownFinished();
     197                this->countdown_mode = false;
     198            }
     199        }
     200
     201    }
     202       
     203    void SpaceRace::startmessage(int second){
     204
     205        std::string message=std::to_string(second);
     206        this->getGametypeInfo()->sendAnnounceMessage(message);
     207        ChatManager::message(message);
     208       
     209       
     210
     211    }
    152212
    153213
  • code/branches/RacingBots_FS18/src/modules/gametypes/SpaceRace.h

    r11840 r11841  
    6262           
    6363            virtual void addBots(unsigned int amount) override; //<! overwrite function in order to bypass the addbots command.
     64            virtual void tick(float dt) override;
     65            virtual void startmessage(int second);
    6466
    6567
     
    8486            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator) override;
    8587            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator) override;
     88            bool countdown_mode = true;
     89            float time_passed = 11.0f;
    8690
    8791        private:
Note: See TracChangeset for help on using the changeset viewer.