Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Boxhead_FS19/src/modules/hover/Hover.cc @ 12399

Last change on this file since 12399 was 12398, checked in by cwaupoti, 6 years ago

temorary

  • Property svn:eol-style set to native
File size: 6.9 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 *      Manuel Meier
24 *   Co-authors:
25 *      Cyrill Burgener
26 *
27 */
28
29/**
30    @file Hover.cc
31    @brief Implementation of the Hover class. Sets up the whole Minigame
32*/
33
34#include "Hover.h"
35
36#include "HoverOrigin.h"
37#include "HoverWall.h"
38
39#include "MazeGenerator.h"
40#include "core/CoreIncludes.h"
41#include "worldentities/pawns/Pawn.h"
42#include "worldentities/pawns/ScriptableControllerDrone.h"
43#include "worldentities/pawns/SpaceShip.h"
44
45#include "tools/Timer.h"
46#include "infos/Bot.h"
47#include "worldentities/pawns/ModularSpaceShip.h"
48#include "graphics/Model.h"
49
50
51
52
53namespace orxonox
54{
55    RegisterUnloadableClass(Hover);
56
57    Hover::Hover(Context* context) : Gametype(context)
58    {
59        RegisterObject(Hover);
60
61        this->origin_ = nullptr;
62        this->firstTick_ = true;
63
64        this->setHUDTemplate("HoverHUD");
65    }
66    // void Hover::spawnZombie(std::string id)
67    // {
68    //     Identifier *identifier = ClassByString("SpaceShip");
69
70    //       if(!identifier)
71    //     {
72    //         orxout(user_error) << "Script tried to spawn unknown object" << std::endl;
73    //         return;
74    //     }
75
76    //     if(!identifier->isLoadable())
77    //     {
78    //         orxout(user_error) << "Script tried to spawn unloadable object" << std::endl;
79    //         return;
80    //     }
81       
82   
83    //     WorldEntity *entity;
84    //     Identifiable *obj = identifier->fabricate(this->controller_->getWorldEntityByID("Player")->getContext());
85
86
87
88    //     orxout(user_status) << "First hit!" << std::endl;
89
90    //    if(obj->isA(ClassIdentifier<WorldEntity>::getIdentifier()))
91    //     {
92    //         orxout(user_status) << "Is WorldEntity!" << std::endl;
93    //         entity = orxonox_cast<WorldEntity*>(obj);
94    //     }
95    //     else if(obj->isA(ClassIdentifier<PlayerInfo>::getIdentifier()))
96    //     {
97    //         // TODO This does not work yet because somehow the controllable entity is not set
98    //         // yet at this stage.
99    // //        entity = orxonox_cast<PlayerInfo*>(obj)->getControllableEntity();
100
101    //         orxout(user_status) << "Is PlayerInfo!" << std::endl;
102
103    //         //use TEMPLATES in the map to define objects that are not present on the map yet
104    //         return;
105    //     }
106    //     else
107    //     {
108    //         orxout(user_warning) << "Script tried to spawn an object that is neither a WorldEntity, nor a PlayerInfo" << std::endl;
109           
110    //         return;
111    //     }
112       
113    //     if(entity->isA(ClassIdentifier<MobileEntity>::getIdentifier())) {
114    //         orxout(user_status) << "Is MobileEntity!" << std::endl;
115    //         this->controller_->registerMobileEntity(id, orxonox_cast<MobileEntity*>(entity));
116    //     }
117
118       
119
120    //     if(entity->isA(ClassIdentifier<Pawn>::getIdentifier())) {
121    //         orxout(user_status) << "Is Pawn!" << std::endl;
122    //         this->controller_->registerPawn(id, orxonox_cast<Pawn*>(entity));
123    //     }
124       
125    //     this->controller_->registerWorldEntity(id, orxonox_cast<WorldEntity*>(entity));
126
127
128    //     ///////////////GOLD!!!!!!!!!!!!!!!////////////////////////
129    //     Pawn* pawn = this->controller_->getPawnByID(id);
130
131    //     //Attach to pawn
132    //     SpaceShip* drone = new SpaceShip(pawn->getContext()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something)
133       
134    //     drone->addTemplate("spaceshipzombie"); //ScriptableControllerDroneTemplate spaceshipescort
135
136    //     Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(500,20,500);
137    //     drone->setPosition(spawnPosition);
138    // }
139
140    void Hover::tick(float dt)
141    {
142        SUPER(Hover, tick, dt);
143
144        if(this->firstTick_ && this->origin_)
145        {
146            this->firstTick_ = false;
147
148            int numCells = this->origin_->getNumCells();
149            int cellSize = this->origin_->getCellSize();
150            int cellHeight = this->origin_->getCellHeight();
151
152            MazeGenerator generator(numCells);
153            generator.generateMaze();
154            generator.renderMaze();
155
156            int* levelcode = generator.getLevelcode();
157
158            //Outer Walls
159            for(int i = 0; i<numCells; i++){
160                (new HoverWall(origin_->getContext()))->init(0,        i+1,      cellSize, cellHeight, 1);
161                (new HoverWall(origin_->getContext()))->init(numCells, i+1,      cellSize, cellHeight, 1);
162                (new HoverWall(origin_->getContext()))->init(i+1,      0,        cellSize, cellHeight, 2);
163                (new HoverWall(origin_->getContext()))->init(i+1,      numCells, cellSize, cellHeight, 2);
164            }
165
166            //Generate inner Walls according to levelcode
167            // for(int y=0; y<numCells; y++){
168            //     for(int x=0; x<numCells; x++){
169            //         switch(levelcode[ y * numCells + x ]){
170            //             case 1: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1);
171            //                     break;
172            //             case 3: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1);
173            //             case 2: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 0);
174            //             default: break;
175            //         }
176            //     }   
177            // }
178
179           
180
181
182
183            //Generate 5 flags randomly
184            // for ( int i = 0; i < 5; i++ )
185            // {
186            //     HoverFlag* zombieship = new SpaceShip(origin_->getContext());
187            //     flag->init(rand()%numCells, rand()%numCells, cellSize);
188            //     flags_.push_back(flag);
189            // }
190
191
192
193        }//firsttick end
194
195        // Check if ship collided with one of the flags
196        // for ( unsigned int i = 0; i < flags_.size(); i++ ){
197        //     if(flags_[i]->getCollided()){
198        //         flags_[i]->destroyLater();
199        //         flags_.erase (flags_.begin()+i);
200        //     }
201        // }
202        // numberOfFlags_ = flags_.size();
203
204        //Spawn Zombies
205        //spawnZombie(z1);
206
207
208    }
209}
Note: See TracBrowser for help on using the repository browser.