Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationFS15/src/modules/towerdefense/TowerDefenseEnemy.cc @ 10487

Last change on this file since 10487 was 10452, checked in by maxima, 10 years ago

Towerdefense merged to Presentation

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
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    */
25    TowerDefenseEnemy::TowerDefenseEnemy(Context* context) : SpaceShip(context)
26    {
27        RegisterObject(TowerDefenseEnemy);
28
29        this->setCollisionType(WorldEntity::Dynamic);
30        //needed to keep track of the PlayerStats coded in TowerDefense.h
31        this->td = orxonox_cast<TowerDefense*>(this->getGametype().get());
32        once_=false;
33
34    }
35    //add credit if enemy is destroyed
36    TowerDefenseEnemy::~TowerDefenseEnemy(){
37
38        if (this->isInitialized())
39        {
40                getGame()->addCredit(1);
41        }
42    }
43
44    void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord)
45    {
46        this->Waypointsvector_.push_back(coord);
47    }
48
49
50    void TowerDefenseEnemy::tick(float dt)
51    {
52        SUPER(TowerDefenseEnemy, tick, dt);
53    }
54
55    WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
56    {
57        if (game == NULL)
58        {
59            for (ObjectList<TowerDefense>::iterator it = ObjectList<TowerDefense>::begin(); it != ObjectList<TowerDefense>::end(); ++it)
60                game = *it;
61        }
62        return game;
63    }
64
65    void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
66    {
67        Pawn::damage(damage, healthdamage, shielddamage, originator);
68        if (getGame() && once_ == false && getHealth() <= 0)
69        {
70                orxout() << "damagefunctionIF" << endl;
71            getGame()->addCredit(1);
72            once_ = true;
73        }
74        orxout() << "damagefunction" << endl;
75
76    }
77
78/*
79    void TowerDefenseEnemy::popWaypoint()
80    {
81        if(Waypointsvector_.size()>0)
82            Waypointsvector_.pop_back();
83    }
84
85    TDCoordinate TowerDefenseEnemy::peekWaypoint()
86    {
87        if(Waypointsvector_.size()<=0){
88            TDCoordinate* coord = TDCoordinate(-1,-1);
89            return coord;
90        }else{
91            return Waypointsvector_.at(Waypointsvector_.size()-1);
92
93        }
94
95
96    }
97*/
98
99}
Note: See TracBrowser for help on using the repository browser.