Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2011/src/orxonox/gametypes/Mission.cc @ 8980

Last change on this file since 8980 was 8980, checked in by jo, 12 years ago

teamgametype merged into trunk

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 *      Johannes Ritz
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "Mission.h"
30//#include "TeamGametype.h"
31#include "items/Engine.h"
32#include "controllers/ArtificialController.h"
33
34#include "core/CoreIncludes.h"
35#include "network/Host.h"
36#include "worldentities/pawns/Pawn.h"
37
38namespace orxonox
39{
40    CreateUnloadableFactory(Mission);
41
42    Mission::Mission(BaseObject* creator) : TeamGametype(creator)
43    {
44        RegisterObject(Mission);
45        this->missionAccomplished_ = false;
46        this->lives_ = 10; // should be 1 as default value
47        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
48    }
49
50    void Mission::tick(float dt)
51    {
52        SUPER(Mission, tick, dt);
53
54        if (missionAccomplished_)
55        {
56            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
57            this->end();
58        }
59    }
60
61    void Mission::pawnKilled(Pawn* victim, Pawn* killer)
62    {
63        if (victim && victim->getPlayer() && this->lives_ == 1)
64        {
65            this->missionAccomplished_ = false;
66            this->end();
67        }
68    }
69
70    void Mission::start()
71    {
72        Gametype::start();
73        this->setTeams();
74        /*for (ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it != ObjectList<Engine>::end(); ++it)
75            it->setActive(false); // works -> @sr :*/
76        this->gtinfo_->sendAnnounceMessage("Your mission has started!");
77    }
78
79    //void Mission::addBots(unsigned int amount)
80
81    void Mission::end()
82    {
83        Gametype::end();
84        /*if (this->missionAccomplished_)
85            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
86        else
87            this->gtinfo_->sendAnnounceMessage("Mission failed!");
88         * */
89    }
90
91    void Mission::setTeams()
92    {//Set pawn-colours
93        for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
94        {
95            Pawn* pawn = static_cast<Pawn*>(*it);
96            if(!pawn) continue;
97                this->setDefaultObjectColour(pawn);
98        }
99    }
100
101
102
103}
Note: See TracBrowser for help on using the repository browser.