Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11666


Ignore:
Timestamp:
Dec 12, 2017, 5:43:22 PM (7 years ago)
Author:
vyang
Message:

damage Funktion der Steine ueberschrieben → Sie koennen sich teilen

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  
    8585
    8686
    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);
    8992    }
    9093
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc

    r11660 r11666  
    120120    }
    121121
     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
    122140    void Asteroids2DStone::split()
    123141    {
    124142        orxout() << "split" << endl;
    125         if(size == 1)
     143        if(size == 3)
    126144        {
    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");
    128149
    129150        }else if(size == 2){
     
    135156            Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 1, this->getPosition());
    136157            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();
    144160    }
    145161
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.h

    r11637 r11666  
    5757            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
    5858            virtual void split();
     59            virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs) override;
    5960
    6061       private:
     62          Asteroids2D* getGame();
     63          WeakPtr<Asteroids2D> game;
    6164          WeakPtr<Asteroids2DShip> player;         
    6265                int size;                               // three sizes, 3-> two 2s, 2-> two 1s, 1-> die
Note: See TracChangeset for help on using the changeset viewer.