Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 9, 2019, 3:29:29 PM (6 years ago)
Author:
ahuwyler
Message:

fuer de jerome

Location:
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc

    r12355 r12359  
    170170
    171171        // Set variable to temporarily force the player to spawn.
     172        // Set variable to temporarily force the player to spawn.
     173        bool temp = this->bForceSpawn_;
    172174        this->bForceSpawn_ = true;
    173175
     
    175177        Deathmatch::start();
    176178
     179        // Reset the variable.
     180        this->bForceSpawn_ = temp;
     181
    177182    }
    178183
     
    184189    {
    185190        ChatManager::message("You suck!!");
     191
     192        if (Highscore::exists())
     193        {
     194            int score = this->getScore(this->getPlayer());
     195            Highscore::getInstance().storeScore("Tetris", score, this->getPlayer());
     196        }
     197
    186198        this->cleanup();
    187199
     
    191203    }
    192204
    193     OrxoBloxShip* OrxoBlox::getPlayer()
    194     {
    195         if (playership == nullptr)
    196         {
    197             for (OrxoBloxShip* ship_ : ObjectList<OrxoBloxShip>())
    198             {
    199                 playership = ship_;
    200             }
    201         }
    202         return playership;
     205    PlayerInfo* OrxoBlox::getPlayer()
     206    {
     207        return this->player_;
    203208    }
    204209   
     
    217222    void OrxoBlox::LevelUp(){
    218223        level_++;
    219 
     224        this->playerScored(this->player_);// add points
    220225        for(OrxoBloxStones* stone : this->stones_){
    221226            int x_=(stone->getPosition()).x;
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h

    r12346 r12359  
    7373            virtual void end() override; ///!< Ends the OrxoBlox minigame.
    7474
    75             OrxoBloxShip* getPlayer();
     75            PlayerInfo* getPlayer();
    7676            void spawnPlayer(PlayerInfo* Player) override;
    7777
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h

    r12331 r12359  
    7474    class OrxoBloxStones;
    7575    class OrxoBloxShip;
     76    class OrxoBloxScore;
    7677}
    7778
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.cc

    r12266 r12359  
    3535
    3636#include "core/CoreIncludes.h"
    37 #include "core/XMLPort.h"
    3837#include "util/Convert.h"
    3938
     
    4140
    4241#include "OrxoBlox.h"
    43 #include "sound/WorldSound.h" /////////////////////////////
    4442
    4543namespace orxonox
     
    5654
    5755        this->owner_ = nullptr;
    58 
    59         this->bShowName_ = true;
    60         this->bShowScore_ = true;
    61         this->bShowPlayer_ = true;
    62     }
     56        this->player_ = nullptr;
    6357
    6458    /**
     
    7064    }
    7165
    72     /**
    73     @brief
    74         Method to create a OrxoBloxScore through XML.
    75     */
    76     void OrxoBloxScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    77     {
    78         SUPER(OrxoBloxScore, XMLPort, xmlelement, mode);
    79 
    80         XMLPortParam(OrxoBloxScore, "showname",        setShowName,        getShowName,        xmlelement, mode).defaultValues(false);
    81         XMLPortParam(OrxoBloxScore, "showscore",       setShowScore,       getShowScore,       xmlelement, mode).defaultValues(false);
    82         XMLPortParam(OrxoBloxScore, "showplayer",  setShowPlayer,  getShowPlayer,  xmlelement, mode).defaultValues(false);
    83     }
    84 
     66   
    8567    /**
    8668    @brief
     
    9779        if (this->owner_ != nullptr)
    9880        {
    99             if (!this->owner_->hasEnded())
     81            std::string score("0");
     82            if(!this->owner_->hasEnded())
    10083            {
    101                 // Get the player.
    102                 //Fehlermeldung
    103                 //player1_ = this->owner_->getPlayer();
     84                //get the player
     85                player_ = this->owner_->getPlayer();
    10486            }
    10587
    106             std::string name1;
    107 
    108             std::string score1("0");
    109 
    110             // Save the name and score of each player as a string.
    111             if (player1_ != nullptr)
     88            if(this->owner_->hasStarted())
    11289            {
    113                 name1 = player1_->getName();
    114                 score1 = multi_cast<std::string>(this->owner_->getScore(player1_));
     90                // Save the name and score of each player as a string.
     91                if (player_ != nullptr)
     92                    score = multi_cast<std::string>(this->owner_->getScore(player_));
    11593            }
    116 
    117             // Assemble the strings, depending on what should all be displayed.
    118             std::string output1;
    119             if (this->bShowPlayer_)
    120             {
    121                 if (this->bShowName_ && this->bShowScore_ && player1_ != nullptr)
    122                     output1 = name1 + " - " + score1;
    123                 else if (this->bShowScore_)
    124                     output1 = score1;
    125                 else if (this->bShowName_)
    126                     output1 = name1;
    127             }
    128 
    129             std::string output("OrxoBlox");
    130             /* Keine Ahnung wofuer das gut ist.
    131 
    132             if (this->bShowName_ || this->bShowScore_)
    133             {
    134                 if (this->bShowLeftPlayer_ && this->bShowRightPlayer_)
    135                     output = output1 + ':' + output2;
    136                 else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_)
    137                     output = output1 + output2;
    138             }*/
    139 
    140             this->setCaption(output);
     94            this->setCaption(score);
    14195        }
    14296    }
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.h

    r12266 r12359  
    6161
    6262            virtual void tick(float dt) override; //!< Creates and sets the caption to be displayed by the OrxoBloxScore.
    63             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    6463            virtual void changedOwner() override; //!< Is called when the owner changes.
    6564
    66             /**
    67             @brief Set whether the OrxoBloxScore displays the players' names.
    68             @param value If true the players' names are displayed.
    69             */
    70             inline void setShowName(bool value)
    71                 { this->bShowName_ = value; }
    72             /**
    73             @brief Get whether the OrxoBloxScore displays the players' names.
    74             @return Returns true if the players' names are displayed, false otherwise.
    75             */
    76             inline bool getShowName() const
    77                 { return this->bShowName_; }
    7865
    79             /**
    80             @brief Set whether the OrxoBloxScore displays the players' scores.
    81             @param value If true the players' scores are displayed.
    82             */
    83             inline void setShowScore(bool value)
    84                 { this->bShowScore_ = value; }
    85             /**
    86             @brief Get whether the OrxoBloxScore displays the players' scores.
    87             @return Returns true if the players' scores are displayed, false otherwise.
    88             */
    89             inline bool getShowScore() const
    90                 { return this->bShowScore_; }
    91 
    92             /**
    93             @brief Set whether the OrxoBloxScore displays the left player.
    94             @param value If true the left player is displayed.
    95             */
    96             inline void setShowPlayer(bool value)
    97                 { this->bShowPlayer_ = value; }
    98             /**
    99             @brief Get whether the OrxoBloxScore displays the left player.
    100             @return Returns true if the left player is displayed, false otherwise.
    101             */
    102             inline bool getShowPlayer() const
    103                 { return this->bShowPlayer_; }
    104 
    105 /*
    106             /**
    107             @brief Set whether the OrxoBloxScore displays the right player.
    108             @param value If true the right player is displayed.
    109            
    110             inline void setShowRightPlayer(bool value)
    111                 { this->bShowRightPlayer_ = value; }
    112             /**
    113             @brief Get whether the OrxoBloxScore displays the right player.
    114             @return Returns true if the right player is displayed, false otherwise.
    115            
    116             inline bool getShowRightPlayer() const
    117                 { return this->bShowRightPlayer_; }
    118 */
    11966        private:
    12067            OrxoBlox* owner_; //!< The OrxoBlox game that owns this OrxoBloxScore.
    121             bool bShowName_; //!< Whether the names of the players are shown.
    122             bool bShowScore_; //!< Whether the score of the players is shown.
    123             bool bShowPlayer_; //!< Whether the left player is shown.
    124             //bool bShowRightPlayer_; //!< Whether the right player is shown.
    125             WeakPtr<PlayerInfo> player1_; //!< Store information about left player permanently.
    126             WeakPtr<PlayerInfo> player2_; //!< Same for the right player. To end the game properly.
    127             WorldSound* scoreSound_;
    128 
     68            PlayerInfo* player_; //!< Store information about the player permanently.
    12969    };
    13070}
Note: See TracChangeset for help on using the changeset viewer.