| 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 | |
|---|
| 44 | #include "SOBCenterpoint.h" |
|---|
| 45 | |
|---|
| 46 | //#include "PongBat.h" |
|---|
| 47 | //#include "PongBot.h" |
|---|
| 48 | //#include "PongAI.h" |
|---|
| 49 | |
|---|
| 50 | namespace 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 | |
|---|
| 63 | this->center_ = nullptr; |
|---|
| 64 | figure_ = nullptr; |
|---|
| 65 | |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | /** |
|---|
| 69 | @brief |
|---|
| 70 | Destructor. Cleans up, if initialized. |
|---|
| 71 | */ |
|---|
| 72 | SOB::~SOB() |
|---|
| 73 | { |
|---|
| 74 | if (this->isInitialized()) |
|---|
| 75 | this->cleanup(); |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | void SOB::start() |
|---|
| 81 | { |
|---|
| 82 | if (center_ != nullptr) // There needs to be a SOBCenterpoint, i.e. the area the game takes place. |
|---|
| 83 | { |
|---|
| 84 | if (figure_ == nullptr) |
|---|
| 85 | { |
|---|
| 86 | figure_ = new SOBFigure(center_->getContext()); |
|---|
| 87 | figure_->addTemplate(center_->getFigureTemplate()); / |
|---|
| 88 | figure_->InitializeAnimation(center_->getContext()); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | center_->attach(figure_); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|---|
| 92 | figure_->setPosition(0, 0, 0); |
|---|
| 93 | } |
|---|
| 94 | else // If no centerpoint was specified, an error is thrown and the level is exited. |
|---|
| 95 | { |
|---|
| 96 | orxout(internal_error) << "SOB: No Centerpoint specified." << endl; |
|---|
| 97 | GSLevel::startMainMenu(); |
|---|
| 98 | return; |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | // Call start for the parent class. |
|---|
| 102 | Deathmatch::start(); |
|---|
| 103 | |
|---|
| 104 | if (figure_ != nullptr) |
|---|
| 105 | { |
|---|
| 106 | camera = figure_->getCamera(); |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | totalScreenShift_ = 0.0; |
|---|
| 110 | screenShiftSinceLastUpdate_ = 0.0; |
|---|
| 111 | sectionNumber_ = 0; |
|---|
| 112 | adventureNumber_ = 0; |
|---|
| 113 | |
|---|
| 114 | addStartSection(); |
|---|
| 115 | addSection(); |
|---|
| 116 | addSection(); |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | void SOB::end() |
|---|
| 120 | { |
|---|
| 121 | cleanup(); |
|---|
| 122 | GSLevel::startMainMenu(); |
|---|
| 123 | |
|---|
| 124 | Deathmatch::end(); |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | void SOB::spawnPlayer(PlayerInfo* player) |
|---|
| 128 | { |
|---|
| 129 | assert(player); |
|---|
| 130 | |
|---|
| 131 | if (figure_->getPlayer() == nullptr) |
|---|
| 132 | { |
|---|
| 133 | player->startControl(figure_); |
|---|
| 134 | players_[player].state_ = PlayerState::Alive; |
|---|
| 135 | } |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | PlayerInfo* SOB::getPlayer() const |
|---|
| 139 | { |
|---|
| 140 | if (this->figure_ != nullptr) |
|---|
| 141 | { |
|---|
| 142 | return this->figure_->getPlayer(); |
|---|
| 143 | } |
|---|
| 144 | else |
|---|
| 145 | { |
|---|
| 146 | return nullptr; |
|---|
| 147 | } |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | } |
|---|