Index: code/branches/towerdefenseFabien/src/modules/towerdefense/CMakeLists.txt
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/CMakeLists.txt	(revision 10585)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/CMakeLists.txt	(revision 10586)
@@ -2,5 +2,4 @@
   TowerDefense.cc
   TowerDefenseTower.cc
-  TowerTurret.cc
   TowerDefenseCenterpoint.cc
   TowerDefenseHUDController.cc
@@ -8,5 +7,7 @@
   TDCoordinate.cc
   TowerDefenseEnemy.cc
-
+  TowerDefenseSelecter.cc
+  TowerDefenseField.cc
+  TDCoordinate.cc
 )
 
@@ -17,4 +18,5 @@
     orxonox
     overlays
+    objects
   SOURCE_FILES ${TOWERDEFENSE_SRC_FILES}
 )
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TDCoordinate.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TDCoordinate.cc	(revision 10585)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TDCoordinate.cc	(revision 10586)
@@ -8,22 +8,55 @@
 namespace orxonox
 {
-    //RegisterClass(TDCoordinate);
-
     /**
     @brief
-        Constructor. Registers and initializes the object.
+        Constructor. Sets the default coordinates: (0,0)
     */
     TDCoordinate::TDCoordinate()
     {
-        //RegisterObject(TDCoordinate);
-        x=0;
-        y=0;
-
+        Set(0,0);
     }
 
     TDCoordinate::TDCoordinate(int x, int y)
-    {
-        this->x=x;
-        this->y=y;
+    {        
+        Set(x,y);
+    }
+
+    void TDCoordinate::Set(int x, int y)
+    {        
+        if (x < 0)
+        {
+            _x = 0;
+        }
+        else if (x > 15)
+        {
+            _x = 15;
+        }
+        else
+        {
+            _x = x;
+        }
+
+        if (y < 0)
+        {
+            _y = 0;
+        }
+        else if (y > 15)
+        {
+            _y = 15;
+        }
+        else
+        {
+            _y = y;
+        }
+    }
+
+    int TDCoordinate::GetX()
+    {        
+        return _x;
+    }
+
+    int TDCoordinate::GetY()
+    {        
+        return _y;
     }
 
@@ -34,7 +67,7 @@
 
         Vector3 *coord = new Vector3();
-        coord->x= (x-8) * tileScale;
-        coord->y= (y-8) * tileScale;
-        coord->z=100;
+        coord->x= (_x-8) * tileScale;
+        coord->y= (_y-8) * tileScale;
+        coord->z=0;
 
         return *coord;
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TDCoordinate.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TDCoordinate.h	(revision 10585)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TDCoordinate.h	(revision 10586)
@@ -13,17 +13,18 @@
 //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
+    class _TowerDefenseExport TDCoordinate
     {
         public:
-            int x;
-            int y;
+            TDCoordinate();
+            TDCoordinate(int x, int y);
+            virtual ~TDCoordinate() {};
+            virtual void Set(int x, int y);
+            virtual int GetX();
+            virtual int GetY();
+            virtual Vector3 get3dcoordinate();
 
-            TDCoordinate();
-
-            Vector3 get3dcoordinate();
-
-            virtual ~TDCoordinate() {};
-
-            TDCoordinate(int x, int y);
+        private:
+            int _x;
+            int _y;
     };
 
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TDEnemy.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TDEnemy.h	(revision 10585)
+++ 	(revision )
@@ -1,26 +1,0 @@
-/*
- * TDEnemy.h
- *
- *  Created on: Mar 30, 2012
- *      Author: weigeltm
- */
-/*
-#ifndef TDENEMY_H_
-#define TDENEMY_H_
-
-class TDEnemy
-{
-
-private:
-    float health;
-    float speed;
-    float armour;
-
-
-
-
-
-};
-
-
-#endif  TDENEMY_H_ */
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/Tower.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/Tower.cc	(revision 10585)
+++ 	(revision )
@@ -1,113 +1,0 @@
-//
-//  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 "core/CoreIncludes.h"
-//#include "core/XMLPort.h"
-
-namespace orxonox
-{
-    RegisterClass(Tower);
-
-    /**
-    @brief
-        Constructor. Registers and initializes the object.
-    */
-    Tower::Tower(Context* context) : Pawn(context)
-    {
-        RegisterObject(Tower);
-
-        this->setCollisionType(WorldEntity::Dynamic);
-
-        //this->removeAllEngines();
-
-        /*
-        this->size_ = 10.0f;
-        this->delay_ = false;
-        this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
-        */
-    }
-
-    void Tower::setOrientation(const Quaternion& orientation)
-    {
-        static int ori;
-        //orxout() << "orientation " << ++ori << endl;
-    }
-
-    void Tower::rotateYaw(const Vector2& value)
-    {
-        static int yaw;
-        //orxout() << "rotateYaw " << ++yaw << endl;
-    }
-
-    void Tower::rotatePitch(const Vector2& value)
-    {
-        static int pitch;
-        //orxout() << "rotatePitch " << ++pitch << endl;
-    }
-
-    void Tower::rotateRoll(const Vector2& value)
-    {
-        static int roll;
-        //orxout() << "rotateRoll" << ++roll << endl;
-    }
-
-    // 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 "TowerMover". This is the controllable entity that the
-    // player controls in order to move the tower along the centerpoint and in order to place the tower at the appropriate position.
-    //
-
-    // The tower 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 tower are in the same team)
-
-    //How to move a tower: simply attach the tower to the TowerMover
-    //How to place a tower: detach the tower from the TowerMover
-
-    /**
-    @brief
-        Overloaded the function to rotate the stone.
-    @param value
-        A vector whose first component is the angle by which to rotate.
-    */
-    /*
-    void Tower::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 Tower::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/branches/towerdefenseFabien/src/modules/towerdefense/Tower.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/Tower.h	(revision 10585)
+++ 	(revision )
@@ -1,52 +1,0 @@
-//
-//  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"
-
-
-namespace orxonox
-{
-    class _TowerDefenseExport Tower : public Pawn
-    {
-    public:
-        Tower(Context* context);
-        virtual ~Tower() {};
-
-        // 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
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.cc	(revision 10585)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.cc	(revision 10586)
@@ -37,5 +37,4 @@
  *
  *
- *
  *TIPP: Eclipse hilft euch schnell auf bereits vorhanden Funktionen zuzugreifen:
  * einfach "this->" eingeben und kurz warten. Dann tauch eine Liste mit Vorschlägen auf. Wenn ihr jetzt weiter
@@ -76,9 +75,5 @@
 #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"
@@ -89,34 +84,41 @@
 #include "core/command/ConsoleCommand.h"
 
+
 namespace orxonox
 {
+    static const std::string __CC_addTower_name  = "addTower";
+    static const std::string __CC_upgradeTower_name = "upgradeTower";
+
+    SetConsoleCommand("TowerDefense", __CC_addTower_name,  &TowerDefense::addTower ).addShortcut().defaultValues(1);
+    SetConsoleCommand("TowerDefense", __CC_upgradeTower_name, &TowerDefense::upgradeTower).addShortcut().defaultValues(0);
+
     RegisterUnloadableClass(TowerDefense);
 
-    TowerDefense::TowerDefense(Context* context) : Deathmatch(context)
+    TowerDefense::TowerDefense(Context* context) : TeamDeathmatch(context)
     {
         RegisterObject(TowerDefense);
-/*
-        for (int i=0; i < 16 ; i++){
-            for (int j = 0; j< 16 ; j++){
-                towermatrix[i][j] = NULL;
-            }
-        }*/
-
+
+        selecter = NULL;
+        this->player_ = NULL;        
         this->setHUDTemplate("TowerDefenseHUD");
+        this->nextwaveTimer_.setTimer(10, false, createExecutor(createFunctor(&TowerDefense::nextwave, this)));
+        this->nextwaveTimer_.stopTimer();
+        this->waves_ = 0;
+        this->time = 0;
+        this->credit_ = 0;
+        this->lifes_ = 0;
 
         //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) ) );
+        ModifyConsoleCommand(__CC_addTower_name).setObject(this);
+        ModifyConsoleCommand(__CC_upgradeTower_name).setObject(this);
     }
 
     TowerDefense::~TowerDefense()
-    {
-        /* Part of a temporary hack to allow the player to add towers */
+    {        /* Part of a temporary hack to allow the player to add towers */
         if (this->isInitialized())
         {
-            if( this->dedicatedAddTower_ )
-                delete this->dedicatedAddTower_;
+            ModifyConsoleCommand(__CC_addTower_name).setObject(NULL);
+            ModifyConsoleCommand(__CC_upgradeTower_name).setObject(NULL);
         }
     }
@@ -124,50 +126,44 @@
     void TowerDefense::setCenterpoint(TowerDefenseCenterpoint *centerpoint)
     {
-        orxout() << "Centerpoint now setting..." << endl;
         this->center_ = centerpoint;
-        orxout() << "Centerpoint now set..." << endl;
     }
 
     void TowerDefense::start()
-    {
-
-        Deathmatch::start();
-
-// 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;
+    {        
+        if (center_ != NULL) // There needs to be a TowerDefenseCenterpoint, i.e. the area the game takes place.
+        {
+            if (selecter == NULL)
+            {
+                selecter = new TowerDefenseSelecter(this->center_->getContext());                
+            }
+            selecter->addTemplate(center_->getSelecterTemplate());
+            center_->attach(selecter);
+        }
+        else // If no centerpoint was specified, an error is thrown and the level is exited.
+        {
+            orxout(internal_error) << "Jump: No Centerpoint specified." << endl;
+            return;
+        }
+
+        enemies_.clear();
+
+        createFields();
+
+        TeamDeathmatch::start();
+
+        // Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path
+        
 
         //set initial credits, lifes and WaveNumber
-        this->setCredit(200);
-        this->setLifes(50);
+        this->setCredit(1000);
+        this->setLifes(100);
         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);
-        }*/
+        time = 0.0;
     }
 
     // Generates a TowerDefenseEnemy. Uses Template "enemytowerdefense". Sets position at first waypoint of path.
-    void TowerDefense::addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr){
-
+    void TowerDefense::addTowerDefenseEnemy(int templatenr)
+    {
+        orxout() << "addTowerDefenseEnemy" << endl;
 
         TowerDefenseEnemy* en1 = new TowerDefenseEnemy(this->center_->getContext());
@@ -185,5 +181,4 @@
             en1->setScale(2);
             en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
-            //  en1->setShieldHealth(en1->getShield() = this->getWaveNumber()*2))
             break;
 
@@ -193,14 +188,30 @@
             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)));
