Changeset 11654 for code/branches
- Timestamp:
- Dec 11, 2017, 3:17:02 PM (7 years ago)
- Location:
- code/branches/SOBv2_HS17/src/modules/superorxobros
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.cc
r11651 r11654 106 106 } 107 107 108 void SOBGumba::die(){ 109 Vector3 velocity = this->getVelocity(); 110 velocity.y = speed_; 111 this->setVelocity(velocity); 112 } 113 108 114 void SOBGumba::tick(float dt) 109 115 { … … 141 147 if(lifetime_>maxLifetime_) 142 148 { 143 this->destroyLater();149 144 150 } 145 151 } 146 152 153 if(abs(this->getPosition().z) > 1000) delete this; 154 147 155 } 148 156 } -
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumba.h
r11651 r11654 52 52 53 53 void setDirection(const bool direction); 54 void die(); 54 55 55 56 bool attachedToFigure_; -
code/branches/SOBv2_HS17/src/modules/superorxobros/SOBGumbaBoss.cc
r11653 r11654 54 54 RegisterObject(SOBGumbaBoss); 55 55 56 gumbaMaxTime_ = 1; 57 gumbaTime_ = 0; 58 maxGumbas_ = 10; //Max Gumbas spawnable by a Boss59 jumpTime _ = 0;60 jumpTime Max_ = 5;56 gumbaMaxTime_ = 1; // time after which a Gumba is shot 57 gumbaTime_ = 0; // time since last gumba was shot 58 maxGumbas_ = 50; // Max Gumbas spawnable by a Boss 59 jumpTimeMax_ = 5; // time after which the gumba boss jumps 60 jumpTime_ = 0; // time since last jump of gumba boss 61 61 62 62 } 63 63 64 64 // PRE: otherObject collides with this. 65 // POST: collision is handled: velocity changed, small gumbas murdered 65 66 bool SOBGumbaBoss::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) { 66 67 … … 68 69 SOBGumbaBoss* gumbaBoss = orxonox_cast<SOBGumbaBoss*>(otherObject); 69 70 71 // if boss collides with small gumbas, destroy them. 70 72 if (gumba != nullptr && gumbaBoss == nullptr && !(gumba->hasCollided_)) { 71 gumba->destroyLater(); 72 gumba->hasCollided_ = true; 73 gumba->die(); 73 74 } 74 75 … … 85 86 86 87 87 88 // POST: done what was to do in a time dt 88 89 void SOBGumbaBoss::tick(float dt) 89 90 { 90 91 SUPER(SOBGumbaBoss, tick, dt); 92 93 // increase timers: 91 94 gumbaTime_ += dt; 92 95 jumpTime_ += dt; 96 97 // set y-component of position of gumba boss to 0, so he doesn't fall in to the nothing 98 Vector3 position = getPosition(); 99 position.y = 0; 100 setPosition(position); 101 93 102 94 103 if (!changeAllowed_) { … … 125 134 dir = -1; 126 135 127 Vector3 velocity = getVelocity(); //Jump 128 if(jumpTime_ > jumpTimeMax_){ 136 // 137 if(getPosition().x < 1640) 138 dir = 1; 139 else if (getPosition().x > 1750) 140 dir = -1; 141 142 //change velocity 143 Vector3 velocity = getVelocity(); 144 if(jumpTime_ > jumpTimeMax_){ // jump if the time has come. 129 145 velocity.z = speed_*15; 130 146 jumpTime_ = 0; 131 147 } 132 else{ //Gravity148 else{ 133 149 velocity.z -= gravityAcceleration_*dt; 134 150 } 135 136 151 velocity.x = dir*speed_; 137 152 setVelocity(velocity); … … 140 155 141 156 } 157 158 // spawn gumbas 142 159 void SOBGumbaBoss::spawnGumba() { 143 160 SOBCenterpoint* center_ = ((SOB*)getGametype())->center_; … … 145 162 SOBGumba* gumba = new SOBGumba(center_->getContext()); 146 163 Vector3 spawnpos = this->getWorldPosition(); 147 spawnpos.z += 0;148 164 gumba->creator_=this; 149 165 166 // we can shoot a gumba! 150 167 if (gumba != nullptr && center_ != nullptr) 151 168 {
Note: See TracChangeset
for help on using the changeset viewer.