Changeset 8107 for code/branches/tetris/src/modules/pong/PongScore.cc
- Timestamp:
- Mar 23, 2011, 9:41:21 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tetris/src/modules/pong/PongScore.cc
r6417 r8107 27 27 */ 28 28 29 /** 30 @file PongScore.cc 31 @brief Implementation of the PongScore class. 32 */ 33 29 34 #include "PongScore.h" 30 35 31 #include "util/Convert.h"32 36 #include "core/CoreIncludes.h" 33 37 #include "core/XMLPort.h" 38 #include "util/Convert.h" 39 40 #include "infos/PlayerInfo.h" 41 34 42 #include "Pong.h" 35 #include "infos/PlayerInfo.h"36 43 37 44 namespace orxonox … … 39 46 CreateFactory(PongScore); 40 47 48 /** 49 @brief 50 Constructor. Registers and initializes the object. 51 */ 41 52 PongScore::PongScore(BaseObject* creator) : OverlayText(creator) 42 53 { … … 51 62 } 52 63 64 /** 65 @brief 66 Destructor. 67 */ 53 68 PongScore::~PongScore() 54 69 { 55 70 } 56 71 72 /** 73 @brief 74 Method to create a PongScore through XML. 75 */ 57 76 void PongScore::XMLPort(Element& xmlelement, XMLPort::Mode mode) 58 77 { … … 65 84 } 66 85 86 /** 87 @brief 88 Is called each tick. 89 Creates and sets the caption to be displayed by the PongScore. 90 @param dt 91 The time that has elapsed since the last tick. 92 */ 67 93 void PongScore::tick(float dt) 68 94 { 69 95 SUPER(PongScore, tick, dt); 70 96 71 if (this->owner_) 97 // If the owner is set. The owner being a Pong game. 98 if (this->owner_ != NULL) 72 99 { 100 // Get the two players. 73 101 PlayerInfo* player1 = this->owner_->getLeftPlayer(); 74 102 PlayerInfo* player2 = this->owner_->getRightPlayer(); … … 80 108 std::string score2("0"); 81 109 82 if (player1) 110 // Save the name and score of each player as a string. 111 if (player1 != NULL) 83 112 { 84 113 name1 = player1->getName(); 85 114 score1 = multi_cast<std::string>(this->owner_->getScore(player1)); 86 115 } 87 88 if (player2) 116 if (player2 != NULL) 89 117 { 90 118 name2 = player2->getName(); … … 92 120 } 93 121 122 // Assemble the strings, depending on what should all be displayed. 94 123 std::string output1; 95 124 if (this->bShowLeftPlayer_) 96 125 { 97 if (this->bShowName_ && this->bShowScore_ && player1 )126 if (this->bShowName_ && this->bShowScore_ && player1 != NULL) 98 127 output1 = name1 + " - " + score1; 99 128 else if (this->bShowScore_) … … 106 135 if (this->bShowRightPlayer_) 107 136 { 108 if (this->bShowName_ && this->bShowScore_ && player2 )137 if (this->bShowName_ && this->bShowScore_ && player2 != NULL) 109 138 output2 = score2 + " - " + name2; 110 139 else if (this->bShowScore_) … … 127 156 } 128 157 129 158 /** 159 @brief 160 Is called when the owner changes. 161 Sets the owner to NULL, if it is not a pointer to a Pong game. 162 */ 130 163 void PongScore::changedOwner() 131 164 { 132 165 SUPER(PongScore, changedOwner); 133 166 134 if (this->getOwner() && this->getOwner()->getGametype())167 if (this->getOwner() != NULL && this->getOwner()->getGametype()) 135 168 this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get()); 136 169 else
Note: See TracChangeset
for help on using the changeset viewer.