-        }
+        }        
+
+        en1->setTeam(2);
+
+        //orxonox::WeakPtr<WaypointController> controller = new WaypointController(this->center_->getContext());
+        //controller->setControllableEntity(en1);
+        //en1->setController(controller);
+
+        WaypointController* controller = (WaypointController*)(en1->getXMLController());
+
+        if (controller != NULL && waypoints_.size() > 1)
+        {
+            en1->setPosition(waypoints_.at(0)->getPosition());
+            en1->setOrientation(Vector3(0,0,10), Degree(0));
+            en1->setDirection(Vector3(0,1,0));
+            en1->lookAt(waypoints_.at(1)->getPosition());
+
+            for (unsigned int i = 0; i < waypoints_.size(); ++ i)
+            {
+                orxonox::WeakPtr<MovableEntity> waypoint = new MovableEntity(this->center_->getContext());
+                waypoint->setPosition(waypoints_.at(i)->getPosition());
+                controller->addWaypoint(waypoints_.at(i));
+            }
+        }
+
+        enemies_.push_back(en1);
     }
 
@@ -209,195 +220,216 @@
     {
 
-        Deathmatch::end();
+        TeamDeathmatch::end();
         ChatManager::message("Match is over! Gameover!");
 
     }
 
+    void TowerDefense::spawnPlayer(PlayerInfo* player)
+    {
+        assert(player);
+        player_ = player;
+
+        orxout() << "spawnPlayer" << endl;
+
+        if (selecter->getPlayer() == NULL)
+        {
+            player_->startControl(selecter);
+            players_[player].state_ = PlayerState::Alive;
+        } 
+    }
+
+    /**
+    @brief
+        Get the player.
+    @return
+        Returns a pointer to the player. If there is no player, NULL is returned.
+    */
+    PlayerInfo* TowerDefense::getPlayer(void) const
+    {
+        return this->player_;
+    }
+
     //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();
