Changeset 12359 for code/branches/OrxoBlox_FS19/src/modules/OrxoBlox
- Timestamp:
- May 9, 2019, 3:29:29 PM (6 years ago)
- 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 170 170 171 171 // Set variable to temporarily force the player to spawn. 172 // Set variable to temporarily force the player to spawn. 173 bool temp = this->bForceSpawn_; 172 174 this->bForceSpawn_ = true; 173 175 … … 175 177 Deathmatch::start(); 176 178 179 // Reset the variable. 180 this->bForceSpawn_ = temp; 181 177 182 } 178 183 … … 184 189 { 185 190 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 186 198 this->cleanup(); 187 199 … … 191 203 } 192 204 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_; 203 208 } 204 209 … … 217 222 void OrxoBlox::LevelUp(){ 218 223 level_++; 219 224 this->playerScored(this->player_);// add points 220 225 for(OrxoBloxStones* stone : this->stones_){ 221 226 int x_=(stone->getPosition()).x; -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.h
r12346 r12359 73 73 virtual void end() override; ///!< Ends the OrxoBlox minigame. 74 74 75 OrxoBloxShip* getPlayer();75 PlayerInfo* getPlayer(); 76 76 void spawnPlayer(PlayerInfo* Player) override; 77 77 -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxPrereqs.h
r12331 r12359 74 74 class OrxoBloxStones; 75 75 class OrxoBloxShip; 76 class OrxoBloxScore; 76 77 } 77 78 -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.cc
r12266 r12359 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "core/XMLPort.h"38 37 #include "util/Convert.h" 39 38 … … 41 40 42 41 #include "OrxoBlox.h" 43 #include "sound/WorldSound.h" /////////////////////////////44 42 45 43 namespace orxonox … … 56 54 57 55 this->owner_ = nullptr; 58 59 this->bShowName_ = true; 60 this->bShowScore_ = true; 61 this->bShowPlayer_ = true; 62 } 56 this->player_ = nullptr; 63 57 64 58 /** … … 70 64 } 71 65 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 85 67 /** 86 68 @brief … … 97 79 if (this->owner_ != nullptr) 98 80 { 99 if (!this->owner_->hasEnded()) 81 std::string score("0"); 82 if(!this->owner_->hasEnded()) 100 83 { 101 // Get the player. 102 //Fehlermeldung 103 //player1_ = this->owner_->getPlayer(); 84 //get the player 85 player_ = this->owner_->getPlayer(); 104 86 } 105 87 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()) 112 89 { 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_)); 115 93 } 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); 141 95 } 142 96 } -
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxScore.h
r12266 r12359 61 61 62 62 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;64 63 virtual void changedOwner() override; //!< Is called when the owner changes. 65 64 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() const77 { return this->bShowName_; }78 65 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() const90 { 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() const103 { 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() const117 { return this->bShowRightPlayer_; }118 */119 66 private: 120 67 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. 129 69 }; 130 70 }
Note: See TracChangeset
for help on using the changeset viewer.