Changeset 11578
- Timestamp:
- Nov 20, 2017, 4:06:43 PM (7 years ago)
- Location:
- code/branches/SOBv2_HS17/src/modules/superorxobros
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc
r11577 r11578 62 62 63 63 //Vars for movement of player 64 moveUpPressed_ = false;65 moveDownPressed_ = false;66 moveLeftPressed_ = false;67 moveDownPressed_ = false;68 firePressed_ = false;69 collDisZ_ = 0;64 moveUpPressed_ = false; 65 moveDownPressed_ = false; 66 moveLeftPressed_ = false; 67 moveDownPressed_ = false; 68 firePressed_ = false; 69 collDisZ_ = 0; 70 70 71 71 //Times and turning 72 timeSinceLastFire_ = 0.0;73 lastSpeed_z = 0.0;74 pitch_ = 0.0;75 timeCounter_ = 0;72 timeSinceLastFire_ = 0.0; 73 lastSpeed_z = 0.0; 74 pitch_ = 0.0; 75 timeCounter_ = 0; 76 76 77 77 //Properties of player 78 gotPowerUp_ = false; 79 isColliding_ = true;80 particlespawner_ = NULL;78 79 isColliding_ = true; 80 particlespawner_ = NULL; 81 81 82 82 //Properties of players life 83 predead_ = false;84 dead_ = false;85 lvlEnded_ = false;83 predead_ = false; 84 dead_ = false; 85 lvlEnded_ = false; 86 86 reachedLvlEndState_ = 0; 87 87 88 // Properties concerning PowerUps and items 89 PowerUpCounter_ = 0; 90 maxPowerUp_ = 2; 91 FireballPower = 2; 88 92 //Properties of fireing Fireballs, NOTE! fireballs are fired with the moveUP Key, not with the fire key 89 fireallowed_ =true;90 firecooldown_ =0;93 fireallowed_ = true; 94 firecooldown_ = 0; 91 95 92 96 … … 110 114 SOBCastlestone* castlestone = orxonox_cast<SOBCastlestone*> (otherObject); 111 115 SOBFireball* fireball = orxonox_cast<SOBFireball*> (otherObject); 112 113 //Check if otherObject is a powerup 116 SOB* SOBGame = orxonox_cast<SOB*> (getGametype()); 117 118 119 //Check if otherObject is a powerup-mushroom 114 120 if (mush != nullptr && !(mush->hasCollided_)) { 115 121 otherObject->destroyLater(); 116 gotPowerUp_ = true; 117 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); //Get the Gametype 122 123 PowerUpCounter_++; 124 if(PowerUpCounter_ > maxPowerUp_) PowerUpCounter_ = maxPowerUp_; // you had already the max 125 else this->changeClothes(); 126 118 127 SOBGame->addMushroom(); // Tell the gametype to increase points 119 128 mush->hasCollided_ = true; // needed because of destroyLater takes some time and player should receive points only once 120 129 121 // now, change the clothes of the Figure to red 122 std::string name = "orxo_material_gross"; 123 this->changeClothes(name); 130 124 131 125 132 } … … 133 140 if (getVelocity().z >= -20) { 134 141 // If player hasn't a power up, he dies. Else he shrinks and the gumba dies. 135 if( !gotPowerUp_){142 if(PowerUpCounter_ == 0){ 136 143 this->die(); 137 } else{ 138 gotPowerUp_ = false; 139 140 141 // now, change the clothes of the Figure to old ones 142 std::string name = "orxo_material"; 143 this->changeClothes(name); 144 } 145 else{ 146 PowerUpCounter_--; 147 this->changeClothes(); 148 144 149 gumba->destroyLater(); 145 150 gumba->hasCollided_ = true; … … 149 154 gumba->destroyLater(); 150 155 gumba->hasCollided_ = true; 151 SOB* SOBGame = orxonox_cast<SOB*>(getGametype());152 156 SOBGame->addGumba(); 153 157 … … 164 168 flagstone->hasCollided_ = true; 165 169 reachedLvlEndState_ = 1; 166 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 170 167 171 SOBGame->setDone(true); 168 172 SOBGame->addPoints(flagstone->getPoints()); … … 237 241 //if input blocked, then cancel every movement operation 238 242 if (!inputAllowed) { 239 moveUpPressed_ = false;240 moveDownPressed_ = false;241 moveLeftPressed_ = false;242 moveRightPressed_ = false;243 moveUpPressed_ = false; 244 moveDownPressed_ = false; 245 moveLeftPressed_ = false; 246 moveRightPressed_ = false; 243 247 } 244 248 … … 251 255 if (hasLocalController()) 252 256 { 257 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 253 258 Vector3 velocity = getVelocity(); 254 259 Vector3 position = getPosition(); … … 259 264 if (position.z < -100) { 260 265 dead_ = true; 261 SOB* SOBGame = orxonox_cast<SOB*>(getGametype());262 266 SOBGame->setDone(true); 263 267 } … … 268 272 velocity.z = 0; 269 273 setVelocity(velocity); 270 SOB* SOBGame = orxonox_cast<SOB*>(getGametype());274 271 275 if (firePressed_) 272 276 SOBGame->restart(); … … 322 326 323 327 //If moveUp pressed, fire a fireball 324 if(moveUpPressed_ && gotPowerUp_&& fireallowed_)328 if(moveUpPressed_ && (PowerUpCounter_ >= FireballPower) && fireallowed_) 325 329 { 326 330 spawnFireball(); 327 fireallowed_ =false;328 firecooldown_ =0;331 fireallowed_ = false; 332 firecooldown_ = 0; 329 333 } 330 334 331 335 //Increase the firecooldown 332 if(firecooldown_> 0.5)336 if(firecooldown_> 0.5) 333 337 { 334 fireallowed_ =true;338 fireallowed_ = true; 335 339 } 336 340 if(!fireallowed_) 337 341 { 338 firecooldown_ +=dt;342 firecooldown_ += dt; 339 343 } 340 344 … … 371 375 } 372 376 373 374 375 376 } 377 378 377 } 379 378 380 379 // Reset key variables 381 moveUpPressed_ = false;382 moveDownPressed_ = false;383 moveLeftPressed_ = false;384 moveRightPressed_ = false;380 moveUpPressed_ = false; 381 moveDownPressed_ = false; 382 moveLeftPressed_ = false; 383 moveRightPressed_ = false; 385 384 386 385 isColliding_ = false; … … 430 429 431 430 // PRE: name is an existing name of a material. Example orxo_material for orxo_material.material in data_extern/materials 431 // !!! PowerUpCounter_ has to be modified before changing the clothes!!! 432 432 // POST: clothes of body of player are changed to name 433 void SOBFigure::changeClothes(std::string& name){ 433 void SOBFigure::changeClothes(){ 434 // clothes: white (basic), red (one PowerUp), orange (Fireball enabled) 435 std::string clothes[] = {"orxo_material", "orxo_material_gross", "orxo_material_fire"}; 436 434 437 std::set<WorldEntity*> attachedObjects = this->getAttachedObjects(); 435 438 std::set<WorldEntity*>::iterator it; … … 439 442 if (FiguresModel != nullptr) 440 443 { 441 442 FiguresModel->setSubMaterial(name, 4); // 4 is the body 443 444 FiguresModel->setSubMaterial(clothes[PowerUpCounter_] , 4); // 4 is the body 444 445 } 445 446 } 446 447 } 447 448 // PRE: 449 // POST: Player jumps out of the game, game is finished and can be restarted. 448 450 void SOBFigure::die(){ 449 451 Vector3 vel = getVelocity(); … … 451 453 vel.z = 200; 452 454 setVelocity(vel); 453 predead_= true;455 predead_= true; 454 456 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 455 457 SOBGame->setDone(true); -
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h
r11575 r11578 46 46 virtual void boost(bool boost) override; 47 47 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; 48 void changeClothes( std::string& name);48 void changeClothes(); 49 49 void spawnFireball(); 50 50 void die(); … … 58 58 //Soooo many declarations 59 59 bool fireallowed_; 60 bool gotPowerUp_; 60 61 61 bool moveUpPressed_; 62 62 bool moveDownPressed_; … … 72 72 bool isColliding_; 73 73 WorldEntity* particlespawner_; 74 int PowerUpCounter_; 75 int maxPowerUp_; 76 int FireballPower; 74 77 int sgn(float x); 75 78 int reachedLvlEndState_;
Note: See TracChangeset
for help on using the changeset viewer.