Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gametypes/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc @ 3019

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

set eol-style:native, no codechanges

  • Property svn:eol-style set to native
File size: 2.5 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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      Val Mikos
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
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    }
87}
88
Note: See TracBrowser for help on using the repository browser.