Changeset 10659 for code/branches/hoverHS15/src/modules/hover/Hover.cc
- Timestamp:
- Oct 19, 2015, 2:40:08 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hoverHS15/src/modules/hover/Hover.cc
r10658 r10659 1 <<<<<<< .mine 1 2 /* 2 3 * ORXONOX - the hottest 3D action shooter ever to exist … … 21 22 * 22 23 * Author: 23 * Florian Zinggeler24 * Cyrill Burgener 24 25 * Co-authors: 25 26 * ... … … 33 34 34 35 #include "Hover.h" 35 #include "HoverShip.h" // Necessary for getPlayer function. Do NOT include this in Header!36 #include "HoverShip.h" 36 37 #include "core/CoreIncludes.h" 37 38 … … 40 41 RegisterUnloadableClass(Hover); 41 42 42 Hover::Hover(Context* context) : GameType(context)43 Hover::Hover(Context* context) : Deathmatch(context) 43 44 { 44 45 RegisterObject(Hover); 45 46 46 //this->setHUDTemplate("HoverHUD"); 47 } 48 49 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 seconds 58 //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 0 61 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 } 50 84 51 85 void Hover::tick(float dt) 52 86 { 53 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 } 54 131 SUPER(Hover, tick, dt); 55 132 } 56 133 57 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 multiplier 157 else 158 multiplier = 1; 159 b_combo = false; 160 } 58 161 59 162 void Hover::start() 60 163 { 61 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 } 62 181 // Call start for the parent class. 63 GameType::start(); 64 } 65 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 cubes 193 /* 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 } 66 215 67 216 void Hover::end() … … 74 223 } 75 224 } 225 ======= 226 /* 227 * ORXONOX - the hottest 3D action shooter ever to exist 228 * > www.orxonox.net < 229 * 230 * 231 * License notice: 232 * 233 * This program is free software; you can redistribute it and/or 234 * modify it under the terms of the GNU General Public License 235 * as published by the Free Software Foundation; either version 2 236 * of the License, or (at your option) any later version. 237 * 238 * This program is distributed in the hope that it will be useful, 239 * but WITHOUT ANY WARRANTY; without even the implied warranty of 240 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 241 * GNU General Public License for more details. 242 * 243 * You should have received a copy of the GNU General Public License 244 * along with this program; if not, write to the Free Software 245 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 246 * 247 * Author: 248 * Florian Zinggeler 249 * Co-authors: 250 * ... 251 * 252 */ 253 254 /** 255 @file Hover.cc 256 @brief Implementation of the Hover class. 257 */ 258 259 #include "Hover.h" 260 #include "HoverShip.h" // Necessary for getPlayer function. Do NOT include this in Header! 261 #include "core/CoreIncludes.h" 262 263 namespace orxonox 264 { 265 RegisterUnloadableClass(Hover); 266 267 Hover::Hover(Context* context) : GameType(context) 268 { 269 RegisterObject(Hover); 270 271 //this->setHUDTemplate("HoverHUD"); 272 } 273 274 275 276 void Hover::tick(float dt) 277 { 278 279 SUPER(Hover, tick, dt); 280 } 281 282 283 284 void Hover::start() 285 { 286 287 // Call start for the parent class. 288 GameType::start(); 289 } 290 291 292 void Hover::end() 293 { 294 // DON'T CALL THIS! 295 // Deathmatch::end(); 296 // It will misteriously crash the game! 297 // Instead startMainMenu, this won't crash. 298 GSLevel::startMainMenu(); 299 } 300 } 301 >>>>>>> .r10658
Note: See TracChangeset
for help on using the changeset viewer.