Index: code/trunk/src/modules/towerdefense/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/towerdefense/CMakeLists.txt	(revision 9958)
+++ code/trunk/src/modules/towerdefense/CMakeLists.txt	(revision 10258)
@@ -1,8 +1,11 @@
 SET_SOURCE_FILES(TOWERDEFENSE_SRC_FILES
   TowerDefense.cc
-  Tower.cc
+  TowerDefenseTower.cc
+  TowerTurret.cc
   TowerDefenseCenterpoint.cc
   TowerDefenseHUDController.cc
   TowerDefensePlayerStats.cc
+  TDCoordinate.cc
+  TowerDefenseEnemy.cc
 
 )
Index: code/trunk/src/modules/towerdefense/TDCoordinate.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TDCoordinate.cc	(revision 10258)
+++ code/trunk/src/modules/towerdefense/TDCoordinate.cc	(revision 10258)
@@ -0,0 +1,42 @@
+#include "TDCoordinate.h"
+
+#include "towerdefense/TowerDefensePrereqs.h"
+
+
+
+
+namespace orxonox
+{
+    //RegisterClass(TDCoordinate);
+
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
+    TDCoordinate::TDCoordinate()
+    {
+        //RegisterObject(TDCoordinate);
+        x=0;
+        y=0;
+
+    }
+
+    TDCoordinate::TDCoordinate(int x, int y)
+    {
+        this->x=x;
+        this->y=y;
+    }
+
+
+    Vector3 TDCoordinate::get3dcoordinate()
+    {
+        float tileScale = 100;
+
+        Vector3 *coord = new Vector3();
+        coord->x= (x-8) * tileScale;
+        coord->y= (y-8) * tileScale;
+        coord->z=100;
+
+        return *coord;
+    }
+}
Index: code/trunk/src/modules/towerdefense/TDCoordinate.h
===================================================================
--- code/trunk/src/modules/towerdefense/TDCoordinate.h	(revision 10258)
+++ code/trunk/src/modules/towerdefense/TDCoordinate.h	(revision 10258)
@@ -0,0 +1,32 @@
+#ifndef _TDCoordinate_H__
+#define _TDCoordinate_H__
+
+#include "core/CoreIncludes.h"
+#include "TDCoordinate.h"
+//#include "towerdefense/TowerDefense.h"
+#include "gametypes/Deathmatch.h"
+#include "towerdefense/TowerDefensePrereqs.h"
+#include "worldentities/pawns/SpaceShip.h"
+namespace orxonox
+{
+
+//Class to save the Coordinates in a class instead of struct
+//Convert 2d coordinates to 3d in order to set waypoints
+    class _TowerDefenseExport TDCoordinate : public OrxonoxClass
+    {
+        public:
+            int x;
+            int y;
+
+            TDCoordinate();
+
+            Vector3 get3dcoordinate();
+
+            virtual ~TDCoordinate() {};
+
+            TDCoordinate(int x, int y);
+    };
+
+}
+
+#endif /* _TDCoordinate_H__ */
Index: code/trunk/src/modules/towerdefense/TDEnemy.h
===================================================================
--- code/trunk/src/modules/towerdefense/TDEnemy.h	(revision 9958)
+++ code/trunk/src/modules/towerdefense/TDEnemy.h	(revision 10258)
@@ -5,5 +5,5 @@
  *      Author: weigeltm
  */
-
+/*
 #ifndef TDENEMY_H_
 #define TDENEMY_H_
@@ -24,3 +24,3 @@
 
 
-#endif /* TDENEMY_H_ */
+#endif  TDENEMY_H_ */
Index: code/trunk/src/modules/towerdefense/Tower.cc
===================================================================
--- code/trunk/src/modules/towerdefense/Tower.cc	(revision 9958)
+++ code/trunk/src/modules/towerdefense/Tower.cc	(revision 10258)
@@ -40,5 +40,5 @@
     {
         static int ori;
-        orxout() << "orientation " << ++ori << endl;
+        //orxout() << "orientation " << ++ori << endl;
     }
 
@@ -46,5 +46,5 @@
     {
         static int yaw;
-        orxout() << "rotateYaw " << ++yaw << endl;
+        //orxout() << "rotateYaw " << ++yaw << endl;
     }
 
@@ -52,5 +52,5 @@
     {
         static int pitch;
-        orxout() << "rotatePitch " << ++pitch << endl;
+        //orxout() << "rotatePitch " << ++pitch << endl;
     }
 
@@ -58,5 +58,5 @@
     {
         static int roll;
-        orxout() << "rotateRoll" << ++roll << endl;
+        //orxout() << "rotateRoll" << ++roll << endl;
     }
 
