Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationFS15merge/src/modules/towerdefense/TowerDefenseEnemy.cc @ 10615

Last change on this file since 10615 was 10615, checked in by landauf, 9 years ago

merged branch towerdefenseFS15

  • Property svn:eol-style set to native
File size: 2.2 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(){
[10615]37
38        if (this->isInitialized())
39        {
40                getGame()->addCredit(1);
41        }
[10172]42    }
[10109]43
[10123]44    void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord)
[10109]45    {
[10246]46        this->Waypointsvector_.push_back(coord);
[10109]47    }
[10132]48
49
50    void TowerDefenseEnemy::tick(float dt)
51    {
52        SUPER(TowerDefenseEnemy, tick, dt);
53    }
54
[10256]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        {
[10615]70                orxout() << "damagefunctionIF" << endl;
[10256]71            getGame()->addCredit(1);
72            once_ = true;
73        }
[10615]74        orxout() << "damagefunction" << endl;
75
[10256]76    }
[10615]77
[10123]78/*
[10109]79    void TowerDefenseEnemy::popWaypoint()
80    {
[10246]81        if(Waypointsvector_.size()>0)
82            Waypointsvector_.pop_back();
[10109]83    }
84
85    TDCoordinate TowerDefenseEnemy::peekWaypoint()
86    {
[10246]87        if(Waypointsvector_.size()<=0){
88            TDCoordinate* coord = TDCoordinate(-1,-1);
89            return coord;
90        }else{
91            return Waypointsvector_.at(Waypointsvector_.size()-1);
[10109]92
[10246]93        }
[10109]94
95
96    }
[10123]97*/
[10126]98
[10109]99}
Note: See TracBrowser for help on using the repository browser.