Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc @ 12190

Last change on this file since 12190 was 12190, checked in by merholzl, 14 months ago

TD merge

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1//
2//  TowerDefenseEnemy.cc
3//  Orxonox
4//
5//  Created by Jonas Erb on 22.10.14.
6
7#include "TowerDefenseEnemy.h"
8#include "core/CoreIncludes.h"
9//#include "core/XMLPort.h"
10
11namespace orxonox
12{
13    RegisterClass(TowerDefenseEnemy);
14
15    /**
16    @brief
17        Constructor. Registers and initializes the object.
18    */
19    TowerDefenseEnemy::TowerDefenseEnemy(Context* context) : SpaceShip(context)
20    {
21        RegisterObject(TowerDefenseEnemy);
22
23        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
24        //needed to keep track of the PlayerStats coded in TowerDefense.h
25        this->td = orxonox_cast<TowerDefense*>(this->getGametype());
26        once_ = false;
27    }
28
29    TowerDefenseEnemy::~TowerDefenseEnemy()
30    {
31    }
32
33    WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
34    {
35        if (game == nullptr)
36        {
37            for (TowerDefense* towerDefense : ObjectList<TowerDefense>())
38                game = towerDefense;
39        }
40        return game;
41    }
42
43    void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
44    {
45        Pawn::damage(damage, healthdamage, shielddamage, originator);
46       
47        if (getGame() && once_ == false && getHealth() <= 0)
48        {
49            getGame()->addCredit(1);
50            once_ = true;
51        }
52    }
53}
Note: See TracBrowser for help on using the repository browser.