Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 12194 was 12190, checked in by merholzl, 6 years ago

TD merge

  • Property svn:eol-style set to native
File size: 1.3 KB
RevLine 
[10109]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    */
[10126]19    TowerDefenseEnemy::TowerDefenseEnemy(Context* context) : SpaceShip(context)
[10109]20    {
21        RegisterObject(TowerDefenseEnemy);
22
[11071]23        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
[10172]24        //needed to keep track of the PlayerStats coded in TowerDefense.h
[10624]25        this->td = orxonox_cast<TowerDefense*>(this->getGametype());
[10629]26        once_ = false;
[10109]27    }
[10622]28
[10629]29    TowerDefenseEnemy::~TowerDefenseEnemy()
30    {
[10109]31    }
[10132]32
[10629]33    WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
[10256]34    {
[11071]35        if (game == nullptr)
[10256]36        {
[11071]37            for (TowerDefense* towerDefense : ObjectList<TowerDefense>())
38                game = towerDefense;
[10256]39        }
40        return game;
41    }
42
[11071]43    void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
[10256]44    {
[10629]45        Pawn::damage(damage, healthdamage, shielddamage, originator);
46       
[10256]47        if (getGame() && once_ == false && getHealth() <= 0)
48        {
49            getGame()->addCredit(1);
50            once_ = true;
51        }
52    }
[10109]53}
Note: See TracBrowser for help on using the repository browser.