Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10863 was 10629, checked in by fvultier, 9 years ago

Merged towerdefenseFabien branch back to trunk. The towerdefense Minigame is now a plugin.

  • Property svn:eol-style set to native
File size: 1.6 KB
RevLine 
[10109]1//
2//  TowerDefenseEnemy.cc
3//  Orxonox
4//
5//  Created by Jonas Erb on 22.10.14.
6
7/**
8@brief
9See TowerDefenseReadme.txt for Information.
10
11@ingroup TowerDefense
12*/
13#include "TowerDefenseEnemy.h"
14#include "core/CoreIncludes.h"
15//#include "core/XMLPort.h"
16
17namespace orxonox
18{
19    RegisterClass(TowerDefenseEnemy);
20
21    /**
22    @brief
23        Constructor. Registers and initializes the object.
24    */
[10126]25    TowerDefenseEnemy::TowerDefenseEnemy(Context* context) : SpaceShip(context)
[10109]26    {
27        RegisterObject(TowerDefenseEnemy);
28
29        this->setCollisionType(WorldEntity::Dynamic);
[10172]30        //needed to keep track of the PlayerStats coded in TowerDefense.h
[10624]31        this->td = orxonox_cast<TowerDefense*>(this->getGametype());
[10629]32        once_ = false;
[10109]33    }
[10622]34
[10629]35    TowerDefenseEnemy::~TowerDefenseEnemy()
36    {
[10109]37
38    }
[10132]39
40    void TowerDefenseEnemy::tick(float dt)
[10629]41    {   
42        //orxout() << "TDE tick1" << endl;
[10132]43        SUPER(TowerDefenseEnemy, tick, dt);
[10629]44        //orxout() << "TDE tick2" << endl;
[10132]45    }
46
[10629]47    WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
[10256]48    {
49        if (game == NULL)
50        {
51            for (ObjectList<TowerDefense>::iterator it = ObjectList<TowerDefense>::begin(); it != ObjectList<TowerDefense>::end(); ++it)
52                game = *it;
53        }
54        return game;
55    }
56
[10629]57    void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
[10256]58    {
[10629]59        Pawn::damage(damage, healthdamage, shielddamage, originator);
60       
[10256]61        if (getGame() && once_ == false && getHealth() <= 0)
62        {
63            getGame()->addCredit(1);
64            once_ = true;
65        }
66    }
[10109]67}
Note: See TracBrowser for help on using the repository browser.