Changeset 10659 for code/branches/hoverHS15/src
- Timestamp:
- Oct 19, 2015, 2:40:08 PM (9 years ago)
- Location:
- code/branches/hoverHS15/src/modules/hover
- Files:
-
- 1 added
- 4 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 -
code/branches/hoverHS15/src/modules/hover/Hover.h
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 36 #ifndef _DodgeRace_H__ 37 #define _DodgeRace_H__ 38 39 #include "hover/HoverPrereqs.h" 40 41 42 #include "core/EventIncludes.h" 43 #include "core/command/Executor.h" 44 #include "core/config/ConfigValueIncludes.h" 45 46 #include "gamestates/GSLevel.h" 47 #include "chat/ChatManager.h" 48 #include <vector> 49 50 // ! HACK 51 #include "infos/PlayerInfo.h" 52 53 #include "core/command/ConsoleCommand.h" 54 #include "worldentities/BigExplosion.h" 55 56 #include "gametypes/Deathmatch.h" 57 #include "tools/Timer.h" 58 59 namespace orxonox 60 { 61 62 class _HoverExport Hover : public Deathmatch 63 { 64 public: 65 Hover(Context* context); 66 67 virtual void start(); 68 virtual void end(); 69 70 virtual void tick(float dt); 71 72 virtual void playerPreSpawn(PlayerInfo* player); 73 74 void levelUp(); 75 76 int getLives(){return this->lives;} 77 int getLevel(){return this->level;} 78 int getPoints(){return this->point;} 79 int getMultiplier(){return this->multiplier;} 80 81 void setCenterpoint(DodgeRaceCenterPoint* center) 82 { this->center_ = center; } 83 virtual void addBots(unsigned int amount){} //<! overwrite function in order to bypass the addbots command 84 85 // checks if multiplier should be reset. 86 void comboControll(); 87 void costLife(); 88 89 bool bEndGame; 90 bool bShowLevel; 91 int lives; 92 int multiplier; 93 float counter; 94 int pattern; 95 float currentPosition; 96 float lastPosition; 97 98 private: 99 Timer endGameTimer; 100 101 DodgeRaceShip* getPlayer(); 102 WeakPtr<DodgeRaceShip> player; 103 std::vector<DodgeRaceCube*> cubeList; 104 void toggleShowLevel(){bShowLevel = !bShowLevel;} 105 void addPoints(int numPoints); 106 107 WeakPtr<DodgeRaceCenterPoint> center_; 108 int level; 109 int point; 110 bool b_combo; 111 112 Timer enemySpawnTimer; 113 Timer comboTimer; 114 Timer showLevelTimer; 115 116 117 /* 118 119 //void spawnEnemy(); 120 121 122 123 124 125 126 127 128 129 130 131 132 private: 133 134 135 136 137 //Context* context; 138 */ 139 }; 140 } 141 142 #endif /* _DodgeRace_H__ */ 143 ======= 144 /* 145 * ORXONOX - the hottest 3D action shooter ever to exist 146 * > www.orxonox.net < 147 * 148 * 149 * License notice: 150 * 151 * This program is free software; you can redistribute it and/or 152 * modify it under the terms of the GNU General Public License 153 * as published by the Free Software Foundation; either version 2 154 * of the License, or (at your option) any later version. 155 * 156 * This program is distributed in the hope that it will be useful, 157 * but WITHOUT ANY WARRANTY; without even the implied warranty of 158 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 159 * GNU General Public License for more details. 160 * 161 * You should have received a copy of the GNU General Public License 162 * along with this program; if not, write to the Free Software 163 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 164 * 165 * Author: 166 * Florian Zinggeler 167 * Co-authors: 168 * ... 169 * 170 */ 171 172 /** 173 @file Hover.h 174 @brief Gametype. 175 @ingroup Hover 176 */ 177 35 178 #ifndef _Hover_H__ 36 179 #define _Hover_H__ … … 82 225 83 226 #endif /* _Hover_H__ */ 227 >>>>>>> .r10658 -
code/branches/hoverHS15/src/modules/hover/HoverShip.cc
r10657 r10659 21 21 * 22 22 * Author: 23 * Florian Zinggeler23 * Cyrill Burgener 24 24 * Co-authors: 25 25 * ... … … 28 28 29 29 /** 30 @file DodgeRaceShip.cc31 @brief Implementation of the DodgeRaceShip class.30 @file HoverShip.cc 31 @brief Implementation of the HoverShip class. 32 32 */ 33 33 34 #include " DodgeRaceShip.h"34 #include "HoverShip.h" 35 35 #include "core/CoreIncludes.h" 36 36 37 37 namespace orxonox 38 38 { 39 RegisterClass( DodgeRaceShip);39 RegisterClass(HoverShip); 40 40 41 DodgeRaceShip::DodgeRaceShip(Context* context) : SpaceShip(context)41 HoverShip::HoverShip(Context* context) : SpaceShip(context) 42 42 { 43 RegisterObject( DodgeRaceShip);43 RegisterObject(HoverShip); 44 44 45 45 speed = 830; … … 53 53 } 54 54 55 void DodgeRaceShip::tick(float dt)55 void HoverShip::tick(float dt) 56 56 { 57 57 Vector3 pos = getPosition(); … … 115 115 } 116 116 117 SUPER( DodgeRaceShip, tick, dt);117 SUPER(HoverShip, tick, dt); 118 118 } 119 119 120 void DodgeRaceShip::updateLevel()120 void HoverShip::updateLevel() 121 121 { 122 122 lastTime = 0; … … 125 125 } 126 126 127 void DodgeRaceShip::moveFrontBack(const Vector2& value)127 void HoverShip::moveFrontBack(const Vector2& value) 128 128 { 129 129 //lastTimeFront = 0; … … 132 132 } 133 133 134 void DodgeRaceShip::moveRightLeft(const Vector2& value)134 void HoverShip::moveRightLeft(const Vector2& value) 135 135 { 136 136 lastTimeLeft = 0; 137 137 desiredVelocity.x = value.x * speed; 138 138 } 139 void DodgeRaceShip::boost(bool bBoost)139 void HoverShip::boost(bool bBoost) 140 140 { 141 141 //getGame()->bEndGame = bBoost; 142 142 } 143 143 144 inline bool DodgeRaceShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)144 inline bool HoverShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 145 145 { 146 146 … … 150 150 } 151 151 152 DodgeRace* DodgeRaceShip::getGame()152 Hover* HoverShip::getGame() 153 153 { 154 154 if (game == NULL) 155 155 { 156 for (ObjectList< DodgeRace>::iterator it = ObjectList<DodgeRace>::begin(); it != ObjectList<DodgeRace>::end(); ++it)156 for (ObjectList<Hover>::iterator it = ObjectList<Hover>::begin(); it != ObjectList<Hover>::end(); ++it) 157 157 { 158 158 game = *it; … … 162 162 } 163 163 164 void DodgeRaceShip::death()164 void HoverShip::death() 165 165 { 166 166 getGame()->costLife(); -
code/branches/hoverHS15/src/modules/hover/HoverShip.h
r10657 r10659 21 21 * 22 22 * Author: 23 * Florian Zinggeler23 * Cyrill Burgener 24 24 * Co-authors: 25 25 * ... … … 28 28 29 29 /** 30 @file DodgeRaceShip.h31 @brief Declaration of the DodgeRaceShip class.30 @file HoverShip.h 31 @brief Declaration of the HoverShip class. 32 32 */ 33 33 34 #ifndef _ DodgeRaceShip_H__35 #define _ DodgeRaceShip_H__34 #ifndef _HoverShip_H__ 35 #define _HoverShip_H__ 36 36 37 37 38 #include " dodgerace/DodgeRacePrereqs.h"38 #include "hover/HoverPrereqs.h" 39 39 40 40 #include "core/XMLPort.h" … … 42 42 #include "graphics/Camera.h" 43 43 44 #include " DodgeRace.h" // Is necessary for getGame function44 #include "Hover.h" // Is necessary for getGame function 45 45 //#include "DodgeRaceCenterPoint.h" 46 46
Note: See TracChangeset
for help on using the changeset viewer.