Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Added mushrooms and deadzone

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