Changeset 10660 for code/branches/hoverHS15/src/modules/hover/Hover.cc
- Timestamp:
- Oct 19, 2015, 2:51:49 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hoverHS15/src/modules/hover/Hover.cc
r10659 r10660 1 <<<<<<< .mine2 /*3 * ORXONOX - the hottest 3D action shooter ever to exist4 * > www.orxonox.net <5 *6 *7 * License notice:8 *9 * This program is free software; you can redistribute it and/or10 * modify it under the terms of the GNU General Public License11 * as published by the Free Software Foundation; either version 212 * of the License, or (at your option) any later version.13 *14 * This program is distributed in the hope that it will be useful,15 * but WITHOUT ANY WARRANTY; without even the implied warranty of16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17 * GNU General Public License for more details.18 *19 * You should have received a copy of the GNU General Public License20 * along with this program; if not, write to the Free Software21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.22 *23 * Author:24 * Cyrill Burgener25 * Co-authors:26 * ...27 *28 */29 30 /**31 @file Hover.cc32 @brief Implementation of the Hover class.33 */34 35 #include "Hover.h"36 #include "HoverShip.h"37 #include "core/CoreIncludes.h"38 39 namespace orxonox40 {41 RegisterUnloadableClass(Hover);42 43 Hover::Hover(Context* context) : Deathmatch(context)44 {45 RegisterObject(Hover);46 47 bEndGame = false;48 lives = 1;49 level = 1;50 point = 0;51 bShowLevel = false;52 multiplier = 1;53 b_combo = false;54 counter = 5000;55 pattern = 1;56 lastPosition = 0;57 // spawn enemy every 3.5 seconds58 //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Hover::spawnEnemy, this)));59 comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Hover::comboControll, this)));60 this->numberOfBots_ = 0; //sets number of default bots temporarly to 061 this->center_ = 0;62 63 this->setHUDTemplate("HoverHUD");64 }65 66 void Hover::levelUp()67 {68 level++;69 if (getPlayer() != NULL)70 {71 for (int i = 0; i < 7; i++)72 {73 BigExplosion* chunk = new BigExplosion(this->center_->getContext());74 chunk->setPosition(Vector3(600, 0, 100.f * i - 300));75 chunk->setVelocity(Vector3(1000, 0, 0)); //player->getVelocity()76 chunk->setScale(20);77 }78 }79 addPoints(multiplier * 42);80 multiplier *= 2;81 toggleShowLevel();82 showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Hover::toggleShowLevel, this)));83 }84 85 void Hover::tick(float dt)86 {87 if (getPlayer() != NULL)88 {89 currentPosition = getPlayer()->getWorldPosition().x;90 counter = counter + (currentPosition - lastPosition);91 lastPosition = currentPosition;92 point = (int) currentPosition;93 getPlayer()->speed = 830.0f - (point / 1000);94 95 for(unsigned int i=0; i < cubeList.size();i++)96 {97 if(cubeList.at(i)->getPosition().x < currentPosition-3000)98 {99 cubeList.at(i)->destroy();100 cubeList.erase(cubeList.begin()+i);101 }102 }103 104 if(counter >= 3000)105 {106 counter = 0;107 for(int i = 0; i<6; i++)108 {109 HoverCube* cube = new HoverCube(this->center_->getContext());110 cubeList.push_back(cube);111 switch(pattern)112 {113 case 1: cube->addTemplate("HoverCube01");114 break;115 case 2: cube->addTemplate("HoverCube02");116 break;117 118 }119 120 cube->setPosition(getPlayer()->getWorldPosition() + Vector3(5000.0f, 0.0f, -3600.0f + (i*1200)));121 //stEntity->setScale3D(50,50,50);122 }123 124 125 pattern %= 2;126 pattern ++;127 128 }129 130 }131 SUPER(Hover, tick, dt);132 }133 134 HoverShip* Hover::getPlayer()135 {136 if (player == NULL)137 {138 for (ObjectList<HoverShip>::iterator it = ObjectList<HoverShip>::begin(); it != ObjectList<HoverShip>::end(); ++it)139 {140 player = *it;141 }142 }143 return player;144 }145 146 void Hover::costLife()147 {148 //endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&Hover::end, this)));149 lives = 0;150 };151 152 void Hover::comboControll()153 {154 if (b_combo)155 multiplier++;156 // if no combo was performed before, reset multiplier157 else158 multiplier = 1;159 b_combo = false;160 }161 162 void Hover::start()163 {164 orxout() << "start" << endl;165 for(unsigned int i=0; i< cubeList.size();i++)166 {167 cubeList.at(i)->destroy();168 cubeList.erase(cubeList.begin()+i);169 170 }171 cubeList.clear();172 // Set variable to temporarily force the player to spawn.173 this->bForceSpawn_ = false;174 175 if (this->center_ == NULL) // abandon mission!176 {177 orxout(internal_error) << "Hover: No Centerpoint specified." << endl;178 GSLevel::startMainMenu();179 return;180 }181 // Call start for the parent class.182 Deathmatch::start();183 }184 185 void Hover::playerPreSpawn(PlayerInfo* player)186 {187 if(lives <= 0)188 {189 this->end();190 }191 192 // Reset all the cubes193 /*194 orxout() << "prespawn" << endl;195 for(int i=0; i< cubeList.size();i++)196 {197 cubeList.at(i)->destroy();198 cubeList.erase(cubeList.begin()+i);199 }200 cubeList.clear();201 lives = 1;202 point = 0;203 lastPosition = 0;204 */205 }206 207 void Hover::addPoints(int numPoints)208 {209 if (!bEndGame)210 {211 point += numPoints * multiplier;212 b_combo = true;213 }214 }215 216 void Hover::end()217 {218 // DON'T CALL THIS!219 // Deathmatch::end();220 // It will misteriously crash the game!221 // Instead startMainMenu, this won't crash.222 GSLevel::startMainMenu();223 }224 }225 =======226 1 /* 227 2 * ORXONOX - the hottest 3D action shooter ever to exist … … 257 32 */ 258 33 34 //#include "orxonox/worldentities/pawns/SpaceShip.h" 259 35 #include "Hover.h" 260 #include "HoverShip.h" // Necessary for getPlayer function. Do NOT include this in Header!36 //#include "HoverShip.h" // Necessary for getPlayer function. Do NOT include this in Header! 261 37 #include "core/CoreIncludes.h" 262 38 … … 285 61 { 286 62 63 287 64 // Call start for the parent class. 288 65 GameType::start(); … … 299 76 } 300 77 } 301 >>>>>>> .r10658
Note: See TracChangeset
for help on using the changeset viewer.