Index: code/trunk/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefense.cc	(revision 9958)
+++ code/trunk/src/modules/towerdefense/TowerDefense.cc	(revision 10258)
@@ -20,5 +20,5 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
- *   Author:
+ *  Author:
  *
  *   Co-authors:
@@ -73,20 +73,17 @@
  *
  */
-
 #include "TowerDefense.h"
-#include "Tower.h"
+#include "TowerDefenseTower.h"
 #include "TowerDefenseCenterpoint.h"
-
+//#include "TDCoordinate.h"
+#include "TowerTurret.h"
 #include "worldentities/SpawnPoint.h"
 #include "worldentities/pawns/Pawn.h"
 #include "worldentities/pawns/SpaceShip.h"
 #include "controllers/WaypointController.h"
-
 #include "graphics/Model.h"
 #include "infos/PlayerInfo.h"
-
 #include "chat/ChatManager.h"
 #include "core/CoreIncludes.h"
-
 /* Part of a temporary hack to allow the player to add towers */
 #include "core/command/ConsoleCommand.h"
@@ -99,11 +96,18 @@
     {
         RegisterObject(TowerDefense);
+/*
+        for (int i=0; i < 16 ; i++){
+            for (int j = 0; j< 16 ; j++){
+                towermatrix[i][j] = NULL;
+            }
+        }*/
 
         this->setHUDTemplate("TowerDefenseHUD");
 
-        this->stats_ = new TowerDefensePlayerStats();
-
-        /* Temporary hack to allow the player to add towers */
+        //this->stats_ = new TowerDefensePlayerStats();
+
+        /* Temporary hack to allow the player to add towers and upgrade them */
         this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
+        this->dedicatedUpgradeTower_ = createConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) );
     }
 
