Changeset 11378 for code/branches/SuperOrxoBros_FS17/src
- Timestamp:
- Mar 23, 2017, 3:53:52 PM (8 years ago)
- Location:
- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt
r11370 r11378 1 SET_SOURCE_FILES(Superorxobros_SRC_FILES 2 Orxo.cc 1 SET_SOURCE_FILES(SOB_SRC_FILES 3 2 3 SOBCenterpoint.cc 4 SOB.cc 5 SOBFigure.cc 6 4 7 5 8 ) … … 11 14 orxonox 12 15 overlays 13 weapons 14 SOURCE_FILES ${Superorxobros_SRC_FILES} 16 SOURCE_FILES ${SOB_SRC_FILES} 15 17 ) -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
r11370 r11378 21 21 * 22 22 * Author: 23 * F lorian Zinggeler23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 25 * ... … … 28 28 29 29 /** 30 @file Invader.cc31 @brief Implementation of the Invaderclass.30 @file Pong.cc 31 @brief Implementation of the Pong class. 32 32 */ 33 33 34 #include " Invader.h"35 #include "Highscore.h" 34 #include "SOB.h" 35 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/EventIncludes.h" … … 42 42 #include "chat/ChatManager.h" 43 43 44 // ! HACK 45 #include "infos/PlayerInfo.h" 44 #include "SOBCenterpoint.h" 46 45 47 #include "InvaderCenterPoint.h" 48 #include "InvaderShip.h" 49 #include "InvaderEnemy.h" 50 #include "InvaderEnemyShooter.h" 51 52 #include "core/command/ConsoleCommand.h" 53 #include "worldentities/ExplosionPart.h" 46 //#include "PongBat.h" 47 //#include "PongBot.h" 48 //#include "PongAI.h" 54 49 55 50 namespace orxonox 56 51 { 57 RegisterUnloadableClass(Invader); 52 53 RegisterUnloadableClass(SOB); 58 54 59 Invader::Invader(Context* context) : Deathmatch(context) 55 /** 56 @brief 57 Constructor. Registers and initializes the object. 58 */ 59 SOB::SOB(Context* context) : Deathmatch(context) 60 60 { 61 RegisterObject( Invader);62 this->numberOfBots_ = 0; //sets number of default bots temporarly to 0 61 RegisterObject(SOB); 62 63 63 this->center_ = nullptr; 64 bEndGame = false; 65 lives = 3; 66 level = 1; 67 point = 0; 68 bShowLevel = false; 69 multiplier = 1; 70 b_combo = false; 71 // spawn enemy every 3.5 seconds 72 enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this))); 73 comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Invader::comboControll, this))); 74 this->setHUDTemplate("InvaderHUD"); 64 figure_ = nullptr; 65 75 66 } 76 67 77 void Invader::levelUp() 68 /** 69 @brief 70 Destructor. Cleans up, if initialized. 71 */ 72 SOB::~SOB() 78 73 { 79 level++; 80 if (getPlayer() != nullptr) 81 { 82 for (int i = 0; i < 7; i++) 83 { 84 85 WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext()); 86 chunk5->setPosition(this->center_->getPosition()); 87 chunk5->setVelocity(Vector3(1000, 0, 0)); //player->getVelocity() 88 chunk5->setScale(10); 89 chunk5->setEffect1("Orxonox/explosion2b"); 90 chunk5->setEffect2("Orxonox/smoke6"); 91 chunk5->setMinSpeed(0); 92 chunk5->setMaxSpeed(0); 93 chunk5->Explode(); 94 95 } 96 } 97 addPoints(multiplier * 42); 98 multiplier *= 2; 99 toggleShowLevel(); 100 showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Invader::toggleShowLevel, this))); 74 if (this->isInitialized()) 75 this->cleanup(); 101 76 } 102 77 103 InvaderShip* Invader::getPlayer() 78 79 80 void SOB::start() 104 81 { 105 if ( player == nullptr)82 if (center_ != nullptr) // There needs to be a SOBCenterpoint, i.e. the area the game takes place. 106 83 { 107 for (InvaderShip* ship : ObjectList<InvaderShip>()) 108 player = ship; 84 if (figure_ == nullptr) 85 { 86 figure_ = new SOBFigure(center_->getContext()); 87 figure_->addTemplate(center_->getFigureTemplate()); / 88 figure_->InitializeAnimation(center_->getContext()); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 89 } 90 91 center_->attach(figure_); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 92 figure_->setPosition(0, 0, 0); 109 93 } 110 return player; 94 else // If no centerpoint was specified, an error is thrown and the level is exited. 95 { 96 orxout(internal_error) << "SOB: No Centerpoint specified." << endl; 97 GSLevel::startMainMenu(); 98 return; 99 } 100 101 // Call start for the parent class. 102 Deathmatch::start(); 103 104 if (figure_ != nullptr) 105 { 106 camera = figure_->getCamera(); 107 } 108 109 totalScreenShift_ = 0.0; 110 screenShiftSinceLastUpdate_ = 0.0; 111 sectionNumber_ = 0; 112 adventureNumber_ = 0; 113 114 addStartSection(); 115 addSection(); 116 addSection(); 111 117 } 112 118 113 void Invader::spawnEnemy()119 void SOB::end() 114 120 { 115 if (getPlayer() == nullptr) 116 return; 121 cleanup(); 122 GSLevel::startMainMenu(); 123 124 Deathmatch::end(); 125 } 117 126 118 for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++) 127 void SOB::spawnPlayer(PlayerInfo* player) 128 { 129 assert(player); 130 131 if (figure_->getPlayer() == nullptr) 119 132 { 120 InvaderEnemy* newPawn; 121 if (rand() % 42/(1 + level*level) == 0) 122 { 123 newPawn = new InvaderEnemyShooter(this->center_->getContext()); 124 newPawn->addTemplate("enemyinvadershooter"); 125 } 126 else 127 { 128 newPawn = new InvaderEnemy(this->center_->getContext()); 129 newPawn->addTemplate("enemyinvader"); 130 } 131 newPawn->setInvaderPlayer(player); 132 newPawn->level = level; 133 // spawn enemy at random points in front of player. 134 newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200)); 133 player->startControl(figure_); 134 players_[player].state_ = PlayerState::Alive; 135 135 } 136 136 } 137 137 138 void Invader::setCenterpoint(InvaderCenterPoint* center)138 PlayerInfo* SOB::getPlayer() const 139 139 { 140 this->center_ = center; 141 } 142 143 void Invader::costLife() 144 { 145 lives--; 146 multiplier = 1; 147 // end the game in 30 seconds. 148 if (lives <= 0) 149 enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&Invader::end, this))); 150 }; 151 152 void Invader::comboControll() 153 { 154 if (b_combo) 155 multiplier++; 156 // if no combo was performed before, reset multiplier 140 if (this->figure_ != nullptr) 141 { 142 return this->figure_->getPlayer(); 143 } 157 144 else 158 multiplier = 1;159 b_combo = false;160 }161 162 void Invader::start()163 {164 // Set variable to temporarily force the player to spawn.165 this->bForceSpawn_ = true;166 167 if (this->center_ == nullptr) // abandon mission!168 145 { 169 orxout(internal_error) << "Invader: No Centerpoint specified." << endl; 170 GSLevel::startMainMenu(); 171 return; 172 } 173 // Call start for the parent class. 174 Deathmatch::start(); 175 } 176 void Invader::addPoints(int numPoints) 177 { 178 if (!bEndGame) 179 { 180 point += numPoints * multiplier; 181 b_combo = true; 146 return nullptr; 182 147 } 183 148 } 184 149 185 void Invader::end()186 {187 // DON'T CALL THIS!188 // Deathmatch::end();189 // It will misteriously crash the game!190 // Instead startMainMenu, this won't crash.191 if (Highscore::exists()){192 int score = this->getPoints();193 if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade"))194 Highscore::getInstance().storeHighscore("Orxonox Arcade",score);195 150 196 } 197 GSLevel::startMainMenu(); 198 } 151 152 199 153 } -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
r11370 r11378 21 21 * 22 22 * Author: 23 * F lorian Zinggeler23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 25 * ... … … 28 28 29 29 /** 30 @file Invader.h31 @brief Gametype.32 @ingroup Invader30 @file Pong.h 31 @brief Declaration of the Pong class. 32 @ingroup Pong 33 33 */ 34 34 35 #ifndef _ Invader_H__36 #define _ Invader_H__35 #ifndef _SOB_H__ 36 #define _SOB_H__ 37 37 38 #include "invader/InvaderPrereqs.h" 38 #include "superorxobros/SOBPrereqs.h" 39 40 #include "tools/Timer.h" 39 41 40 42 #include "gametypes/Deathmatch.h" 41 #include " tools/Timer.h"43 #include "SOBCenterpoint.h" 42 44 43 45 namespace orxonox 44 46 { 45 47 46 class _InvaderExport Invader : public Deathmatch 48 49 class _SOBExport SOB : public Deathmatch 47 50 { 48 51 public: 49 Invader(Context* context); 52 SOB(Context* context); //!< Constructor. Registers and initializes the object. 53 virtual ~SOB(); //!< Destructor. Cleans up, if initialized. 50 54 51 virtual void start() override; 52 virtual void end() override; 53 virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command 55 56 void setCenterpoint(SOBCenterpoint* center) 57 { this->center_ = center; } 58 void setFigureTemplate(const std::string& newTemplate) 59 { this->figureTemplate_ = newTemplate; } 60 61 const std::string& getFigureTemplate() const 62 { return this->figureTemplate_; } 63 64 65 protected: 66 54 67 55 void spawnEnemy(); 56 57 void setCenterpoint(InvaderCenterPoint* center); 58 59 int getLives(){return this->lives;} 60 int getLevel(){return this->level;} 61 int getPoints(){return this->point;} 62 int getMultiplier(){return this->multiplier;} 63 64 void costLife(); 65 void levelUp(); 66 void addPoints(int numPoints); 67 // checks if multiplier should be reset. 68 void comboControll(); 69 int lives; 70 int multiplier; 71 bool bEndGame; 72 bool bShowLevel; 73 private: 74 void toggleShowLevel(){bShowLevel = !bShowLevel;} 75 InvaderShip* getPlayer(); 76 WeakPtr<InvaderCenterPoint> center_; 77 WeakPtr<InvaderShip> player; 78 79 Timer enemySpawnTimer; 80 Timer comboTimer; 81 Timer showLevelTimer; 82 //Context* context; 83 int level; 84 int point; 85 bool b_combo; 68 void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats. 69 WeakPtr<SOBCenterpoint> center_; 70 WeakPtr<SOBFigure> figure_; 71 WeakPtr<Camera> camera; 72 86 73 }; 87 74 } 88 75 89 #endif /* _ Invader_H__ */76 #endif /* _Pong_H__ */
Note: See TracChangeset
for help on using the changeset viewer.