[10097] | 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 | * ... |
---|
| 24 | * Co-authors: |
---|
| 25 | * Johannes Ritz |
---|
| 26 | * |
---|
| 27 | * |
---|
| 28 | * |
---|
| 29 | * |
---|
| 30 | *TASK c) end the game in a nicer way |
---|
| 31 | *TASK d) save the highscore |
---|
| 32 | *TASK e) eye candy |
---|
| 33 | */ |
---|
| 34 | |
---|
| 35 | /** |
---|
| 36 | @file Tetris.cc |
---|
| 37 | @brief Implementation of the Mini4Dgame class. |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | #include "Mini4Dgame.h" |
---|
| 41 | |
---|
| 42 | #include "core/CoreIncludes.h" |
---|
[10101] | 43 | #include "core/EventIncludes.h" |
---|
[10097] | 44 | #include "core/command/Executor.h" |
---|
| 45 | #include "core/config/ConfigValueIncludes.h" |
---|
[10101] | 46 | #include "infos/PlayerInfo.h" |
---|
[10097] | 47 | |
---|
| 48 | #include "gamestates/GSLevel.h" |
---|
| 49 | #include "chat/ChatManager.h" |
---|
| 50 | |
---|
| 51 | #include "Mini4DgameCenterpoint.h" |
---|
| 52 | |
---|
| 53 | namespace orxonox |
---|
| 54 | { |
---|
| 55 | |
---|
| 56 | RegisterUnloadableClass(Mini4Dgame); |
---|
| 57 | |
---|
| 58 | /** |
---|
| 59 | @brief |
---|
| 60 | Constructor. Registers and initializes the object. |
---|
| 61 | */ |
---|
| 62 | Mini4Dgame::Mini4Dgame(Context* context) : Deathmatch(context) |
---|
| 63 | { |
---|
| 64 | RegisterObject(Mini4Dgame); |
---|
| 65 | |
---|
[10101] | 66 | this->center_ = 0; |
---|
[10100] | 67 | //TODO: player Null setzen |
---|
[10097] | 68 | } |
---|
| 69 | |
---|
| 70 | /** |
---|
| 71 | @brief |
---|
| 72 | Destructor. Cleans up, if initialized. |
---|
| 73 | */ |
---|
| 74 | Mini4Dgame::~Mini4Dgame() |
---|
| 75 | { |
---|
| 76 | if (this->isInitialized()) |
---|
| 77 | this->cleanup(); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | @brief |
---|
| 82 | Cleans up the Gametype. |
---|
| 83 | */ |
---|
| 84 | void Mini4Dgame::cleanup() |
---|
| 85 | { |
---|
| 86 | |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | /* |
---|
| 90 | bool Mini4Dgame::isValidMove(Vector4* move, const Mini4DgameBoard* board) |
---|
| 91 | { |
---|
| 92 | |
---|
| 93 | } |
---|
| 94 | */ |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | /** |
---|
| 98 | @brief |
---|
| 99 | Starts the Tetris minigame. |
---|
| 100 | */ |
---|
| 101 | void Mini4Dgame::start() |
---|
| 102 | { |
---|
| 103 | if (this->center_ != NULL) // There needs to be a Mini4DgameCenterpoint, i.e. the area the game takes place. |
---|
| 104 | { |
---|
| 105 | //TODO: create all objects if they don't exist so far and attach the parameters specified in the centerpoint to them |
---|
| 106 | } |
---|
| 107 | else // If no centerpoint was specified, an error is thrown and the level is exited. |
---|
| 108 | { |
---|
| 109 | orxout(internal_error) << "Mini4Dgame: No Centerpoint specified." << endl; |
---|
| 110 | GSLevel::startMainMenu(); |
---|
| 111 | return; |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | // Set variable to temporarily force the player to spawn. |
---|
| 115 | bool temp = this->bForceSpawn_; |
---|
| 116 | this->bForceSpawn_ = true; |
---|
| 117 | |
---|
| 118 | // Call start for the parent class. |
---|
| 119 | Deathmatch::start(); |
---|
| 120 | |
---|
| 121 | // Reset the variable. |
---|
| 122 | this->bForceSpawn_ = temp; |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | /** |
---|
| 126 | @brief |
---|
| 127 | Ends the Mini4Dgame minigame. |
---|
| 128 | */ |
---|
| 129 | void Mini4Dgame::end() |
---|
| 130 | { |
---|
| 131 | this->cleanup(); |
---|
| 132 | |
---|
| 133 | // Call end for the parent class. |
---|
| 134 | Deathmatch::end(); |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | /** |
---|
| 139 | @brief |
---|
| 140 | Spawns player. |
---|
| 141 | */ |
---|
| 142 | void Mini4Dgame::spawnPlayersIfRequested() |
---|
| 143 | { |
---|
[10100] | 144 | // first spawn human players to assign always the left bat to the player in singleplayer |
---|
[10097] | 145 | for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) |
---|
| 146 | if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_)) |
---|
| 147 | this->spawnPlayer(it->first); |
---|
[10100] | 148 | // now spawn bots |
---|
| 149 | for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) |
---|
| 150 | if (!it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_)) |
---|
| 151 | this->spawnPlayer(it->first); |
---|
[10097] | 152 | } |
---|
| 153 | |
---|
| 154 | /** |
---|
| 155 | @brief |
---|
| 156 | Spawns the input player. |
---|
| 157 | @param player |
---|
| 158 | The player to be spawned. |
---|
| 159 | */ |
---|
[10100] | 160 | void Mini4Dgame::spawnPlayer(PlayerInfo* player) |
---|
[10097] | 161 | { |
---|
| 162 | assert(player); |
---|
| 163 | |
---|
[10100] | 164 | if(false)//this->player_ == NULL) |
---|
[10097] | 165 | { |
---|
[10100] | 166 | //this->player_ = player; |
---|
[10097] | 167 | this->players_[player].state_ = PlayerState::Alive; |
---|
| 168 | } |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | } |
---|