Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc @ 11400

Last change on this file since 11400 was 11392, checked in by jkindle, 7 years ago

Lululululululululu

File size: 3.4 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 *      ...
26 *
27 */
28
29/**
30    @file Pong.cc
31    @brief Implementation of the Pong class.
32*/
33
34#include "SOB.h"
35
36#include "core/CoreIncludes.h"
37#include "core/EventIncludes.h"
38#include "core/command/Executor.h"
39#include "core/config/ConfigValueIncludes.h"
40
41#include "gamestates/GSLevel.h"
42#include "chat/ChatManager.h"
43#include "infos/PlayerInfo.h"
44
45#include "SOBCenterpoint.h"
46
47#include "SOBFigure.h"
48#include "graphics/Camera.h"
49
50namespace orxonox
51{
52
53    RegisterUnloadableClass(SOB);
54
55    /**
56    @brief
57        Constructor. Registers and initializes the object.
58    */
59    SOB::SOB(Context* context) : Deathmatch(context)
60    {
61        RegisterObject(SOB);
62        camera = nullptr;
63
64        this->center_ = nullptr;
65        figure_ = nullptr;
66
67    }
68
69    /**
70    @brief
71        Destructor. Cleans up, if initialized.
72    */
73    SOB::~SOB()
74    {
75        if (this->isInitialized())
76            this->cleanup();
77    }
78
79    void SOB::cleanup()
80    {
81        camera = nullptr;
82    }
83
84        void SOB::start()
85    {
86        if (center_ != nullptr) // There needs to be a SOBCenterpoint, i.e. the area the game takes place.
87        {
88            if (figure_ == nullptr)
89            {
90                figure_ = new SOBFigure(center_->getContext());
91                figure_->addTemplate(center_->getFigureTemplate());
92               // figure_->InitializeAnimation(center_->getContext()); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
93            }
94
95            center_->attach(figure_);
96            figure_->setPosition(0, 0, 0);
97        }
98        else // If no centerpoint was specified, an error is thrown and the level is exited.
99        {
100            orxout(internal_error) << "SOB: No Centerpoint specified." << endl;
101            GSLevel::startMainMenu();
102            return;
103        }
104
105        // Call start for the parent class.
106        Deathmatch::start();
107
108        if (figure_ != nullptr)
109        {
110            camera = figure_->getCamera();
111        }
112
113    }
114
115    void SOB::end()
116    {
117        cleanup();
118        GSLevel::startMainMenu();
119
120        Deathmatch::end();
121    }
122
123    void SOB::spawnPlayer(PlayerInfo* player)
124    {
125        assert(player);
126
127        if (figure_->getPlayer() == nullptr)
128        {
129            player->startControl(figure_);
130            players_[player].state_ = PlayerState::Alive;
131        }
132    }
133
134    PlayerInfo* SOB::getPlayer() const
135    {
136        if (this->figure_ != nullptr)
137        {
138            return this->figure_->getPlayer();
139        }
140        else
141        {
142            return nullptr;
143        }
144    }
145
146
147
148
149}
Note: See TracBrowser for help on using the repository browser.