-        }*/
+    void TowerDefense::addTower(int x,int y)
+    {
+        TDCoordinate* coord = new TDCoordinate(x,y);
+        x = coord->GetX();
+        y = coord->GetY();
+
+        int cost = center_->getTowerCost(1);
+
+        if (fields_[x][y]->isFree() == true && getCredit() >= cost)
+        {
+            payCredit(cost);
+            fields_[x][y]->createTower(1);
+        }
     }
 
     /*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 int towerCost = 20;
-
-        if (!this->hasEnoughCreditForTower(towerCost))
-        {
-            orxout() << "not enough credit: " << (this->getCredit()) << " available, " << towerCost << " needed.";
+
+    void TowerDefense::upgradeTower(int x, int y)
+    {    
+        TDCoordinate* coord = new TDCoordinate(x,y);
+        x = coord->GetX();
+        y = coord->GetY();     
+
+        int cost = center_->getTowerCost(fields_[x][y]->getUpgrade() + 1);
+
+        if (fields_[x][y]->isFree() == false && fields_[x][y]->canUpgrade() == true && getCredit() >= cost)
+        {
+            payCredit(cost);
+            fields_[x][y]->upgrade();
+        }
+    }    
+
+    void TowerDefense::tick(float dt)
+    {
+        //orxout() << "tick1" << endl;
+        SUPER(TowerDefense, tick, dt);
+        //orxout() << "tick2" << endl;
+
+        if (hasStarted() == false || player_ == NULL)
+        {
             return;
         }
-
-        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();
-
-        if (x > 15 || y > 15 || x < 0 || y < 0)
-        {
-            //Hard coded: TODO: let this depend on the centerpoint's height, width and fieldsize (fieldsize doesn't exist yet)
-            orxout() << "Can not add Tower: x and y should be between 0 and 15" << endl;
-            return;
-        }
-
-        orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
-
-       //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)
+        time += dt;       
+
+        //build/upgrade tower at selecter position
+        if (selecter != NULL && selecter->buildTower_ == true)
+        {
+            selecter->buildTower_ = false;
+
+            if (getField(selecter->selectedPos_)->canUpgrade() == true)
+            {
+                upgradeTower(selecter->selectedPos_->GetX(), selecter->selectedPos_->GetY());
+            }
+            else
+            {
+                addTower(selecter->selectedPos_->GetX(), selecter->selectedPos_->GetY());
+            }            
+        }
+
+        if (time >= 1.3 * enemies_.size() && enemies_.size() < 10)
         {
             //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);
+            addTowerDefenseEnemy(this->getWaveNumber() % 3 +1 );
+        }
+
         //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();
-                    }
+
+        std::vector<orxonox::WeakPtr<TowerDefenseEnemy> >::iterator itBegin = enemies_.begin();
+        std::vector<orxonox::WeakPtr<TowerDefenseEnemy> >::iterator it = itBegin;
+        std::vector<orxonox::WeakPtr<TowerDefenseEnemy> >::iterator itEnd = enemies_.end();
+
+        while(it != itEnd)
+        {
+            //destroys enemys at the end of the path and reduces the life by 1. No credits gifted
+            Vector3 ship = (*it)->getRVWorldPosition();
+            float distance = ship.distance(endpoint_);
+            if(distance < 50)
+            {
+                std::vector<orxonox::WeakPtr<TowerDefenseEnemy> >::iterator itTemp = it;
+                ++ it;
+                orxout() << "enemy deleted" << endl;                
+                enemies_.erase(itTemp);
+                (*itTemp)->destroy();
+                this->reduceLifes(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;
-            }
-        }
-
-
-    }
-
-    // Function to test if we can add waypoints using code only. Doesn't work yet
-
-    // THE PROBLEM: WaypointController's getControllableEntity() returns null, so it won't track. How do we get the controlableEntity to NOT BE NULL???
-    /*
-    void TowerDefense::addWaypointsAndFirstEnemy()
-    {
-        SpaceShip *newShip = new SpaceShip(this->center_);
-        newShip->addTemplate("spaceshipassff");
-
-        WaypointController *newController = new WaypointController(newShip);
-        newController->setAccuracy(3);
-
-        Model *wayPoint1 = new Model(newController);
-        wayPoint1->setMeshSource("crate.mesh");
-        wayPoint1->setPosition(7,-7,5);
-        wayPoint1->setScale(0.2);
-
-        Model *wayPoint2 = new Model(newController);
-        wayPoint2->setMeshSource("crate.mesh");
-        wayPoint2->setPosition(7,7,5);
-        wayPoint2->setScale(0.2);
-
-        newController->addWaypoint(wayPoint1);
-        newController->addWaypoint(wayPoint2);
-
-        // The following line causes the game to crash
-
-        newShip->setController(newController);
-//        newController -> getPlayer() -> startControl(newShip);
-        newShip->setPosition(-7,-7,5);
-        newShip->setScale(0.1);
-        //newShip->addSpeed(1);
-
-
-
-//      this->center_->attach(newShip);
-    }
-    */
+            else
+            {
+                ++ it;
+            }
+        }        
+
+        if (enemies_.size() == 0 && !this->nextwaveTimer_.isActive())
+        {
+            this->nextwaveTimer_.startTimer();
+        }
+    }
+
+    void TowerDefense::createFields()
+    {
+        assert(center_);
+        TDCoordinate coord(0,0);
+        TDCoordinate startCoord(0,0);
+
+        std::string fields = center_->getFields();
+        int pos = 0;
+        for (int j = 15; j >= 0; --j)
+        {
+            for (int i = 0; i < 16; ++i)
+            {
+                coord.Set(i,j);
+                fields_[i][j] = new TowerDefenseField(center_->getContext());
+                fields_[i][j]->setCenterpoint(center_);
+                center_->attach(fields_[i][j]);
+                fields_[i][j]->setPosition(coord.get3dcoordinate());                
+                fields_[i][j]->create(fields.at(pos), fields.at(pos+1));           
+                pos += 2;
+                if (fields_[i][j]->getType() == START)
+                {
+                    startCoord.Set(i,j);
+                    waypoints_.push_back(fields_[i][j]);
+                }
+            }
+        }
+
+        //Place waypoints along the street for the waypoint controllers of the enemies
+        TDCoordinate* thisCoord = &startCoord;
+        TDCoordinate* nextCoord;
+        while ((nextCoord = getNextStreetCoord(thisCoord)) != NULL)
+        {
+            waypoints_.push_back(fields_[nextCoord->GetX()][nextCoord->GetY()]);            
+            thisCoord = nextCoord;
+            endpoint_ = nextCoord->get3dcoordinate();
+        }
+
+    }
+
+    TDCoordinate* TowerDefense::getNextStreetCoord(TDCoordinate* thisCoord)
+    {        
+        TowerDefenseField* thisField = fields_[thisCoord->GetX()][thisCoord->GetY()];
+        TDCoordinate* nextCoord = new TDCoordinate(0,0);
+
+        if (thisField->getType() != STREET && thisField->getType() != START)
+        {
+            return NULL;
+        }
+
+        if (thisField->getAngle() == 0)
+        {
+            nextCoord->Set(thisCoord->GetX(), thisCoord->GetY() - 1);
+        }
+        else if (thisField->getAngle() == 1)
+        {
+            nextCoord->Set(thisCoord->GetX() + 1, thisCoord->GetY());
+        }
+        else if (thisField->getAngle() == 2)
+        {
+            nextCoord->Set(thisCoord->GetX(), thisCoord->GetY() + 1);
+        }
+        else if (thisField->getAngle() == 3)
+        {
+            nextCoord->Set(thisCoord->GetX() - 1, thisCoord->GetY());
+        }
+
+        if (thisCoord->GetX() != nextCoord->GetX() || thisCoord->GetY() != nextCoord->GetY())
+        {
+            return nextCoord;
+        }
+
+        return NULL;
+    }
+
     /*
     void TowerDefense::playerEntered(PlayerInfo* player)
     {
-        Deathmatch::playerEntered(player);
+        TeamDeathmatch::playerEntered(player);
 
         const std::string& message = player->getName() + " entered the game";
@@ -407,5 +439,5 @@
     bool TowerDefense::playerLeft(PlayerInfo* player)
     {
-        bool valid_player = Deathmatch::playerLeft(player);
+        bool valid_player = TeamDeathmatch::playerLeft(player);
 
         if (valid_player)
@@ -437,5 +469,5 @@
         }
 
-        Deathmatch::pawnKilled(victim, killer);
+        TeamDeathmatch::pawnKilled(victim, killer);
     }
 
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.h	(revision 10585)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.h	(revision 10586)
@@ -38,28 +38,26 @@
 #define _TowerDefense_H__
 #include "TDCoordinate.h"
+#include "TowerDefenseSelecter.h"
 #include "towerdefense/TowerDefensePrereqs.h"
-#include "gametypes/Deathmatch.h"
+#include "gametypes/TeamDeathmatch.h"
 #include "TowerDefenseEnemy.h"
 #include "util/Output.h"
-#include "core/object/WeakPtr.h"
+#include "TowerDefenseField.h"
 
 namespace orxonox
 {
-    class _TowerDefenseExport TowerDefense : public Deathmatch
+    class _TowerDefenseExport TowerDefense : public TeamDeathmatch
     {
     public:
         TowerDefense(Context* context);
-        virtual ~TowerDefense();
-
-        std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > TowerDefenseEnemyvector;
-        bool towermatrix[16][16];
-        void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr);
+        virtual ~TowerDefense();        
+        void addTowerDefenseEnemy(int templatenr);
         virtual void start(); //<! The function is called when the gametype starts
         virtual void end();
         virtual void tick(float dt);
-        //virtual void playerEntered(PlayerInfo* player);
-        //virtual bool playerLeft(PlayerInfo* player);
-        //Player Stats (set,get, reduce)
+        virtual void spawnPlayer(PlayerInfo* player);
+        PlayerInfo* getPlayer(void) const;
         int getCredit(){ return this->credit_; }
+        void payCredit(int pay){ this->credit_ -= pay; }
         int getLifes(){ return this->lifes_; }
         int getWaveNumber(){ return this->waves_; }
@@ -69,23 +67,20 @@
         void buyTower(int cost){ credit_ -= cost;}
         void addCredit(int credit) { credit_+=credit; }
-        void nextwave(){ waves_++;}
+        void nextwave(){ enemies_.clear(); waves_++; time=0;}
         int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; }
+        TowerDefenseField* getField(TDCoordinate* coord){ return fields_[coord->GetX()][coord->GetY()]; }
+        /*  Called by TowerDefenseCenterpoint upon game start
+            The centerpoint is used to create towers
+        */
+        void setCenterpoint(TowerDefenseCenterpoint* centerpoint);        
+        /* Adds a tower at x, y in the playfield */
+        void addTower(int x, int y);
+        void upgradeTower(int x, int y); 
+        virtual TDCoordinate* getNextStreetCoord(TDCoordinate*);
 
         //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
         //virtual void playerScored(PlayerInfo* player, int score);
 
