Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10156 was 10156, checked in by richtero, 9 years ago

getting closer to a playable version

File size: 5.2 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#include "core/command/ConsoleCommand.h"
48
49#include "gamestates/GSLevel.h"
50#include "chat/ChatManager.h"
51
52namespace orxonox
53{
54
55        SetConsoleCommand("Mini4Dgame", "setStone", &Mini4Dgame::setStone).addShortcut();
56
57    RegisterUnloadableClass(Mini4Dgame);
58
59    /**
60    @brief
61        Constructor. Registers and initializes the object.
62    */
63    Mini4Dgame::Mini4Dgame(Context* context) : Deathmatch(context)
64    {
65        RegisterObject(Mini4Dgame);
66
67        this->board_ = 0;
68        //ConsoleCommand("Mini4Dgame", "setStone", &Mini4Dgame::setStone).addShortcut().setAsInputCommand();
69
70        // Set the type of Bots for this particular Gametype.
71        //this->botclass_ = Class(Mini4DgameBot);
72    }
73
74    /**
75    @brief
76        Destructor. Cleans up, if initialized.
77    */
78    Mini4Dgame::~Mini4Dgame()
79    {
80        if (this->isInitialized())
81            this->cleanup();
82    }
83
84    /**
85    @brief
86        Cleans up the Gametype.
87    */
88    void Mini4Dgame::cleanup()
89    {
90
91    }
92
93    /**
94    @brief
95        Starts the mini4Dgame.
96    */
97    void Mini4Dgame::start()
98    {
99        if (this->board_ != NULL) // There needs to be a Mini4DgameCenterpoint, i.e. the area the game takes place.
100        {
101                /*
102                if (this->board_ == NULL)
103                {
104                        this->board_ = new Mini4DgameBoard(this->board_->getContext());
105                        // Apply the template for the ball specified by the centerpoint.
106                        this->board_->addTemplate(this->center_->getBoardtemplate());
107                }
108                */
109
110                // Attach the board to the centerpoint and set the parameters as specified in the centerpoint, the ball is attached to.
111
112                this->board_->setPosition(0, 0, 0);
113
114        }
115        else // If no centerpoint was specified, an error is thrown and the level is exited.
116        {
117            orxout(internal_error) << "Mini4Dgame: No Centerpoint specified." << endl;
118            GSLevel::startMainMenu();
119            return;
120        }
121
122        // Set variable to temporarily force the player to spawn.
123        bool temp = this->bForceSpawn_;
124        this->bForceSpawn_ = true;
125
126        // Call start for the parent class.
127        Deathmatch::start();
128
129        // Reset the variable.
130        this->bForceSpawn_ = temp;
131    }
132
133    /**
134    @brief
135        Ends the Mini4Dgame minigame.
136    */
137    void Mini4Dgame::end()
138    {
139        this->cleanup();
140
141        // Call end for the parent class.
142        Deathmatch::end();
143    }
144
145
146    /**
147    @brief
148        Spawns player.
149    */
150    void Mini4Dgame::spawnPlayersIfRequested()
151    {
152        // first spawn human players to assign always the left bat to the player in singleplayer
153        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
154            if (it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
155                this->spawnPlayer(it->first);
156        // now spawn bots
157        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
158            if (!it->first->isHumanPlayer() && (it->first->isReadyToSpawn() || this->bForceSpawn_))
159                this->spawnPlayer(it->first);
160    }
161
162    /**
163    @brief
164        Spawns the input player.
165    @param player
166        The player to be spawned.
167    */
168    void Mini4Dgame::spawnPlayer(PlayerInfo* player)
169    {
170        assert(player);
171
172        if(false)//this->player_ == NULL)
173        {
174            //this->player_ = player;
175            this->players_[player].state_ = PlayerState::Alive;
176        }
177    }
178
179    //void Mini4Dgame::setStone(Vector4 move, const int playerColor, Mini4DgameBoard* board)
180    void Mini4Dgame::setStone(int x,int y,int z,int w)//Vector4 move, const int playerColor)
181    {
182        Vector4 move = Vector4(x,y,z,w);
183        ObjectList<Mini4DgameBoard>::iterator it = ObjectList<Mini4DgameBoard>::begin();
184        it->makeMove(move,1);//playerColor);
185    }
186
187    void Mini4Dgame::win(Mini4DgameWinner winner)
188    {
189
190    }
191}
Note: See TracBrowser for help on using the repository browser.