@@ -127,47 +131,134 @@
     void TowerDefense::start()
     {
+
         Deathmatch::start();
 
-        const int kInitialTowerCount = 3;
-        Coordinate initialTowerCoordinates[kInitialTowerCount] = {{3,2}, {8,5}, {12,10}};
-
-        for (int i = 0; i < kInitialTowerCount; i++)
-        {
-            Coordinate coordinate = initialTowerCoordinates[i];
-            addTower(coordinate.x, coordinate.y);
-        }
-
-        ChatManager::message("Use the console command addTower x y to add towers");
-
-        //TODO: let the player control his controllable entity && TODO: create a new ControllableEntity for the player
-    }
+// Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path
+        for (int i=0; i < 16 ; i++){
+            for (int j = 0; j< 16 ; j++){
+                towermatrix[i][j] = false;
+            }
+        }
+
+        for (int k=0; k<3; k++)
+            towermatrix[1][k]=true;
+        for (int l=1; l<11; l++)
+            towermatrix[l][3]=true;
+        for (int m=3; m<12; m++)
+            towermatrix[10][m]=true;
+        for (int n=10; n<14; n++)
+            towermatrix[n][11]=true;
+        for (int o=13; o<16; o++)
+            towermatrix[13][o]=true;
+
+        //set initial credits, lifes and WaveNumber
+        this->setCredit(200);
+        this->setLifes(50);
+        this->setWaveNumber(0);
+        time=0.0;
+
+        //adds initial towers
+        for (int i=0; i <7; i++){
+            addTower(i+3,4);
+        }/*
+        for (int j=0; j < 7; j++){
+            addTower(9,j+5);
+        }*/
+    }
+
+    // Generates a TowerDefenseEnemy. Uses Template "enemytowerdefense". Sets position at first waypoint of path.
+    void TowerDefense::addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr){
+
+
+        TowerDefenseEnemy* en1 = new TowerDefenseEnemy(this->center_->getContext());
+        
+        switch(templatenr)
+        {
+        case 1 :
+            en1->addTemplate("enemytowerdefense1");
+            en1->setScale(3);
+            en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
+            break;
+
+        case 2 :
+            en1->addTemplate("enemytowerdefense2");
+            en1->setScale(2);
+            en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
+            //  en1->setShieldHealth(en1->getShield() = this->getWaveNumber()*2))
+            break;
+
+        case 3 :
+            en1->addTemplate("enemytowerdefense3");
+            en1->setScale(1);
+            en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
+            break;
+        }
+
+        en1->getController();
+        en1->setPosition(path.at(0)->get3dcoordinate());
+        TowerDefenseEnemyvector.push_back(en1);
+
+        for(unsigned int i = 0; i < path.size(); ++i)
+        {
+            en1->addWaypoint((path.at(i)));
+        }
+    }
+
 
     void TowerDefense::end()
     {
+
         Deathmatch::end();
-
-        ChatManager::message("Match is over");
-    }
-
+        ChatManager::message("Match is over! Gameover!");
+
+    }
+
+    //not working yet
+    void TowerDefense::upgradeTower(int x,int y)
+    {/*
+        const int upgradeCost = 20;
+
+        if (!this->hasEnoughCreditForTower(upgradeCost))
+        {
+            orxout() << "not enough credit: " << (this->getCredit()) << " available, " << upgradeCost << " needed.";
+            return;
+        }
+
+        if (towermatrix [x][y] == NULL)
+        {
+            orxout() << "no tower on this position" << endl;
+            return;
+        }
+
+        else
+        {
+            (towermatrix [x][y])->upgradeTower();
+        }*/
+    }
+
+    /*adds Tower at Position (x,y) and reduces credit and adds the point to the towermatrix. template ("towerturret")
+    so towers have ability if the turrets
+
+    */
     void TowerDefense::addTower(int x, int y)
     {
-        const TowerCost towerCost = TDDefaultTowerCost;
+        const int towerCost = 20;
 
         if (!this->hasEnoughCreditForTower(towerCost))
         {
-            orxout() << "not enough credit: " << (this->stats_->getCredit()) << " available, " << TDDefaultTowerCost << " needed.";
+            orxout() << "not enough credit: " << (this->getCredit()) << " available, " << towerCost << " needed.";
             return;
         }
 
-        if (this->towerExists(x,y))
-        {
-            orxout() << "tower exists!!" << endl;
+        if (towermatrix [x][y]==true)
+        {
+            orxout() << "not possible to put tower here!!" << endl;
             return;
         }
 
-        /*
+/*
         unsigned int width = this->center_->getWidth();
         unsigned int height = this->center_->getHeight();
-        */
+*/
 
         int tileScale = (int) this->center_->getTileScale();
@@ -182,40 +273,87 @@
         orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
 
-        // Add tower to coordinatesStack
-        Coordinate newTowerCoordinates = {x, y};
-        addedTowersCoordinates_.push_back(newTowerCoordinates);
-
-        // Reduce credit
-        this->stats_->buyTower(towerCost);
-
-        // Create tower
-        Tower* newTower = new Tower(this->center_->getContext());
-        newTower->addTemplate(this->center_->getTowerTemplate());
-
-        newTower->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75);
-        newTower->setGame(this);
-    }
-
-    bool TowerDefense::hasEnoughCreditForTower(TowerCost towerCost)
-    {
-        return ((this->stats_->getCredit()) >= towerCost);
-    }
-
-    bool TowerDefense::towerExists(int x, int y)
-    {
-        for(std::vector<Coordinate>::iterator it = addedTowersCoordinates_.begin(); it != addedTowersCoordinates_.end(); ++it)
-        {
-            Coordinate currentCoordinates = (Coordinate) (*it);
-            if (currentCoordinates.x == x && currentCoordinates.y == y)
-                return true;
-        }
-
-        return false;
-    }
-
-
+       //Reduce credit
+        this->buyTower(towerCost);
+        towermatrix [x][y]=true;
+
+        //Creates tower
+        TowerDefenseTower* towernew = new TowerDefenseTower(this->center_->getContext());
+        towernew->addTemplate("towerturret");
+        towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75);
+        towernew->setGame(this);
+    }
+
+    bool TowerDefense::hasEnoughCreditForTower(int towerCost)
+    {
+        return ((this->getCredit()) >= towerCost);
+    }
+
+
+    bool TowerDefense::hasEnoughCreditForUpgrade()
+    {
+        return true;
+    }
+
+ 
     void TowerDefense::tick(float dt)
     {
         SUPER(TowerDefense, tick, dt);
+        time +=dt;
+
+        TDCoordinate* coord1 = new TDCoordinate(1,1);
+        std::vector<TDCoordinate*> path;
+        path.push_back(coord1);
+        if(time>1 && TowerDefenseEnemyvector.size() < 30)
+        {
+            //adds different types of enemys depending on the WaveNumber
+            addTowerDefenseEnemy(path, this->getWaveNumber() % 3 +1 );
+            time = time-1;
+        }
+
+        Vector3* endpoint = new Vector3(500, 700, 150);
+        //if ships are at the end they get destroyed
+        for(unsigned int i =0; i < TowerDefenseEnemyvector.size(); ++i)
+        {
+            if(TowerDefenseEnemyvector.at(i) != NULL && TowerDefenseEnemyvector.at(i)->isAlive())
+            {
+                //destroys enemys at the end of teh path and reduces the life by 1. no credits gifted
+
+                Vector3 ship = TowerDefenseEnemyvector.at(i)->getRVWorldPosition();
+                float distance = ship.distance(*endpoint);
+
+                if(distance <50){
+                    TowerDefenseEnemyvector.at(i)->destroy();
+                    this->reduceLifes(1);
+                    this->buyTower(1);
+                    if (this->getLifes()==0)
+                    {
+                        this->end();
+                    }
+                }
+            }
+        }
+        //goes thorugh vector to see if an enemy is still alive. if not next wave is launched
+        int count= 0;
+        for(unsigned int i =0; i < TowerDefenseEnemyvector.size(); ++i)
+        {
+            if(TowerDefenseEnemyvector.at(i)!= NULL)
+            {
+                ++count;
+            }
+        }
+
+        if(count== 0)
+        {
+            time2 +=dt;
+            if(time2 > 10)
+            {
+                TowerDefenseEnemyvector.clear();
+                this->nextwave();
+                time=0;
+                time2=0;
+            }
+        }
+
+
     }
 
