Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc @ 3087

Last change on this file since 3087 was 3086, checked in by landauf, 15 years ago

added bot-support for TeamBaseMatch (and some small fixes)

  • 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 "objects/Teamcolourable.h"
34
35namespace orxonox
36{
37    CreateFactory(TeamBaseMatchBase);
38
39    TeamBaseMatchBase::TeamBaseMatchBase(BaseObject* creator) : Pawn(creator)
40    {
41        RegisterObject(TeamBaseMatchBase);
42
43        this->state_ = BaseState::uncontrolled;
44
45        TeamBaseMatch* gametype = dynamic_cast<TeamBaseMatch*>(this->getGametype());
46        if (gametype)
47        {
48            gametype->addBase(this);
49        }
50
51        this->setRadarObjectShape(RadarViewable::Triangle);
52    }
53
54    void TeamBaseMatchBase::changeTeamColour()
55    {
56        this->fireEvent();
57
58        TeamDeathmatch* gametype = dynamic_cast<TeamDeathmatch*>(this->getGametype());
59        if (!gametype)
60            return;
61
62        ColourValue colour;
63
64        switch (this->state_)
65        {
66            case BaseState::controlTeam1:
67                colour = gametype->getTeamColour(0);
68                break;
69            case BaseState::controlTeam2:
70                colour = gametype->getTeamColour(1);
71                break;
72            case BaseState::uncontrolled:
73            default:
74                colour = ColourValue(0.5, 0.5, 0.5, 1.0);
75                break;
76        }
77
78
79        std::set<WorldEntity*> attachments = this->getAttachedObjects();
80        for (std::set<WorldEntity*>::iterator it = attachments.begin(); it != attachments.end(); ++it)
81        {
82            if ((*it)->isA(Class(Teamcolourable)))
83            {
84                Teamcolourable* tc = dynamic_cast<Teamcolourable*>(*it);
85                tc->setTeamColour(colour);
86            }
87        }
88
89        this->setRadarObjectColour(colour);
90
91        // Call this so bots stop shooting at the base after they converted it
92        for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)
93            it->destroyedPawn(this);
94    }
95}
96
Note: See TracBrowser for help on using the repository browser.