-
-        /*  Called by TowerDefenseCenterpoint upon game start
-            The centerpoint is used to create towers
-        */
-        void setCenterpoint(TowerDefenseCenterpoint *centerpoint);
-
-        /* Adds a tower at x, y in the playfield */
-        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_;
+        TowerDefenseSelecter* selecter;        
 
         //TODO: void spawnNewWave()
@@ -93,20 +88,18 @@
         //      or spawn a new wave when the old wave has been killed           (event driven)
 
-
     private:
-        TowerDefenseCenterpoint *center_;
-        float time;
-        float time2;
+        orxonox::WeakPtr<TowerDefenseCenterpoint> center_;
+        PlayerInfo* player_;
+        float time;        
         int credit_;
         int waves_;
         int lifes_;
+        Timer nextwaveTimer_;
+        std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > enemies_;
+        TowerDefenseField* fields_[16][16];
+        std::vector<orxonox::WeakPtr<TowerDefenseField> > waypoints_;
+        Vector3 endpoint_;
 
-        /* handles stats */
-        bool hasEnoughCreditForTower(int towerCost);
-        bool hasEnoughCreditForUpgrade();
-
-
-
-        std::vector<TowerTurret*> towers_;
+        void createFields();
     };
 }
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseCenterpoint.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseCenterpoint.cc	(revision 10585)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseCenterpoint.cc	(revision 10586)
@@ -53,5 +53,4 @@
         this->width_ = 15;
         this->height_ = 15;
-        this->towerTemplate_ = "";
 
         //this->setCollisionType(Static);
@@ -72,5 +71,16 @@
         XMLPortParam(TowerDefenseCenterpoint, "height", setHeight, getHeight, xmlelement, mode);
         XMLPortParam(TowerDefenseCenterpoint, "tileScale", setTileScale, getTileScale, xmlelement, mode);
-        XMLPortParam(TowerDefenseCenterpoint, "towerTemplate", setTowerTemplate, getTowerTemplate, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "selecterTemplate", setSelecterTemplate, getSelecterTemplate, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "tower1Template", setTower1Template, getTower1Template, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "tower2Template", setTower2Template, getTower2Template, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "tower3Template", setTower3Template, getTower3Template, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "tower4Template", setTower4Template, getTower4Template, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "tower5Template", setTower5Template, getTower5Template, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "fields", setFields, getFields, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "tower1Cost", setTower1Cost, getTower1Cost, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "tower2Cost", setTower2Cost, getTower2Cost, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "tower3Cost", setTower3Cost, getTower3Cost, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "tower4Cost", setTower4Cost, getTower4Cost, xmlelement, mode);
+        XMLPortParam(TowerDefenseCenterpoint, "tower5Cost", setTower5Cost, getTower5Cost, xmlelement, mode);
 
         //TODO: add XMLPortObject(TowerDefenseCenterpoint, WorldEntity, "waypoints", addWaypoint, getWaypoint,  xmlelement, mode);
@@ -107,3 +117,29 @@
         }
     }