Index: code/trunk/src/modules/towerdefense/TowerDefense.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefense.h	(revision 9958)
+++ code/trunk/src/modules/towerdefense/TowerDefense.h	(revision 10258)
@@ -37,9 +37,10 @@
 #ifndef _TowerDefense_H__
 #define _TowerDefense_H__
-
+#include "TDCoordinate.h"
 #include "towerdefense/TowerDefensePrereqs.h"
 #include "gametypes/Deathmatch.h"
-
- #include "TowerDefensePlayerStats.h"
+#include "TowerDefenseEnemy.h"
+#include "util/Output.h"
+#include "core/object/WeakPtr.h"
 
 namespace orxonox
@@ -51,4 +52,7 @@
         virtual ~TowerDefense();
 
+        std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > TowerDefenseEnemyvector;
+        bool towermatrix[16][16];
+        void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr);
         virtual void start(); //<! The function is called when the gametype starts
         virtual void end();
@@ -56,4 +60,15 @@
         //virtual void playerEntered(PlayerInfo* player);
         //virtual bool playerLeft(PlayerInfo* player);
+        //Player Stats (set,get, reduce)
+        int getCredit(){ return this->credit_; }
+        int getLifes(){ return this->lifes_; }
+        int getWaveNumber(){ return this->waves_; }
+        void setCredit(int credit){ credit_ = credit; }
+        void setLifes(int lifes){ lifes_ = lifes; }
+        void setWaveNumber(int wavenumber){ waves_=wavenumber; }
+        void buyTower(int cost){ credit_ -= cost;}
+        void addCredit(int credit) { credit_+=credit; }
+        void nextwave(){ waves_++;}
+        int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; }
 
         //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
@@ -69,6 +84,8 @@
         void addTower(int x, int y);
 
+        void upgradeTower(int x, int y);
         /* Part of a temporary hack to allow the player to add towers */
         ConsoleCommand* dedicatedAddTower_;
+        ConsoleCommand* dedicatedUpgradeTower_;
 
         //TODO: void spawnNewWave()
@@ -79,18 +96,17 @@
     private:
         TowerDefenseCenterpoint *center_;
+        float time;
+        float time2;
+        int credit_;
+        int waves_;
+        int lifes_;
 
         /* handles stats */
-        TowerDefensePlayerStats *stats_;
-        bool hasEnoughCreditForTower(TowerCost towerCost);
+        bool hasEnoughCreditForTower(int towerCost);
+        bool hasEnoughCreditForUpgrade();
 
-        bool towerExists(int x, int y);
 
-        typedef struct {
-            int x;
-            int y;
-        } Coordinate;
 
-        std::vector<Coordinate> addedTowersCoordinates_;
-        std::vector<Tower*> towers_;
+        std::vector<TowerTurret*> towers_;
     };
 }
Index: code/trunk/src/modules/towerdefense/TowerDefenseController.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseController.cc	(revision 9958)
+++ code/trunk/src/modules/towerdefense/TowerDefenseController.cc	(revision 10258)
@@ -33,4 +33,5 @@
 #include "core/XMLPort.h"
 #include "worldentities/pawns/Pawn.h"
+#include "controllers/WaypointController.h"
 
 namespace orxonox
@@ -53,4 +54,5 @@
         XMLPortParam(TowerDefenseController, "alertnessradius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues(500.0f);
     }
+
 
     void TowerDefenseController::tick(float dt)
