Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

CMakeList added

File size: 4.6 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/command/Executor.h"
44#include "core/config/ConfigValueIncludes.h"
45
46#include "gamestates/GSLevel.h"
47#include "chat/ChatManager.h"
48
49#include "Mini4DgameCenterpoint.h"
50
51namespace orxonox
52{
53
54    RegisterUnloadableClass(Mini4Dgame);
55
56    /**
57    @brief
58        Constructor. Registers and initializes the object.
59    */
60    Mini4Dgame::Mini4Dgame(Context* context) : Deathmatch(context)
61    {
62        RegisterObject(Mini4Dgame);
63
64        this->center_ = NULL;
65        //TODO: player Null setzen
66    }
67
68    /**
69    @brief
70        Destructor. Cleans up, if initialized.
71    */
72    Mini4Dgame::~Mini4Dgame()
73    {
74        if (this->isInitialized())
75            this->cleanup();
76    }
77
78    /**
79    @brief
80        Cleans up the Gametype.
81    */
82    void Mini4Dgame::cleanup()
83    {
84
85    }
86
87    /*
88    bool Mini4Dgame::isValidMove(Vector4* move, const Mini4DgameBoard* board)
89    {
90
91    }
92    */
93
94
95    /**
96    @brief
97        Starts the Tetris minigame.
98    */
99    void Mini4Dgame::start()
100    {
101        if (this->center_ != NULL) // There needs to be a Mini4DgameCenterpoint, i.e. the area the game takes place.
102        {
103            //TODO: create all objects if they don't exist so far and attach the parameters specified in the centerpoint to them
104        }
105        else // If no centerpoint was specified, an error is thrown and the level is exited.
106        {
107            orxout(internal_error) << "Mini4Dgame: No Centerpoint specified." << endl;
108            GSLevel::startMainMenu();
109            return;
110        }
111
112        // Set variable to temporarily force the player to spawn.
113        bool temp = this->bForceSpawn_;
114        this->bForceSpawn_ = true;
115
116        // Call start for the parent class.
117        Deathmatch::start();
118
119        // Reset the variable.
120        this->bForceSpawn_ = temp;
121    }
122
123    /**
124    @brief
125        Ends the Mini4Dgame minigame.
126    */
127    void Mini4Dgame::end()
128    {
129        this->cleanup();
130
131        // Call end for the parent class.
132        Deathmatch::end();
133    }
134
135
136    /**
137    @brief
138        Spawns player.
139    */
140    void Mini4Dgame::spawnPlayersIfRequested()
141    {
142        // first spawn human players to assign always the left bat to the player in singleplayer
143        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
144            if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
145                this->spawnPlayer(it->first);
146        // now spawn bots
147        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
148            if (!it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
149                this->spawnPlayer(it->first);
150    }
151
152    /**
153    @brief
154        Spawns the input player.
155    @param player
156        The player to be spawned.
157    */
158    void Mini4Dgame::spawnPlayer(PlayerInfo* player)
159    {
160        assert(player);
161
162        if(false)//this->player_ == NULL)
163        {
164            //this->player_ = player;
165            this->players_[player].state_ = PlayerState::Alive;
166        }
167    }
168
169
170    /**
171    @brief
172        Get the player.
173    @return
174        Returns a pointer to the player. If there is no player, NULL is returned.
175    */
176    //TODO: colors
177    PlayerInfo* Mini4Dgame::getPlayer(int color) const
178    {
179        return players[color];
180        //for(int i=0;i<NUMBEROFPLAYERS;i++)
181                //if(color == this->mini4DgamePlayers[i].color)
182                        //return this->mini4DgamePlayers[i].info;
183    }
184
185}
Note: See TracBrowser for help on using the repository browser.