Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pch/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc @ 3183

Last change on this file since 3183 was 3183, checked in by rgrieder, 15 years ago

Renamed Teamcolourable to TeamColourable

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Val Mikos
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29
30#include "TeamBaseMatchBase.h"
31#include "core/CoreIncludes.h"
32#include "objects/gametypes/TeamBaseMatch.h"
33#include "interfaces/TeamColourable.h"
34#include "interfaces/PawnListener.h"
35
36namespace orxonox
37{
38    CreateFactory(TeamBaseMatchBase);
39
40    TeamBaseMatchBase::TeamBaseMatchBase(BaseObject* creator) : Pawn(creator)
41    {
42        RegisterObject(TeamBaseMatchBase);
43
44        this->state_ = BaseState::uncontrolled;
45
46        TeamBaseMatch* gametype = dynamic_cast<TeamBaseMatch*>(this->getGametype());
47        if (gametype)
48        {
49            gametype->addBase(this);
50        }
51
52        this->setRadarObjectShape(RadarViewable::Triangle);
53    }
54
55    void TeamBaseMatchBase::changeTeamColour()
56    {
57        this->fireEvent();
58
59        TeamDeathmatch* gametype = dynamic_cast<TeamDeathmatch*>(this->getGametype());
60        if (!gametype)
61            return;
62
63        ColourValue colour;
64
65        switch (this->state_)
66        {
67            case BaseState::controlTeam1:
68                colour = gametype->getTeamColour(0);
69                break;
70            case BaseState::controlTeam2:
71                colour = gametype->getTeamColour(1);
72                break;
73            case BaseState::uncontrolled:
74            default:
75                colour = ColourValue(0.5, 0.5, 0.5, 1.0);
76                break;
77        }
78
79
80        std::set<WorldEntity*> attachments = this->getAttachedObjects();
81        for (std::set<WorldEntity*>::iterator it = attachments.begin(); it != attachments.end(); ++it)
82        {
83            if ((*it)->isA(Class(TeamColourable)))
84            {
85                TeamColourable* tc = dynamic_cast<TeamColourable*>(*it);
86                tc->setTeamColour(colour);
87            }
88        }
89
90        this->setRadarObjectColour(colour);
91
92        // Call this so bots stop shooting at the base after they converted it
93        for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)
94            it->destroyedPawn(this);
95    }
96}
97
Note: See TracBrowser for help on using the repository browser.