+
+    /**
+    @brief
+        Removes all blanks, tabs and returns from the string passed.
+    */
+    void TowerDefenseCenterpoint::trimString(std::string* str)
+    {
+        std::string* trimmed = new std::string("");
+        int length = str->size();
+        char temp;
+        for (int i = 0; i < length; ++ i)
+        {
+            temp = str->at(i);
+            if (temp != ' ' && temp != '\t' && temp != '\n')
+            {
+                trimmed->push_back(temp);
+            }
+        }
+
+        *str = *trimmed;
+    }
+
+    const int TowerDefenseCenterpoint::getTowerCost(int upgrade) const
+    {
+        return towerCosts_[(upgrade%5)];
+    }
 }
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseCenterpoint.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseCenterpoint.h	(revision 10585)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseCenterpoint.h	(revision 10586)
@@ -41,5 +41,5 @@
 #include <string>
 #include <util/Math.h>
-
+#include "TowerDefenseTower.h"
 #include "worldentities/MobileEntity.h"
 
@@ -60,13 +60,63 @@
             void setWidth(unsigned int width)
                 { this->width_ = width; }
-
             unsigned int getWidth(void) const
                 { return this->width_; }
-
             void setHeight(unsigned int height)
                 { this->height_ = height; }
-
             unsigned int getHeight(void) const
                 { return this->height_; }
+            void setFields(const std::string& newFields)
+                { this->fields_ = newFields; trimString(&fields_); }
+            const std::string& getFields() const
+                { return this->fields_; }                    
+            void setSelecterTemplate(const std::string& newTemplate)
+                { this->selecterTemplate_ = newTemplate; }
+            const std::string& getSelecterTemplate() const
+                { return this->selecterTemplate_; }   
+
+            void setTower1Template(const std::string& newTemplate)
+                { this->towerTemplates_[0] = newTemplate;}
+            const std::string& getTower1Template() const
+                { return this->towerTemplates_[0]; }  
+            void setTower2Template(const std::string& newTemplate)
+                { this->towerTemplates_[1] = newTemplate; }
+            const std::string& getTower2Template() const
+                { return this->towerTemplates_[1]; }
+            void setTower3Template(const std::string& newTemplate)
+                { this->towerTemplates_[2] = newTemplate; }
+            const std::string& getTower3Template() const
+                { return this->towerTemplates_[2]; } 
+            void setTower4Template(const std::string& newTemplate)
+                { this->towerTemplates_[3] = newTemplate; }
+            const std::string& getTower4Template() const
+                { return this->towerTemplates_[3]; }
+            void setTower5Template(const std::string& newTemplate)
+                { this->towerTemplates_[4] = newTemplate; }
+            const std::string& getTower5Template() const
+                { return this->towerTemplates_[4]; }  
+
+            void setTower1Cost(const int& newCost)
+                { this->towerCosts_[0] = newCost;}
+            const int& getTower1Cost() const
+                { return this->towerCosts_[0]; }  
+            void setTower2Cost(const int& newCost)
+                { this->towerCosts_[1] = newCost; }
+            const int& getTower2Cost() const
+                { return this->towerCosts_[1]; }
+            void setTower3Cost(const int& newCost)
+                { this->towerCosts_[2] = newCost; }
+            const int& getTower3Cost() const
+                { return this->towerCosts_[2]; } 
+            void setTower4Cost(const int& newCost)
+                { this->towerCosts_[3] = newCost; }
+            const int& getTower4Cost() const
+                { return this->towerCosts_[3]; }
+            void setTower5Cost(const int& newCost)
+                { this->towerCosts_[4] = newCost; }
+            const int& getTower5Cost() const
+                { return this->towerCosts_[4]; }
+
+            const int getTowerCost(int upgrade) const;
+                                            
 
             /**
@@ -79,22 +129,14 @@
                 { return this->tileScale_; }
 
-            /**
-            @brief Set the template for the towers.
-            @param template The template name to be applied to each tower.
-            */
-            void setTowerTemplate(const std::string& templateName)
-                { this->towerTemplate_ = templateName; }
-
-            const std::string& getTowerTemplate(void) const
-                { return this->towerTemplate_; }
-
         private:
             void checkGametype();
-
+            void trimString(std::string*);
+            std::string selecterTemplate_;
+            std::string towerTemplates_[5];
+            int towerCosts_[5];
+            std::string fields_;
             unsigned int width_;
             unsigned int height_;
             unsigned int tileScale_;
-
-            std::string towerTemplate_;
     };
 }
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseController.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseController.cc	(revision 10585)
+++ 	(revision )
@@ -1,146 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "TowerDefenseController.h"
-
-#include "util/Math.h"
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "worldentities/pawns/Pawn.h"
-#include "controllers/WaypointController.h"
-
-namespace orxonox
-{
-    RegisterClass(TowerDefenseController);
-
-    TowerDefenseController::TowerDefenseController(Context* context) : WaypointController(context)
-    {
-        RegisterObject(TowerDefenseController);
-
-        this->alertnessradius_ = 500;
-
-        this->patrolTimer_.setTimer(rnd(), true, createExecutor(createFunctor(&TowerDefenseController::searchEnemy, this)));
-    }
-
-    void TowerDefenseController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(TowerDefenseController, XMLPort, xmlelement, mode);
-
-        XMLPortParam(TowerDefenseController, "alertnessradius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues(500.0f);
-    }
-
-
-    void TowerDefenseController::tick(float dt)
-    {
-        if (!this->isActive())
-            return;
-
-        if (this->target_)
-        {
-            this->aimAtTarget();
-
-            if (this->bHasTargetPosition_)
-                this->moveToTargetPosition();
-
-            if (this->getControllableEntity() && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
-                this->getControllableEntity()->fire(0);
-        }
-        else
-        {
-            SUPER(TowerDefenseController, tick, dt);
-        }
-    }
-
-
-    bool sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
-    {
-        if (entity1 == entity2)
-            return true;
-
-        int team1 = -1;
-        int team2 = -1;
-
-        Controller* controller = 0;
-        if (entity1->getController())
-            controller = entity1->getController();
-        else
-            controller = entity1->getXMLController();
-        if (controller)
-        {
-            FormationController* ac = orxonox_cast<FormationController*>(controller);
-            if (ac)
-                team1 = ac->getTeam();
-        }
-
-        if (entity2->getController())
-            controller = entity2->getController();
-        else
-            controller = entity2->getXMLController();
-        if (controller)
-        {
-            FormationController* ac = orxonox_cast<FormationController*>(controller);
-            if (ac)
-                team2 = ac->getTeam();
-        }
-
-
-
-        return (team1 == team2 && team1 != -1);
-    }
-
-
-
-
-
-    void TowerDefenseController::searchEnemy()
-    {
-        this->patrolTimer_.setInterval(rnd());
-
-        if (!this->getControllableEntity())
-            return;
-
-        Vector3 myposition = this->getControllableEntity()->getPosition();
-        float shortestsqdistance = (float)static_cast<unsigned int>(-1);
-
-        for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
-        {
-            if (ArtificialController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(*it), this->getGametype()))
-                continue;
-
-            float sqdistance = it->getPosition().squaredDistance(myposition);
-            if (sqdistance < shortestsqdistance)
-            {
-                shortestsqdistance = sqdistance;
-                this->target_ = (*it);
-            }
-        }
-
-        if (shortestsqdistance > (this->alertnessradius_ * this->alertnessradius_))
-            this->target_ = 0;
-    }
-}
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseController.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseController.h	(revision 10585)
+++ 	(revision )
@@ -1,61 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _TowerDefenseController_H__
-#define _TowerDefenseController_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "tools/Timer.h"
-#include "WaypointController.h"
-
-namespace orxonox
-{
-    class _TowerDefenseExport TowerDefenseController : public WaypointController
-    {
-        public:
-            TowerDefenseController(Context* context);
-            virtual ~TowerDefenseController() {}
-
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            virtual void tick(float dt);
-
-            inline void setAlertnessRadius(float radius)
-                { this->alertnessradius_ = radius; }
-            inline float getAlertnessRadius() const
-                { return this->alertnessradius_; }
-
-        protected:
-            void searchEnemy();
-
-            float alertnessradius_;
-            Timer patrolTimer_;
-    };
-}
-
-#endif /* _TowerDefenseController_H__ */
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseEnemy.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseEnemy.cc	(revision 10585)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseEnemy.cc	(revision 10586)
@@ -30,21 +30,17 @@
         //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);