Index: code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc	(revision 10258)
+++ code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc	(revision 10258)
@@ -0,0 +1,91 @@
+//
+//  TowerDefenseEnemy.cc
+//  Orxonox
+//
+//  Created by Jonas Erb on 22.10.14.
+
+/**
+@brief
+See TowerDefenseReadme.txt for Information.
+
+@ingroup TowerDefense
+*/
+#include "TowerDefenseEnemy.h"
+#include "core/CoreIncludes.h"
+//#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    RegisterClass(TowerDefenseEnemy);
+
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
+    TowerDefenseEnemy::TowerDefenseEnemy(Context* context) : SpaceShip(context)
+    {
+        RegisterObject(TowerDefenseEnemy);
+
+        this->setCollisionType(WorldEntity::Dynamic);
+        //needed to keep track of the PlayerStats coded in TowerDefense.h
+        this->td = orxonox_cast<TowerDefense*>(this->getGametype().get());
+        once_=false;
+
+    }
+    //add credit if enemy is destroyed
+    TowerDefenseEnemy::~TowerDefenseEnemy(){
+        //this->td->addCredit(1);
+    }
+
+    void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord)
+    {
+        this->Waypointsvector_.push_back(coord);
+    }
+
+
+    void TowerDefenseEnemy::tick(float dt)
+    {
+        SUPER(TowerDefenseEnemy, tick, dt);
+    }
+
+    WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
+    {
+        if (game == NULL)
+        {
+            for (ObjectList<TowerDefense>::iterator it = ObjectList<TowerDefense>::begin(); it != ObjectList<TowerDefense>::end(); ++it)
+                game = *it;
+        }
+        return game;
+    }
+
+    void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
+    {
+        Pawn::damage(damage, healthdamage, shielddamage, originator);
+        if (getGame() && once_ == false && getHealth() <= 0)
+        {
+            getGame()->addCredit(1);
+            once_ = true;
+        }
+    }
+/*
+    void TowerDefenseEnemy::popWaypoint()
+    {
+        if(Waypointsvector_.size()>0)
+            Waypointsvector_.pop_back();
+    }
+
+    TDCoordinate TowerDefenseEnemy::peekWaypoint()
+    {
+        if(Waypointsvector_.size()<=0){
+            TDCoordinate* coord = TDCoordinate(-1,-1);
+            return coord;
+        }else{
+            return Waypointsvector_.at(Waypointsvector_.size()-1);
+
+        }
+
+
+    }
+*/
+
+}
Index: code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h	(revision 10258)
+++ code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h	(revision 10258)
@@ -0,0 +1,61 @@
+//
+//  TowerDefenseEnemy.h
+//  Orxonox
+//
+//  Created by Jonas Erb on 22.10.14.
+
+/**
+@brief
+See TowerDefenseReadme.txt for Information.
+
+@ingroup TowerDefense
+*/
+
+
+
+#ifndef Orxonox_Tower_h
+#define Orxonox_Tower_h
+
+#include "TDCoordinate.h"
+#include "gametypes/Deathmatch.h"
+#include "towerdefense/TowerDefensePrereqs.h"
+#include "worldentities/pawns/SpaceShip.h"
+#include "util/Output.h"
+#include "controllers/ArtificialController.h"
+#include "TowerDefense.h"
+
+namespace orxonox
+{
+/* Class to give the TowerDefenseEnemy spaceships waypoints and
+ *
+ */
+    class _TowerDefenseExport TowerDefenseEnemy : public SpaceShip
+    {
+    public:
+        TowerDefenseEnemy(Context* context);
+        virtual ~TowerDefenseEnemy();
+
+        //health gibt es unter: health_
+
+        virtual void tick(float dt);
+        void addWaypoint(TDCoordinate* coord);
+        void popWaypoint();
+        TDCoordinate peekWaypoint();
+
+        virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator);
+
+
+    private:
+        WeakPtr<TowerDefense> getGame();
+        WeakPtr<TowerDefense> game;
+        TowerDefense* td;
+        bool once_;
+        std::vector<TDCoordinate*> Waypointsvector_;
+
+    };
+
+
+
+}
+
+#endif /* _TowerDefense_H__ */
Index: code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc	(revision 9958)
+++ code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc	(revision 10258)
@@ -32,5 +32,4 @@
 #include "util/Convert.h"
 
