Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11356 for code/trunk/src


Ignore:
Timestamp:
Mar 9, 2017, 3:38:58 PM (7 years ago)
Author:
patricwi
Message:

merged space race with trunk

Location:
code/trunk
Files:
9 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/dodgerace/DodgeRace.cc

    r11071 r11356  
    3636#include "DodgeRaceCube.h"
    3737#include "core/CoreIncludes.h"
     38#include "Highscore.h"
    3839
    3940namespace orxonox
     
    224225        // It will misteriously crash the game!
    225226        // Instead startMainMenu, this won't crash.
     227        if (Highscore::exists()){
     228                    int score = this->getPoints();
     229                    if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race"))
     230                        Highscore::getInstance().storeHighscore("Dodge Race",score);
     231
     232          }
    226233        GSLevel::startMainMenu();
    227234    }
  • code/trunk/src/modules/invader/Invader.cc

    r11083 r11356  
    3333
    3434#include "Invader.h"
    35 
     35#include "Highscore.h"
    3636#include "core/CoreIncludes.h"
    3737#include "core/EventIncludes.h"
     
    189189        // It will misteriously crash the game!
    190190        // Instead startMainMenu, this won't crash.
     191        if (Highscore::exists()){
     192                    int score = this->getPoints();
     193                    if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade"))
     194                        Highscore::getInstance().storeHighscore("Orxonox Arcade",score);
     195
     196          }
    191197        GSLevel::startMainMenu();
    192198    }
  • code/trunk/src/modules/jump/Jump.cc

    r11071 r11356  
    3434#include "Jump.h"
    3535#include "core/CoreIncludes.h"
     36#include "Highscore.h"
    3637
    3738#include "JumpCenterpoint.h"
     
    311312        cleanup();
    312313        GSLevel::startMainMenu();
    313 
     314        if (Highscore::exists()){
     315                    int score = this->getScore(this->getPlayer());
     316                    if(score > Highscore::getInstance().getHighestScoreOfGame("Jump"))
     317                        Highscore::getInstance().storeHighscore("Jump",score);
     318
     319          }
    314320        Deathmatch::end();
    315321    }
  • code/trunk/src/modules/tetris/Tetris.cc

    r11083 r11356  
    3939
    4040#include "Tetris.h"
     41#include "Highscore.h"
    4142
    4243#include "core/CoreIncludes.h"
     
    327328            this->player_->stopControl();
    328329        }
    329 
     330         if (Highscore::exists()){
     331                    int score = this->getScore(this->getPlayer());
     332                    if(score > Highscore::getInstance().getHighestScoreOfGame("Tetris"))
     333                        Highscore::getInstance().storeHighscore("Tetris",score);
     334
     335          }
    330336        this->cleanup();
    331337
  • code/trunk/src/modules/towerdefense/TowerDefense.cc

    r11083 r11356  
    8181#include "chat/ChatManager.h"
    8282#include "core/CoreIncludes.h"
     83#include "Highscore.h"
    8384
    8485namespace orxonox
     
    197198    void TowerDefense::end()
    198199    {
    199 
     200        if (Highscore::exists()){
     201                    int score = this->getWaveNumber();
     202                    if(score > Highscore::getInstance().getHighestScoreOfGame("Tower Defense"))
     203                        Highscore::getInstance().storeHighscore("Tower Defense",score);
     204
     205          }
    200206        TeamDeathmatch::end();
    201207        ChatManager::message("Match is over! Gameover!");
  • code/trunk/src/orxonox/CMakeLists.txt

    r11353 r11356  
    2828  LevelInfo.cc
    2929  LevelManager.cc
     30  Highscore.cc
    3031  Main.cc
    3132  MoodManager.cc
     
    6162    LevelInfo.h
    6263    LevelManager.h
     64    Highscore.h
    6365    MoodManager.h
    6466    controllers/HumanController.h
  • code/trunk/src/orxonox/LevelInfo.cc

    r11099 r11356  
    151151    }
    152152
     153    bool LevelInfoItem::addHighscore(const std::string& name, const int score)
     154    {
     155        std::stringstream stream;
     156        stream << name << "/:/" << score;
     157        bool success = this->highscores_.insert(stream.str()).second;
     158        if(success)
     159            this->highscoresUpdated();
     160        return success;
     161    }
     162
    153163    /**
    154164    @brief
     
    191201    }
    192202
     203    void LevelInfoItem::highscoresUpdated(void)
     204    {
     205        std::stringstream stream;
     206        std::set<std::string>::iterator temp;
     207        for(std::set<std::string>::iterator it = this->highscores_.begin(); it != this->highscores_.end(); )
     208        {
     209            temp = it;
     210            if(++it == this->highscores_.end()) // If this is the last tag we don't add a comma.
     211                stream << *temp;
     212            else
     213                stream << *temp << ", ";
     214        }
     215
     216        this->highscoresString_ = std::string(stream.str());
     217    }
    193218    /**
    194219    @brief
  • code/trunk/src/orxonox/LevelInfo.h

    r11099 r11356  
    118118            inline bool hasTag(const std::string& tag) const { return this->tags_.find(tag) != this->tags_.end(); } // tolua_export
    119119
     120            bool addHighscore(const std::string& name,const int score);
     121
     122            inline const std::string& getHighscores(void) const { return this->highscoresString_; } // tolua_export
     123
    120124            void setStartingShips(const std::string& ships); //!< Set the starting ship models of the level
    121125            bool addStartingShip(const std::string& ship, bool update = true); //!< Add a model to shipselection
     
    154158            void startingshipsUpdated(void); //!< Updates the comma-seperated string of all possible starting ships.
    155159            void tagsUpdated(void); //!< Updates the comma-seperated string of all tags, if the set of tags has changed.
     160            void highscoresUpdated(void);
    156161            static void initializeTags(void); //!< Initialize the set of allowed tags.
    157162            /**
     
    170175            std::string screenshot_; //!< The screenshot of the Level.
    171176            std::set<std::string> tags_; //!< The set of tags the Level is tagged with.
     177
     178            std::set<std::string> highscores_;
     179            std::string highscoresString_;
     180
    172181            std::string tagsString_; //!< The comma-seperated string of all the tags the Level is tagged with.
    173182            std::set<std::string> startingShips_; //!< The set of starting ship models the Level allows.
     
    244253            inline const std::string& getTags(void) const
    245254                { return this->LevelInfoItem::getTags(); }
     255
     256            inline const std::string& getHighscores(void) const
     257                { return this->LevelInfoItem::getHighscores(); }
    246258            /**
    247259            @brief Set the starting ship models of the level
Note: See TracChangeset for help on using the changeset viewer.