+        once_ = false;
     }
 
-    void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord)
+    TowerDefenseEnemy::~TowerDefenseEnemy()
     {
-        this->Waypointsvector_.push_back(coord);
+        orxout() << "TowerDefenseEnemy::~TowerDefenseEnemy" << endl;
     }
 
-
     void TowerDefenseEnemy::tick(float dt)
-    {
+    {   
+        //orxout() << "TDE tick1" << endl;
         SUPER(TowerDefenseEnemy, tick, dt);
+        //orxout() << "TDE tick2" << endl;
     }
 
@@ -61,4 +57,5 @@
     void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
     {
+        orxout() << "TowerDefenseEnemy::damage" << endl;
         Pawn::damage(damage, healthdamage, shielddamage, originator);
         if (getGame() && once_ == false && getHealth() <= 0)
@@ -68,24 +65,3 @@
         }
     }
-/*
-    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/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseEnemy.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseEnemy.h	(revision 10585)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseEnemy.h	(revision 10586)
@@ -39,10 +39,5 @@
 
         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:
@@ -51,6 +46,4 @@
         TowerDefense* td;
         bool once_;
-        std::vector<TDCoordinate*> Waypointsvector_;
-
     };
 
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseField.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseField.cc	(revision 10586)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseField.cc	(revision 10586)
@@ -0,0 +1,287 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file TowerDefenseField.cc
+    @brief Implementation of the TowerDefenseField class.
+*/
+
+#include "TowerDefenseField.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "TowerDefense.h"
+
+namespace orxonox
+{
+    RegisterClass(TowerDefenseField);
+
+    /**
+    @brief
+        Constructor. Registers and initializes the object and checks whether the gametype is actually TowerDefense.
+    */
+    TowerDefenseField::TowerDefenseField(Context* context) : MovableEntity(context)
+    {
+        RegisterObject(TowerDefenseField);
+
+        tower_ = NULL;
+        type_ = FREE;
+        center_ = NULL;
+        upgrade_ = 0;
+        setPosition(0,0,0);        
+        model_ = new Model(getContext());
+        model_->setScale(25);
+        model_->pitch(Degree(90));
+        attach(model_);
+        setAngle(0); 
+    }
+
+    /**
+    @brief
+        Method to create a TowerDefenseField through XML.
+    */
+    void TowerDefenseField::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(TowerDefenseField, XMLPort, xmlelement, mode);
+
+        //XMLPortParam(TowerDefenseField, "width", setWidth, getWidth, xmlelement, mode);
+
+    }
+
+    void TowerDefenseField::setCenterpoint(TowerDefenseCenterpoint* center)
+    {
+        center_ = center;
+    }
+
+    void TowerDefenseField::upgrade()
+    {
+        if (canUpgrade() == true)
+        {
+            destroyTower();
+            createTower(getUpgrade() + 1);
+        }
+    }
+
+    int TowerDefenseField::getUpgrade()
+    {
+        return upgrade_;
+    }
+
+    TowerDefenseFieldType TowerDefenseField::getType()
+    {
+        return type_;
+    }
+
+    void TowerDefenseField::setUpgrade(int upgrade)
+    {
+        if (upgrade < 0)
+        {
+            upgrade_ = 0;
+        }   
+        else if (upgrade > 5)
+        {
+            upgrade = 5;
+        }
+        else
+        {
+            upgrade_ = upgrade;
+        }                            
+    }
+
+    bool TowerDefenseField::canUpgrade()
+    {
+        if (tower_ != NULL && upgrade_ < 5)
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+    void TowerDefenseField::setAngle(int newAngle)
+    {
+        if (model_ == NULL)
+        {
+            return;
+        }
+
+        switch (newAngle)
+        {
+            case 0:
+                model_->yaw(Degree(0));
+                angle_ = 0;
+                break;
+            case 1:
+                model_->yaw(Degree(90));
+                angle_ = 1;
+                break;    
+            case 2:
+                model_->yaw(Degree(180));
+                angle_ = 2;
+                break;   
+            case 3:
+                model_->yaw(Degree(270));
+                angle_ = 3;
+                break;                                           
+        }
+    }
+
+    int TowerDefenseField::getAngle()
+    {
+        return angle_;
+    }
+
+    void TowerDefenseField::createFree(int orientation)
+    {            
+        model_->setMeshSource("TD_F1.mesh");
+        tower_ = NULL;
+        type_ = FREE;
+        setUpgrade(0);
+        setAngle(orientation);
+    }
+
+    void TowerDefenseField::createStart(int orientation)
+    {      
+        model_->setMeshSource("TD_S5.mesh");
+        tower_ = NULL;
+        type_ = START;
+        setUpgrade(0);
+        setAngle(orientation);    
+    }
+
+
+    void TowerDefenseField::createEnd(int orientation)
+    {     
+        model_->setMeshSource("TD_S4.mesh");
+        tower_ = NULL;
+        type_ = END;
+        setUpgrade(0);
+        setAngle(orientation);
+    }   
+
+    void TowerDefenseField::createStraight(int orientation)
+    {      
+        model_->setMeshSource("TD_S1.mesh");
+        tower_ = NULL;
+        type_ = STREET;
+        setUpgrade(0);
+        setAngle(orientation);
+    }  
+
+    void TowerDefenseField::createRCurve(int orientation)
+    {     
+        model_->setMeshSource("TD_S2.mesh");
+        tower_ = NULL;
+        type_ = STREET;
+        setUpgrade(0);
+        setAngle(orientation);
+    }  
+
+    void TowerDefenseField::createLCurve(int orientation)
+    {    
+        model_->setMeshSource("TD_S3.mesh");
+        tower_ = NULL;
+        type_ = STREET;
+        setUpgrade(0);
+        setAngle(orientation);
+    } 
+
+    void TowerDefenseField::createTower(int upgrade)
+    {        
+        if (tower_ == NULL)
+        {
+            tower_ = new TowerDefenseTower(center_->getContext());
+            attach(tower_);
+            type_ = TOWER;
+            setUpgrade(upgrade);
+            if (upgrade_ > 0 && model_ != NULL)
+            {
+                switch (upgrade_)
+                {
+                    case 1:
+                        model_->setMeshSource("TD_T1.mesh");                    
+                        tower_->addTemplate(center_->getTower1Template());
+                        break;
+                    case 2:
+                        model_->setMeshSource("TD_T2.mesh");
+                        tower_->addTemplate(center_->getTower2Template());
+                        break;
+                    case 3:
+                        model_->setMeshSource("TD_T3.mesh");
+                        tower_->addTemplate(center_->getTower3Template());
+                        break;
+                    case 4:
+                        model_->setMeshSource("TD_T4.mesh");
+                        tower_->addTemplate(center_->getTower4Template());
+                        break;
+                    case 5:
+                        model_->setMeshSource("TD_T5.mesh");
+                        tower_->addTemplate(center_->getTower5Template());
+                        break;
+                }
+            }
+        }                           
+    }
+
+    void TowerDefenseField::destroyTower()
+    {
+        if (tower_ != NULL)
+        {
+            tower_->destroy();
+            tower_ = NULL;
+        }
+    }
+
+    void TowerDefenseField::create(char object, char param)
+    {
+        int paramInt = atoi(&param);
+        switch (object)
+        {
+            case 'F':
+                createFree(paramInt);
+                break;
+            case 'I':                
+                createStraight(paramInt);
+                break;
+            case 'R':                
+                createRCurve(paramInt);
+                break;  
+            case 'L':               
+                createLCurve(paramInt);
+                break;
+            case 'X':               
+                createStart(paramInt);
+                break;     
+            case 'O':               
+                createEnd(paramInt);
+                break;    
+            case 'T':                               
+                createTower(paramInt);               
+                break;                                                                                                         
+        }
+    }
+}
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseField.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseField.h	(revision 10586)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseField.h	(revision 10586)
@@ -0,0 +1,94 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @brief
+ See TowerDefenseReadme.txt for Information.
+ @ingroup TowerDefense
+ */
+
+
+#ifndef _TowerDefenseField_H__
+#define _TowerDefenseField_H__
+
+#include "towerdefense/TowerDefensePrereqs.h"
+#include "TowerDefenseTower.h"
+ #include "TowerDefenseCenterpoint.h"
+#include <string>
+#include "graphics/Model.h"
+#include "worldentities/MovableEntity.h"
+
+namespace orxonox
+{
+    enum TowerDefenseFieldType
+    { 
+        FREE,
+        STREET, 
+        START, 
+        END,
+        TOWER
+    };
+
+
+    class _TowerDefenseExport TowerDefenseField : public MovableEntity
+    {
+        public:
+            TowerDefenseField(Context* context);
+            virtual ~TowerDefenseField() {}
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            const bool isFree() const
+                { return type_==FREE; }
+            virtual void create(char object, char param);
+            virtual void setCenterpoint(TowerDefenseCenterpoint* center);
+            virtual void upgrade();
+            virtual int getUpgrade();
+            virtual TowerDefenseFieldType getType();
+            virtual void setUpgrade(int upgrade);
+            virtual bool canUpgrade();
+            virtual void createFree(int orientation);
+            virtual void createStart(int orientation);
+            virtual void createEnd(int orientation);
+            virtual void createStraight(int orientation);
+            virtual void createLCurve(int orientation);
+            virtual void createRCurve(int orientation);
+            virtual void createTower(int upgrade);
+            virtual int getAngle();
+        private:
+            virtual void setAngle(int newAngle);            
+            virtual void destroyTower();
+            int angle_;
+            TowerDefenseFieldType type_;
+            Model* model_;
+            TowerDefenseTower* tower_;
+            TowerDefenseCenterpoint* center_;
+            int upgrade_;
+
+    };    
+}
+
+#endif /* _TowerDefenseField_H__ */
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseSelecter.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseSelecter.cc	(revision 10586)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseSelecter.cc	(revision 10586)
@@ -0,0 +1,186 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabien Vultier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file TowerDefenseSelecter.cc
+    @brief This class represents your figure when you play the minigame. Here the movement of the figure, activating items, ... are handled.
+*/
+
+#include "TowerDefenseSelecter.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "graphics/Model.h"
+
+namespace orxonox
+{
+    RegisterClass(TowerDefenseSelecter);
+
+    TowerDefenseSelecter::TowerDefenseSelecter(Context* context) : ControllableEntity(context)
+    {
+        RegisterObject(TowerDefenseSelecter);
+
+        // initialize variables
+        moveUpPressed_ = false;
+        moveDownPressed_ = false;
+        moveLeftPressed_ = false;
+        moveRightPressed_ = false;
+        boostPressed_ = false;
+        buildTower_ = false;
+        setSelectedPosition(0,0);     
+    }
+
+    TowerDefenseSelecter::~TowerDefenseSelecter()
+    {
+
+    }
+
+    void TowerDefenseSelecter::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(TowerDefenseSelecter, XMLPort, xmlelement, mode);
+    }
+
+    void TowerDefenseSelecter::tick(float dt)
+    {
+        SUPER(TowerDefenseSelecter, tick, dt);
+
+        time_ += dt;
+
+        if (hasLocalController() && time_ >= 0.25)
+        {    
+            time_ = 0;
+
+            int selecterPosX = selectedPos_->GetX();
+            int selecterPosY = selectedPos_->GetY();
+
+            if (moveUpPressed_ == true)
+            {                
+                moveUpPressed_ = false;
+                selectedPos_->Set(selecterPosX, selecterPosY + 1);
+                updatePosition();
+            }
+            if (moveDownPressed_ == true)
+            {
+                moveDownPressed_ = false;
+            	selectedPos_->Set(selecterPosX, selecterPosY - 1);
+                updatePosition();
+            }
+            if (moveLeftPressed_ == true)
+            {
+                moveLeftPressed_ = false;
+                selectedPos_->Set(selecterPosX - 1, selecterPosY);
+                updatePosition();
+            }
+            if (moveRightPressed_ == true)
+            {
+                moveRightPressed_ = false;
+            	selectedPos_->Set(selecterPosX + 1, selecterPosY);
+                updatePosition();
+            }
+            if (boostPressed_ == true)
+            {
+                boostPressed_ = false;
+                buildTower_ = true;
+            }
+        }         
+    }
+
+
+    void TowerDefenseSelecter::moveFrontBack(const Vector2& value)
+    {
+        if (value.x > 0)
+        {
+            moveUpPressed_ = true;
+            moveDownPressed_ = false;
+        }
+        else
+        {
+            moveUpPressed_ = false;
+            moveDownPressed_ = true;
+        }
+    }
+
+    void TowerDefenseSelecter::moveRightLeft(const Vector2& value)
+    {
+        if (value.x > 0)
+        {
+            moveLeftPressed_ = false;
+            moveRightPressed_ = true;
+        }
+        else
+        {
+            moveLeftPressed_ = true;
+            moveRightPressed_ = false;
+        }
+    }
+
+    void TowerDefenseSelecter::rotateYaw(const Vector2& value)
+    {
+    }
+
+    void TowerDefenseSelecter::rotatePitch(const Vector2& value)
+    {
+    }
+
+    void TowerDefenseSelecter::rotateRoll(const Vector2& value)
+    {
+    }
+
+    void TowerDefenseSelecter::fire(unsigned int firemode)
+    {
+    }
+
+    void TowerDefenseSelecter::fired(unsigned int firemode)
+    {
+        
+    }
+
+    void TowerDefenseSelecter::boost(bool bBoost)
+    {
+        if (bBoost == true)
+        {
+            boostPressed_ = true;
+        }
+    }
+
+    void TowerDefenseSelecter::updatePosition()
+    {
+        setPosition(selectedPos_->get3dcoordinate());
+    }
+
+    void TowerDefenseSelecter::setSelectedPosition(TDCoordinate* newPos)
+    {
+        selectedPos_ = newPos;
+        updatePosition();
+    }
+
+    void TowerDefenseSelecter::setSelectedPosition(int x,  int y)
+    {
+        setSelectedPosition(new TDCoordinate(x,y));
+    }
+}
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseSelecter.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseSelecter.h	(revision 10586)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseSelecter.h	(revision 10586)
@@ -0,0 +1,69 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabien Vultier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _TowerDefenseSelecter_H__
+#define _TowerDefenseSelecter_H__
+
+#include "towerdefense/TowerDefensePrereqs.h"
+#include "worldentities/ControllableEntity.h"
+#include "TDCoordinate.h"
+
+namespace orxonox
+{
+class _TowerDefenseExport TowerDefenseSelecter : public ControllableEntity
+    {
+        public:
+            TowerDefenseSelecter(Context* context); //!< Constructor. Registers and initializes the object.
+            virtual ~TowerDefenseSelecter();
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);         
+            virtual void tick(float dt);            
+            virtual void moveFrontBack(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
+            virtual void moveRightLeft(const Vector2& value); //!< Overloaded the function to steer the bat up and down.
+            virtual void rotateYaw(const Vector2& value);
+            virtual void rotatePitch(const Vector2& value);
+            virtual void rotateRoll(const Vector2& value);
+            void fire(unsigned int firemode);
+            virtual void fired(unsigned int firemode);
+            virtual void boost(bool bBoost);
+            virtual void setSelectedPosition(TDCoordinate* newPos);
+            virtual void setSelectedPosition(int x, int y);
+
+            bool buildTower_;
+            TDCoordinate* selectedPos_;
+        private:            
+            virtual void updatePosition();                        
+            float time_;
+            bool moveUpPressed_;
+            bool moveDownPressed_;
+            bool moveLeftPressed_;
+            bool moveRightPressed_;                        
+            bool boostPressed_;            
+    };
+}
+
+#endif /* _TowerDefenseSelecter_H__ */
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseTower.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseTower.cc	(revision 10585)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseTower.cc	(revision 10586)
@@ -22,10 +22,10 @@
         Constructor. Registers and initializes the object.
     */
