Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationHS14merge/src/modules/towerdefense/TowerDefenseEnemy.cc @ 10256

Last change on this file since 10256 was 10256, checked in by landauf, 10 years ago

found some hidden changes in a merge commit in presentationHS14 and applied it to this branch.
cleanup in Mini4DgamePrereqs.h

  • Property svn:eol-style set to native
File size: 2.1 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        //this->td->addCredit(1);
38    }
39
40    void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord)
41    {
42        this->Waypointsvector_.push_back(coord);
43    }
44
45
46    void TowerDefenseEnemy::tick(float dt)
47    {
48        SUPER(TowerDefenseEnemy, tick, dt);
49    }
50
51    WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
52    {
53        if (game == NULL)
54        {
55            for (ObjectList<TowerDefense>::iterator it = ObjectList<TowerDefense>::begin(); it != ObjectList<TowerDefense>::end(); ++it)
56                game = *it;
57        }
58        return game;
59    }
60
61    void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
62    {
63        Pawn::damage(damage, healthdamage, shielddamage, originator);
64        if (getGame() && once_ == false && getHealth() <= 0)
65        {
66            getGame()->addCredit(1);
67            once_ = true;
68        }
69    }
70/*
71    void TowerDefenseEnemy::popWaypoint()
72    {
73        if(Waypointsvector_.size()>0)
74            Waypointsvector_.pop_back();
75    }
76
77    TDCoordinate TowerDefenseEnemy::peekWaypoint()
78    {
79        if(Waypointsvector_.size()<=0){
80            TDCoordinate* coord = TDCoordinate(-1,-1);
81            return coord;
82        }else{
83            return Waypointsvector_.at(Waypointsvector_.size()-1);
84
85        }
86
87
88    }
89*/
90
91}
Note: See TracBrowser for help on using the repository browser.