Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 12394 was 12390, checked in by cwaupoti, 6 years ago

Zombie can now approach, tried to add waves

  • Property svn:eol-style set to native
File size: 6.9 KB
RevLine 
[10658]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:
[10930]23 *      Manuel Meier
[10658]24 *   Co-authors:
[11036]25 *      Cyrill Burgener
[10658]26 *
27 */
28
29/**
30    @file Hover.cc
[10930]31    @brief Implementation of the Hover class. Sets up the whole Minigame
[10658]32*/
33
34#include "Hover.h"
[11495]35
[11041]36#include "HoverOrigin.h"
[10708]37#include "HoverWall.h"
[12374]38
39#include "MazeGenerator.h"
[10658]40#include "core/CoreIncludes.h"
[12390]41#include "worldentities/pawns/Pawn.h"
42#include "worldentities/pawns/ScriptableControllerDrone.h"
43#include "worldentities/pawns/SpaceShip.h"
[10658]44
[12390]45#include "tools/Timer.h"
46#include "infos/Bot.h"
47#include "worldentities/pawns/ModularSpaceShip.h"
48#include "graphics/Model.h"
[12267]49
[12374]50
[12390]51
52
[10658]53namespace orxonox
54{
55    RegisterUnloadableClass(Hover);
56
[10664]57    Hover::Hover(Context* context) : Gametype(context)
[10658]58    {
59        RegisterObject(Hover);
[11035]60
[11071]61        this->origin_ = nullptr;
[11035]62        this->firstTick_ = true;
63
[10895]64        this->setHUDTemplate("HoverHUD");
[10658]65    }
[12390]66    // void Hover::spawnZombie(std::string id)
67    // {
68    //     Identifier *identifier = ClassByString("SpaceShip");
[10658]69
[12390]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
[11495]140    void Hover::tick(float dt)
[10658]141    {
[11495]142        SUPER(Hover, tick, dt);
143
[11040]144        if(this->firstTick_ && this->origin_)
[11035]145        {
146            this->firstTick_ = false;
[10787]147
[11495]148            int numCells = this->origin_->getNumCells();
149            int cellSize = this->origin_->getCellSize();
150            int cellHeight = this->origin_->getCellHeight();
[11040]151
152            MazeGenerator generator(numCells);
[11035]153            generator.generateMaze();
154            generator.renderMaze();
[10787]155
[11035]156            int* levelcode = generator.getLevelcode();
[10787]157
[10928]158            //Outer Walls
[11040]159            for(int i = 0; i<numCells; i++){
[11042]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);
[10928]164            }
165
[10930]166            //Generate inner Walls according to levelcode
[12211]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            // }
[10787]178
[12390]179           
[12374]180
181
[12390]182
[11495]183            //Generate 5 flags randomly
[12354]184            // for ( int i = 0; i < 5; i++ )
185            // {
[12374]186            //     HoverFlag* zombieship = new SpaceShip(origin_->getContext());
[12354]187            //     flag->init(rand()%numCells, rand()%numCells, cellSize);
188            //     flags_.push_back(flag);
189            // }
[10900]190
[12354]191
192
[11495]193        }//firsttick end
[10930]194
195        // Check if ship collided with one of the flags
[12354]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();
[12390]203
204        //Spawn Zombies
205        //spawnZombie(z1);
206
207
[10658]208    }
209}
Note: See TracBrowser for help on using the repository browser.