[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 | |
---|
| 50 | namespace orxonox |
---|
| 51 | { |
---|
[11378] | 52 | |
---|
| 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; |
---|
[11378] | 66 | |
---|
[11370] | 67 | } |
---|
| 68 | |
---|
[11378] | 69 | /** |
---|
| 70 | @brief |
---|
| 71 | Destructor. Cleans up, if initialized. |
---|
| 72 | */ |
---|
| 73 | SOB::~SOB() |
---|
[11370] | 74 | { |
---|
[11378] | 75 | if (this->isInitialized()) |
---|
| 76 | this->cleanup(); |
---|
| 77 | } |
---|
[11370] | 78 | |
---|
[11381] | 79 | void SOB::cleanup() |
---|
| 80 | { |
---|
| 81 | camera = nullptr; |
---|
| 82 | } |
---|
[11370] | 83 | |
---|
[11378] | 84 | void SOB::start() |
---|
[11370] | 85 | { |
---|
[11378] | 86 | if (center_ != nullptr) // There needs to be a SOBCenterpoint, i.e. the area the game takes place. |
---|
[11370] | 87 | { |
---|
[11378] | 88 | if (figure_ == nullptr) |
---|
| 89 | { |
---|
| 90 | figure_ = new SOBFigure(center_->getContext()); |
---|
[11381] | 91 | figure_->addTemplate(center_->getFigureTemplate()); |
---|
| 92 | // figure_->InitializeAnimation(center_->getContext()); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
---|
[11378] | 93 | } |
---|
| 94 | |
---|
| 95 | center_->attach(figure_); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
---|
| 96 | figure_->setPosition(0, 0, 0); |
---|
[11370] | 97 | } |
---|
[11378] | 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(); |
---|
[11370] | 102 | return; |
---|
[11378] | 103 | } |
---|
[11370] | 104 | |
---|
[11378] | 105 | // Call start for the parent class. |
---|
| 106 | Deathmatch::start(); |
---|
| 107 | |
---|
| 108 | if (figure_ != nullptr) |
---|
[11370] | 109 | { |
---|
[11378] | 110 | camera = figure_->getCamera(); |
---|
[11370] | 111 | } |
---|
| 112 | |
---|
[11381] | 113 | // totalScreenShift_ = 0.0; |
---|
| 114 | // screenShiftSinceLastUpdate_ = 0.0; |
---|
| 115 | //sectionNumber_ = 0; |
---|
| 116 | //adventureNumber_ = 0; |
---|
[11378] | 117 | |
---|
[11381] | 118 | //addStartSection(); |
---|
| 119 | // addSection(); |
---|
| 120 | // addSection(); |
---|
[11370] | 121 | } |
---|
| 122 | |
---|
[11378] | 123 | void SOB::end() |
---|
[11370] | 124 | { |
---|
[11378] | 125 | cleanup(); |
---|
| 126 | GSLevel::startMainMenu(); |
---|
| 127 | |
---|
| 128 | Deathmatch::end(); |
---|
[11370] | 129 | } |
---|
| 130 | |
---|
[11378] | 131 | void SOB::spawnPlayer(PlayerInfo* player) |
---|
[11370] | 132 | { |
---|
[11378] | 133 | assert(player); |
---|
[11370] | 134 | |
---|
[11378] | 135 | if (figure_->getPlayer() == nullptr) |
---|
[11370] | 136 | { |
---|
[11378] | 137 | player->startControl(figure_); |
---|
| 138 | players_[player].state_ = PlayerState::Alive; |
---|
[11370] | 139 | } |
---|
| 140 | } |
---|
[11378] | 141 | |
---|
| 142 | PlayerInfo* SOB::getPlayer() const |
---|
[11370] | 143 | { |
---|
[11378] | 144 | if (this->figure_ != nullptr) |
---|
[11370] | 145 | { |
---|
[11378] | 146 | return this->figure_->getPlayer(); |
---|
[11370] | 147 | } |
---|
[11378] | 148 | else |
---|
| 149 | { |
---|
| 150 | return nullptr; |
---|
| 151 | } |
---|
[11370] | 152 | } |
---|
| 153 | |
---|
| 154 | |
---|
[11378] | 155 | |
---|
| 156 | |
---|
[11370] | 157 | } |
---|