Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/SuperOrxoBros_HS18/SuperOrxoBros_HS18/src/orxonox/gametypes/Mission.cc @ 12175

Last change on this file since 12175 was 12175, checked in by siramesh, 5 years ago

Super Orxo Bros (Sidharth Ramesh, Nisa Balta, Jeff Ren)

File size: 3.7 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
31#include "items/Engine.h"
32#include "controllers/ArtificialController.h"
33
34#include "core/CoreIncludes.h"
35#include "core/command/ConsoleCommandIncludes.h"
36#include "infos/PlayerInfo.h"
37#include "network/Host.h"
38#include "worldentities/pawns/Pawn.h"
39#include "LevelManager.h"
40
41namespace orxonox
42{
43    SetConsoleCommand("Mission", "endMission", &Mission::endMission);
44    SetConsoleCommand("Mission", "setLives", &Mission::setLivesWrapper);
45    RegisterUnloadableClass(Mission);
46
47    Mission::Mission(Context* context) : TeamGametype(context)
48    {
49        RegisterObject(Mission);
50        this->missionAccomplished_ = false;
51        this->lives_ = 10; // should be 1 as default value
52        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
53    }
54
55    void Mission::tick(float dt)
56    {
57        SUPER(Mission, tick, dt);
58
59        if (missionAccomplished_)
60        {
61            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
62            this->end();
63        }
64        else if (this->lives_ == 0)
65        {
66            this->missionAccomplished_ = false;
67            this->end();
68        }
69    }
70
71    void Mission::pawnKilled(Pawn* victim, Pawn* killer)
72    {
73        if (victim && victim->getPlayer() && victim->getPlayer()->isHumanPlayer())
74        {
75            this->lives_--;
76        }
77    }
78
79    void Mission::start()
80    {
81        Gametype::start();
82        this->setTeams();
83
84        this->gtinfo_->sendAnnounceMessage("Your mission has started!");
85    }
86
87    void Mission::end()
88    {
89        if (this->missionAccomplished_ && !this->gtinfo_->hasEnded())
90        {
91            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
92
93            LevelManager::getInstance().setLastFinishedCampaignMission(this->getFilename());
94        }
95        else if (!this->gtinfo_->hasEnded())
96            this->gtinfo_->sendAnnounceMessage("Mission failed!");
97
98        Gametype::end();
99    }
100
101    void Mission::setTeams()
102    { //Set pawn-colours
103        for (Pawn* pawn : ObjectList<Pawn>())
104        {
105            if (!pawn)
106                continue;
107            this->setDefaultObjectColour(pawn);
108        }
109    }
110    void Mission::endMission(bool accomplished)
111    {
112        for (Mission* mission : ObjectList<Mission>())
113        { //TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would end ALL missions!
114            mission->setMissionAccomplished(accomplished);
115            mission->end();
116        }
117    }
118
119    void Mission::setLivesWrapper(unsigned int amount)
120    {
121        for (Mission* mission : ObjectList<Mission>())
122        { //TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would affect ALL missions!
123            mission->setLives(amount);
124        }
125    }
126}
Note: See TracBrowser for help on using the repository browser.