Changeset 2985
- Timestamp:
- May 18, 2009, 5:01:45 PM (16 years ago)
- Location:
- code/branches/gametypes/src/orxonox/objects
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.cc
r2934 r2985 20 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 21 * 22 * Author: 22 * Author: Val Mikos 23 23 */ 24 24 … … 28 28 29 29 30 //implement this! not done yet!31 30 #include "objects/worldentities/pawns/TeamBaseMatchBase.h" 32 31 #include "core/CoreIncludes.h" … … 99 98 } 100 99 100 101 // if the player is in the same team as the base, he can't make any damage to it 102 bool TeamBaseMatch::allowPawnDamage(Pawn* victim, Pawn* originator) 103 { 104 TeamBaseMatchBase* base = dynamic_cast<TeamBaseMatchBase*>(victim); 105 if (base) 106 { 107 std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.find(base); 108 if (it != this->bases_.end()) 109 return (!this->pawnsAreInTheSameTeam(victim, base)); 110 } 111 return (!this->pawnsAreInTheSameTeam(victim, originator)); 112 } 113 114 bool TeamBaseMatch::pawnsAreInTheSameTeam(Pawn* pawn1, TeamBaseMatchBase* base) 115 { 116 if (pawn1 && base) 117 { 118 std::map<PlayerInfo*, int>::const_iterator it1 = this->teamnumbers_.find(pawn1->getPlayer()); 119 int teamnrbase = -1; 120 int teamnrplayer = getTeam(pawn1->getPlayer()); 121 122 switch(base->getState()) 123 { 124 case BaseState::controlTeam1: 125 teamnrbase = 0; 126 break; 127 case BaseState::controlTeam2: 128 teamnrbase = 1; 129 break; 130 case BaseState::uncontrolled: 131 default: 132 teamnrbase = -1; 133 } 134 135 136 if(teamnrbase == teamnrplayer){ 137 return false; 138 } 139 } 140 return true; 141 } 142 143 144 145 146 101 147 // collect Points for killing oppenents 102 148 void TeamBaseMatch::playerScored(PlayerInfo* player) … … 181 227 return 0; 182 228 } 183 184 185 // declare the functions 'getshape' and 'setshape' from the XML function here186 187 188 189 190 229 191 230 } 192 231 193 232 194 195 -
code/branches/gametypes/src/orxonox/objects/gametypes/TeamBaseMatch.h
r2934 r2985 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Val Mikos 26 26 * 27 27 */ … … 59 59 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); 60 60 61 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator); 62 63 64 61 65 // give information about the state of a base 62 66 // (this should be pretty useless atm) … … 78 82 void winPoints(); 79 83 84 85 bool pawnsAreInTheSameTeam(Pawn* pawn1, TeamBaseMatchBase* base); 86 using TeamDeathmatch::pawnsAreInTheSameTeam; 87 80 88 std::set<TeamBaseMatchBase*> bases_; 81 89 Timer<TeamBaseMatch> scoreTimer_; -
code/branches/gametypes/src/orxonox/objects/gametypes/TeamDeathmatch.h
r2903 r2985 55 55 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn); 56 56 57 inline const ColourValue& getTeamColour(int teamnr) const 58 { return this->teamcolours_[teamnr]; } 59 57 60 protected: 58 61 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; -
code/branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc
r2934 r2985 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Val Mikos 26 26 * 27 27 */ … … 31 31 #include "core/CoreIncludes.h" 32 32 #include "objects/gametypes/TeamBaseMatch.h" 33 #include "objects/Teamcolourable.h" 33 34 34 35 namespace orxonox … … 48 49 } 49 50 } 51 52 void TeamBaseMatchBase::changeTeamColour() 53 { 54 this->fireEvent(); 55 56 TeamDeathmatch* gametype = dynamic_cast<TeamDeathmatch*>(this->getGametype()); 57 if (!gametype) 58 return; 59 60 ColourValue colour; 61 62 switch (this->state_) 63 { 64 case BaseState::controlTeam1: 65 colour = gametype->getTeamColour(0); 66 break; 67 case BaseState::controlTeam2: 68 colour = gametype->getTeamColour(1); 69 break; 70 case BaseState::uncontrolled: 71 default: 72 colour = ColourValue(0.5, 0.5, 0.7, 1.0); 73 break; 74 } 75 76 77 std::set<WorldEntity*> attachments = this->getAttachedObjects(); 78 for (std::set<WorldEntity*>::iterator it = attachments.begin(); it != attachments.end(); ++it) 79 { 80 if ((*it)->isA(Class(Teamcolourable))) 81 { 82 Teamcolourable* tc = dynamic_cast<Teamcolourable*>(*it); 83 tc->setTeamColour(colour); 84 } 85 } 86 } 50 87 } 51 88 -
code/branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h
r2934 r2985 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Val Mikos 26 26 * 27 27 */ … … 70 70 { 71 71 this->state_ = state; 72 this->changeTeamColour(); 72 73 } 73 74 … … 81 82 82 83 protected: 84 void changeTeamColour(); 83 85 84 86 BaseState::Enum state_;
Note: See TracChangeset
for help on using the changeset viewer.