-
 namespace orxonox
 {
@@ -40,4 +39,5 @@
     {
         RegisterObject(TowerDefenseHUDController);
+        this->td = 0;
     }
 
@@ -50,4 +50,16 @@
     {
         SUPER(TowerDefenseHUDController, tick, dt);
+        const std::string& lifes = multi_cast<std::string>(this->td->getLifes());
+        const std::string& credits = multi_cast<std::string>(this->td->getCredit());
+        const std::string& wave = multi_cast<std::string>(this->td->getWaveNumber());
+
+        if(showlives == true)
+          this->setCaption(multi_cast<std::string>(lifes));
+        else if(showcredits == true)
+          this->setCaption(multi_cast<std::string>(credits));
+        else if(showwaves == true)
+          this->setCaption(multi_cast<std::string>(wave));
+
+
     }
 
@@ -55,16 +67,24 @@
     {
         SUPER(TowerDefenseHUDController, XMLPort, xmlelement, mode);
+
+        XMLPortParam(TowerDefenseHUDController, "showlives", setShowlives, getShowlives, xmlelement, mode);
+        XMLPortParam(TowerDefenseHUDController, "showcredits", setShowcredits, getShowcredits, xmlelement, mode);
+        XMLPortParam(TowerDefenseHUDController, "showwaves", setShowwaves, getShowwaves, xmlelement, mode);
+
     }
 
     void TowerDefenseHUDController::changedOwner()
-    {
-        SUPER(TowerDefenseHUDController, changedOwner);
-        /*
-        if (this->getOwner() != NULL && this->getOwner()->getGametype())
-            this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get());
-        else
-            this->owner_ = 0;
-        */
-    }
+        {
+            SUPER(TowerDefenseHUDController, changedOwner);
 
-}
+            if (this->getOwner() && this->getOwner()->getGametype())
+                    {
+                        this->td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype().get());
+                    }
+                    else
+                    {
+                        this->td = 0;
+                    }
+                }
+        }
+
Index: code/trunk/src/modules/towerdefense/TowerDefenseHUDController.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseHUDController.h	(revision 9958)
+++ code/trunk/src/modules/towerdefense/TowerDefenseHUDController.h	(revision 10258)
@@ -39,8 +39,8 @@
 
 #include "towerdefense/TowerDefensePrereqs.h"
-
+#include "TowerDefensePlayerStats.h"
 #include "tools/interfaces/Tickable.h"
 #include "overlays/OverlayText.h"
-
+#include "TowerDefense.h"
 
 namespace orxonox
@@ -52,7 +52,28 @@
         virtual ~TowerDefenseHUDController();
 
+
         virtual void tick(float dt);
         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
         virtual void changedOwner();
+        void setShowlives(bool temp)
+            { this->showlives = temp; }
+        unsigned int getShowlives(void) const
+            { return this->showlives; }
+
+        void setShowcredits(bool temp)
+            { this->showcredits = temp; }
+        unsigned int getShowcredits(void) const
+            { return this->showcredits; }
+
+        void setShowwaves(bool temp)
+            { this->showwaves = temp; }
+        unsigned int getShowwaves(void) const
+            { return this->showwaves; }
+
+    private:
+        TowerDefense* td;
+        bool showcredits;
+        bool showlives;
+        bool showwaves;
     };
 }
Index: code/trunk/src/modules/towerdefense/TowerDefensePlayerStats.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefensePlayerStats.cc	(revision 9958)
+++ code/trunk/src/modules/towerdefense/TowerDefensePlayerStats.cc	(revision 10258)
@@ -25,5 +25,5 @@
  *      ...
  */
-
+/*
 #include "TowerDefensePlayerStats.h"
 
@@ -31,14 +31,16 @@
 {
     const int kDefaultCredit = 200;
-
+    const int kDefaultLifes=20;
     TowerDefensePlayerStats::TowerDefensePlayerStats()
     {
         this->credit_ = kDefaultCredit;
         this->waveNumber_ = 0;
+        this->lifes_=kDefaultLifes;
     }
-    /*
+
     TowerDefensePlayerStats::~TowerDefensePlayerStats()
     {
     }
-    */
+
 }
+*/
Index: code/trunk/src/modules/towerdefense/TowerDefensePlayerStats.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefensePlayerStats.h	(revision 9958)
+++ code/trunk/src/modules/towerdefense/TowerDefensePlayerStats.h	(revision 10258)
@@ -27,10 +27,10 @@
  */
 
- /**
+ /*
     @brief
         This manages the stats of the player. It is used by 'TowerDefense', the gametype
 
     @ingroup TowerDefense
- */
+
 
 
@@ -44,5 +44,6 @@
     typedef enum _TowerCosts {
         // Set to 0 for debug...
-        TDDefaultTowerCost = 0
+        TDDefaultTowerCost = 20 ,
+        TDDefaultUpgradeCost = 15
     } TowerCost;
 
@@ -67,10 +68,23 @@
             { waveNumber_++; }
 
+        inline int getLifes()
+            {return lifes_; }
+
+        inline void reduceLifes(int NumberofLifes)
+        {lifes_-=NumberofLifes; }
+
+        inline void upgradeTower(int upgradecost)
+            { credit_ -= upgradecost;}
+
+
+
     private:
         int credit_;
         int waveNumber_;