-    TowerDefenseTower::TowerDefenseTower(Context* context) : Pawn(context)
+    TowerDefenseTower::TowerDefenseTower(Context* context) : Turret(context)
     {
         RegisterObject(TowerDefenseTower);
-
-        this->setCollisionType(WorldEntity::Dynamic);
-        upgrade = 0;
+        game_ =NULL;
+        this->setCollisionType(WorldEntity::None);
+        upgrade = 1;
 
         //this->removeAllEngines();
@@ -38,4 +38,5 @@
     }
 
+    /*
     void TowerDefenseTower::setOrientation(const Quaternion& orientation)
     {
@@ -53,19 +54,20 @@
     {
     }
+    */
 
     bool TowerDefenseTower::upgradeTower()
     {
-        if(upgrade < 3)
+        if(upgrade < 5)
         {
             upgrade++;
             float reloadrate = getReloadRate();
             float reloadwaittime = getReloadWaitTime();
-            this->setDamageMultiplier(5000);
-
+            this->setDamageMultiplier((upgrade+1)*2);
+            //this->setRotationThrust(2*this->getRotationThrust());
             reloadrate = 0.5f*reloadrate;
             reloadwaittime = 0.5f*reloadwaittime;
             setReloadRate(reloadrate);
             setReloadWaitTime(reloadwaittime);
-            this->addTemplate("towerturret1");
+            //this->addTemplate("towerturret1");
         }
         else
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseTower.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseTower.h	(revision 10585)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseTower.h	(revision 10586)
@@ -19,10 +19,10 @@
 
 #include "towerdefense/TowerDefensePrereqs.h"
-#include "worldentities/pawns/SpaceShip.h"
+#include "objects/Turret.h"
 
 
 namespace orxonox
 {
-    class _TowerDefenseExport TowerDefenseTower : public Pawn
+    class _TowerDefenseExport TowerDefenseTower : public Turret
     {
     public:
@@ -37,8 +37,8 @@
 
         // 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);
+        //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();
 
Index: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerTurret.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerTurret.cc	(revision 10585)
+++ 	(revision )
@@ -1,41 +1,0 @@
-//
-//  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/branches/towerdefenseFabien/src/modules/towerdefense/TowerTurret.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerTurret.h	(revision 10585)
+++ 	(revision )
@@ -1,53 +1,0 @@
-//
-//  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
