- Timestamp:
- Dec 12, 2017, 5:43:22 PM (7 years ago)
- Location:
- code/branches/Asteroid_HS17/src/modules/asteroids2D
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
r11660 r11666 85 85 86 86 87 88 //shoot? 87 //if you hit an asteroid, the ship will turn -> you need to reorientate the ship 88 Quaternion ort = this->getOrientation(); 89 ort.x = 0; 90 ort.z = 0; 91 this->setOrientation(ort); 89 92 } 90 93 -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc
r11660 r11666 120 120 } 121 121 122 void Asteroids2DStone::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) 123 { 124 split(); 125 //Pawn::damage(damage, healthdamage, shielddamage, originator, cs); 126 if (getGame() && orxonox_cast<Asteroids2DShip*>(originator) != nullptr && getHealth() <= 0) 127 getGame()->addPoints(3*42); 128 } 129 130 Asteroids2D* Asteroids2DStone::getGame() 131 { 132 if (game == nullptr) 133 { 134 for (Asteroids2D* asteroids : ObjectList<Asteroids2D>()) 135 game = asteroids; 136 } 137 return game; 138 } 139 122 140 void Asteroids2DStone::split() 123 141 { 124 142 orxout() << "split" << endl; 125 if(size == 1)143 if(size == 3) 126 144 { 127 this->death(); 145 Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 2, this->getPosition()); 146 newStone1->addTemplate("stone2"); 147 Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 2, this->getPosition()); 148 newStone2->addTemplate("stone2"); 128 149 129 150 }else if(size == 2){ … … 135 156 Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 1, this->getPosition()); 136 157 newStone2->addTemplate("stone1"); 137 138 }else{ 139 Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 2, this->getPosition()); 140 newStone1->addTemplate("stone1"); 141 Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 2, this->getPosition()); 142 newStone2->addTemplate("stone1"); 143 } 158 } 159 this->death(); 144 160 } 145 161 -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.h
r11637 r11666 57 57 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; 58 58 virtual void split(); 59 virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) override; 59 60 60 61 private: 62 Asteroids2D* getGame(); 63 WeakPtr<Asteroids2D> game; 61 64 WeakPtr<Asteroids2DShip> player; 62 65 int size; // three sizes, 3-> two 2s, 2-> two 1s, 1-> die
Note: See TracChangeset
for help on using the changeset viewer.