Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/minigame4DHS14/src/modules/mini4Dgame/Mini4Dgame.cc @ 10121

Last change on this file since 10121 was 10121, checked in by richtero, 10 years ago

finished getWinner function which checks if somebody has won and started on the AI.

File size: 4.3 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 *      ...
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"
43#include "core/EventIncludes.h"
44#include "core/command/Executor.h"
45#include "core/config/ConfigValueIncludes.h"
46#include "infos/PlayerInfo.h"
47
48#include "gamestates/GSLevel.h"
49#include "chat/ChatManager.h"
50
51#include "Mini4DgameCenterpoint.h"
52
53namespace 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
66        this->center_ = 0;
67        //TODO: player Null setzen
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    {
144        // first spawn human players to assign always the left bat to the player in singleplayer
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);
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);
152    }
153
154    /**
155    @brief
156        Spawns the input player.
157    @param player
158        The player to be spawned.
159    */
160    void Mini4Dgame::spawnPlayer(PlayerInfo* player)
161    {
162        assert(player);
163
164        if(false)//this->player_ == NULL)
165        {
166            //this->player_ = player;
167            this->players_[player].state_ = PlayerState::Alive;
168        }
169    }
170
171
172}
Note: See TracBrowser for help on using the repository browser.