- Timestamp:
- Dec 11, 2017, 2:14:15 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumbaBoss.cc
r11647 r11650 31 31 @file SOBGumbaBoss.cc 32 32 @brief A Boss Gumba, which shoots small Gumbas 33 * /33 **/ 34 34 35 35 #include "SOB.h" … … 54 54 RegisterObject(SOBGumbaBoss); 55 55 56 gumbaMaxTime_ = 1; 57 gumbaTime_ = 0; 58 maxGumbas = 2; //Max Gumbas spawnable by a Boss 56 gumbaMaxTime_ = 1; 57 gumbaTime_ = 0; 58 maxGumbas_ = 10; //Max Gumbas spawnable by a Boss 59 jumpTime_ = 0; 60 jumpTimeMax_ = 5; 59 61 60 62 } … … 63 65 bool SOBGumbaBoss::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) { 64 66 67 SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject); 68 SOBGumbaBoss* gumbaBoss = orxonox_cast<SOBGumbaBoss*>(otherObject); 69 70 if (gumba != nullptr && gumbaBoss == nullptr && !(gumba->hasCollided_)) { 71 gumba->destroyLater(); 72 gumba->hasCollided_ = true; 73 } 74 75 65 76 //Every object with mass -1 does not change the direction of the GumbaBoss. For example the ground floor! The other objects switch the direction of the GumbaBoss. 66 if (changeAllowed_ && otherObject->getMass() != -1) {77 else if (changeAllowed_ && otherObject->getMass() != -1) { 67 78 goesRight_ = !goesRight_; 68 79 changeAllowed_ = false; … … 78 89 { 79 90 SUPER(SOBGumbaBoss, tick, dt); 91 gumbaTime_ += dt; 92 jumpTime_ += dt; 80 93 81 94 if (!changeAllowed_) { … … 89 102 } 90 103 91 gumbaTime_ += dt;92 104 93 105 if(gumbaTime_ > gumbaMaxTime_){ //Spawn Gumba … … 103 115 104 116 105 if(gumbaCounter<maxGumbas ){ //only maxGumbas are allowed at one time per Gumbaboss117 if(gumbaCounter<maxGumbas_){ //only maxGumbas are allowed at one time per Gumbaboss 106 118 spawnGumba(); 107 119 gumbaTime_ = 0; … … 114 126 115 127 Vector3 velocity = getVelocity(); 116 velocity.z -= gravityAcceleration_*dt; 128 if(jumpTime_ > jumpTimeMax_){ 129 velocity.z = speed_*15; 130 jumpTime_ = 0; 131 } 132 else{ 133 velocity.z -= gravityAcceleration_*dt; 134 } 135 117 136 velocity.x = dir*speed_; 118 137 setVelocity(velocity); … … 132 151 { 133 152 gumba->addTemplate("gumbaShootable"); 134 bool direction = ((this->getWorldOrientation().getRoll().valueRadians())>-1.6&&(this->getWorldOrientation().getRoll().valueRadians()<1.6)); 135 gumba->setDirection(direction); 136 if(direction) 153 gumba->setDirection(goesRight_); 154 if(goesRight_) 137 155 { 138 156 spawnpos.x+=20; … … 148 166 149 167 Vector3 velocity = gumba->getVelocity(); 150 velocity.z -= 100; 168 velocity.x += (2*goesRight_ -1) * 100; 169 velocity.z += 200; 151 170 gumba->setVelocity(velocity); 152 171 }
Note: See TracChangeset
for help on using the changeset viewer.