+        int upgradecost;
+        int lifes_;
         //int baseHealth_;
     };
 }
 
-#endif /* _TowerDefensePlayerStats_H__ */
+#endif  _TowerDefensePlayerStats_H__ */
Index: code/trunk/src/modules/towerdefense/TowerDefensePrereqs.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefensePrereqs.h	(revision 9958)
+++ code/trunk/src/modules/towerdefense/TowerDefensePrereqs.h	(revision 10258)
@@ -66,8 +66,14 @@
 {
     class TowerDefense;
-    class Tower;
+
+    class TowerDefenseTower;
+
     class TowerDefenseCenterpoint;
     class TowerDefenseHUDController;
     class TowerDefensePlayerStats;
+    class TowerDefenseEnemy;
+    class TDCoordinate;
+    class TowerTurret;
+    class TowerDefenseTower;
 }
 
Index: code/trunk/src/modules/towerdefense/TowerDefenseTower.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseTower.cc	(revision 10258)
+++ code/trunk/src/modules/towerdefense/TowerDefenseTower.cc	(revision 10258)
@@ -0,0 +1,129 @@
+//
+//  TowerDefenseTower.cc
+//  Orxonox
+//
+//  Created by Fabian Mentzer on 29.04.12.
+//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+/* Not implemented fully */
+
+#include "TowerDefenseTower.h"
+
+#include "core/CoreIncludes.h"
+//#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    RegisterClass(TowerDefenseTower);
+
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
+    TowerDefenseTower::TowerDefenseTower(Context* context) : Pawn(context)
+    {
+        RegisterObject(TowerDefenseTower);
+
+        this->setCollisionType(WorldEntity::Dynamic);
+        upgrade = 0;
+
+        //this->removeAllEngines();
+
+        /*
+        this->size_ = 10.0f;
+        this->delay_ = false;
+        this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
+        */
+    }
+
+    void TowerDefenseTower::setOrientation(const Quaternion& orientation)
+    {
+    }
+
+    void TowerDefenseTower::rotateYaw(const Vector2& value)
+    {
+    }
+
+    void TowerDefenseTower::rotatePitch(const Vector2& value)
+    {
+    }
+
+    void TowerDefenseTower::rotateRoll(const Vector2& value)
+    {
+    }
+
+    bool TowerDefenseTower::upgradeTower()
+    {
+        if(upgrade < 3)
+        {
+            upgrade++;
+            float reloadrate = getReloadRate();
+            float reloadwaittime = getReloadWaitTime();
+            this->setDamageMultiplier(5000);
+
+            reloadrate = 0.5f*reloadrate;
+            reloadwaittime = 0.5f*reloadwaittime;
+            setReloadRate(reloadrate);
+            setReloadWaitTime(reloadwaittime);
+            this->addTemplate("towerturret1");
+        }
+        else
+        {
+            orxout() << "Tower fully upgraded" << endl;
+            return false;
+        }
+        return true;
+    }
+
+    // This function is called whenever a player presses the up or the down key.
+    // You have to implement what happens when the up or the down key is pressed.
+    // value.x < 0 means: down key is pressed.
+    // I suggest to create a new class which is a controllable entity I will refer to as "TowerDefenseTowerMover". This is the controllable entity that the
+    // player controls in order to move the TowerDefenseTower along the centerpoint and in order to place the TowerDefenseTower at the appropriate position.
+    //
+
+    // The TowerDefenseTower itsself is controlled by a WayPointPatroController at the instance you place it on the centerpoint.
+    //(don't forget to set the team_ parameter such that all TowerDefenseTower are in the same team)
+
+    //How to move a TowerDefenseTower: simply attach the TowerDefenseTower to the TowerDefenseTowerMover
+    //How to place a TowerDefenseTower: detach the TowerDefenseTower from the TowerDefenseTowerMover
+
+    /**
+    @brief
+        Overloaded the function to rotate the stone.
+    @param value
+        A vector whose first component is the angle by which to rotate.
+    */
+    /*
+    void TowerDefenseTower::moveFrontBack(const Vector2& value)
+    {
+        //orxout() << "frontBack.x: " << value.x << endl;
+    }
+    */
+
+    /**
+    @brief
+        Overloaded the function to steer the stone right and left
+    @param value
+        A vector whose first component is the direction in which we want to steer the stone.
+    */
+    /*
+    void TowerDefenseTower::moveRightLeft(const Vector2& value)
+    {
+        //orxout() << "rightLeft.x: " << value.x << endl;
+
+        if(!this->delay_)
+        {
+            const Vector3& position = this->getPosition();
+            Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
+            if(!this->tetris_->isValidMove(this, newPos))
+                return;
+
+            this->setPosition(newPos);
+            this->delay_ = true;
+            this->delayTimer_.startTimer();
+        }
+    }
+    */
+}
Index: code/trunk/src/modules/towerdefense/TowerDefenseTower.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseTower.h	(revision 10258)
+++ code/trunk/src/modules/towerdefense/TowerDefenseTower.h	(revision 10258)
@@ -0,0 +1,55 @@
+//
+//  TowerDefenseTower.h
+//  Orxonox
+//
+//  Created by Fabian Mentzer on 29.04.12.
+//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+/**
+@brief
+See TowerDefenseTowerDefenseReadme.txt for Information.
+
+@ingroup TowerDefenseTowerDefense
+*/
+
+
+#ifndef Orxonox_TowerDefenseTower_h
+#define Orxonox_TowerDefenseTower_h
+
+#include "towerdefense/TowerDefensePrereqs.h"
+#include "worldentities/pawns/SpaceShip.h"
+
+
+namespace orxonox
+{
+    class _TowerDefenseExport TowerDefenseTower : public Pawn
+    {
+    public:
+        TowerDefenseTower(Context* context);
+        virtual ~TowerDefenseTower() {};
+
+        // Maybe later override these to move TowerDefenseTowers with cursor keys
+        /*
+        virtual void moveFrontBack(const Vector2& value);
+        virtual void moveRightLeft(const Vector2& value);
+        */
+
+        // Overriding these to stop TowerDefenseTowers from spasing out
+        void setOrientation(const Quaternion& orientation);
+        virtual void rotateYaw(const Vector2& value);
+        virtual void rotatePitch(const Vector2& value);
+        virtual void rotateRoll(const Vector2& value);
+        virtual bool upgradeTower();
+
+
+        void setGame(TowerDefense* Towerdefense)
+        { assert(Towerdefense); game_ = Towerdefense; }
+    private:
+        TowerDefense* game_;
+        int upgrade;
+    };
+}
+
+
+#endif
Index: code/trunk/src/modules/towerdefense/TowerTurret.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerTurret.cc	(revision 10258)
+++ code/trunk/src/modules/towerdefense/TowerTurret.cc	(revision 10258)
@@ -0,0 +1,41 @@
+//
+//  Tower.cc
+//  Orxonox
+//
+//  Created by Fabian Mentzer on 29.04.12.
+//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+/* Not implemented fully */
+
+//#include "Tower.h"
+#include "TowerTurret.h"
+
+#include "core/CoreIncludes.h"
+//#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    RegisterClass(TowerTurret);
+
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
+    TowerTurret::TowerTurret(Context* context) : StaticEntity(context)
+    {
+        RegisterObject(TowerTurret);
+
+        this->setCollisionType(WorldEntity::Static);
+
+
+    }
+
+    void TowerTurret::setOrientation(const Quaternion& orientation)
+    {
+        static int ori;
+        orxout() << "orientation " << ++ori << endl;
+    }
+
+
+}
Index: code/trunk/src/modules/towerdefense/TowerTurret.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerTurret.h	(revision 10258)
+++ code/trunk/src/modules/towerdefense/TowerTurret.h	(revision 10258)
@@ -0,0 +1,53 @@
+//
+//  Tower.h
+//  Orxonox
+//
+//  Created by Fabian Mentzer on 29.04.12.
+//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+/**
+@brief
+See TowerDefenseReadme.txt for Information.
+
+@ingroup TowerDefense
+*/
+
+
+#ifndef Orxonox_Tower_h
+#define Orxonox_Tower_h
+
+#include "towerdefense/TowerDefensePrereqs.h"
+#include "worldentities/pawns/SpaceShip.h"
+#include "worldentities/StaticEntity.h"
+
+
+namespace orxonox
+{
+    class _TowerDefenseExport TowerTurret : public StaticEntity
+    {
+    public:
+        TowerTurret(Context* context);
+        virtual ~TowerTurret() {};
+
+        // Maybe later override these to move towers with cursor keys
+        /*
+        virtual void moveFrontBack(const Vector2& value);
+        virtual void moveRightLeft(const Vector2& value);
+        */
+
+        // Overriding these to stop towers from spasing out
+        void setOrientation(const Quaternion& orientation);
+        //virtual void rotateYaw(const Vector2& value);
+        //virtual void rotatePitch(const Vector2& value);
+        //virtual void rotateRoll(const Vector2& value);
+
+        void setGame(TowerDefense* towerdefense)
+        { assert(towerdefense); game_ = towerdefense; }
+    private:
+        TowerDefense* game_;
+    };
+}
+
+
+#endif
