Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged presentationHS14merge back to trunk

  • Property svn:eol-style set to native
File size: 2.1 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
[10159]31        this->td = orxonox_cast<TowerDefense*>(this->getGametype().get());
[10256]32        once_=false;
[10109]33
34    }
[10172]35    //add credit if enemy is destroyed
36    TowerDefenseEnemy::~TowerDefenseEnemy(){
[10256]37        //this->td->addCredit(1);
[10172]38    }
[10109]39
[10123]40    void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord)
[10109]41    {
[10246]42        this->Waypointsvector_.push_back(coord);
[10109]43    }
[10132]44
45
46    void TowerDefenseEnemy::tick(float dt)
47    {
48        SUPER(TowerDefenseEnemy, tick, dt);
49    }
50
[10256]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    }
[10123]70/*
[10109]71    void TowerDefenseEnemy::popWaypoint()
72    {
[10246]73        if(Waypointsvector_.size()>0)
74            Waypointsvector_.pop_back();
[10109]75    }
76
77    TDCoordinate TowerDefenseEnemy::peekWaypoint()
78    {
[10246]79        if(Waypointsvector_.size()<=0){
80            TDCoordinate* coord = TDCoordinate(-1,-1);
81            return coord;
82        }else{
83            return Waypointsvector_.at(Waypointsvector_.size()-1);
[10109]84
[10246]85        }
[10109]86
87
88    }
[10123]89*/
[10126]90
[10109]91}
Note: See TracBrowser for help on using the repository browser.