Index: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc	(revision 10397)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc	(revision 10406)
@@ -35,5 +35,4 @@
  * pawnKilled() // wird aufgerufen, wenn ein Pawn stirbt (z.B: wenn )
  * playerScored() // kann man aufrufen um dem Spieler Punkte zu vergeben.
- *
  *
  *
@@ -110,6 +109,5 @@
 
         selecter = NULL;
-
-
+        this->player_ = NULL;        
         this->setHUDTemplate("TowerDefenseHUD");
         this->nextwaveTimer_.setTimer(10, false, createExecutor(createFunctor(&TowerDefense::nextwave, this)));
@@ -145,8 +143,22 @@
     void TowerDefense::start()
     {
+        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;
+        }
 
         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
+        // 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++)
         {
@@ -158,5 +170,15 @@
         }
 
-        selecter = new TowerDefenseSelecter(this->center_->getContext());
+        
+
+        if (player_ != NULL)
+        {
+            //this->player_->startControl(selecter);
+        }
+        else
+        {
+            orxout() << "player=NULL" << endl;
+        }
+
 
         Model* dummyModel = new Model(this->center_->getContext());
@@ -219,5 +241,5 @@
         en1->setTeam(2);
         en1->getController();
-        en1->setPosition(path.at(0)->get3dcoordinate());
+        en1->setPosition(path.at(0)->get3dcoordinate());        
         TowerDefenseEnemyvector.push_back(en1);
 
@@ -237,7 +259,35 @@
     }
 
+    void TowerDefense::spawnPlayer(PlayerInfo* player)
+    {
+        assert(player);
+        this->player_ = player;
+
+        if (selecter->getPlayer() == NULL)
+        {
+            this->player_ = player;
+            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)
     {
+        TDCoordinate* coord = new TDCoordinate(x,y);
+        x = coord->GetX();
+        y = coord->GetY();
+        
         const int upgradeCost = 20;
 
@@ -266,8 +316,12 @@
     /*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)
-    {
+    {        
+        TDCoordinate* coord = new TDCoordinate(x,y);
+        x = coord->GetX();
+        y = coord->GetY();
+
         const int towerCost = 20;
 
@@ -291,22 +345,20 @@
         int tileScale = (int) this->center_->getTileScale();
 
-        if (x > 15 || y > 15 || x < 0 || y < 0)
+        /*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;
-
+        }*/
+
+        //orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
+        orxout() << "Will add tower at (" << x << "," << y << ")" << endl;
 
 
         //Create Model
-        Model* newtowermodel = new Model(this->center_->getContext());
-        newtowermodel->setMeshSource("Tower.mesh");
-        newtowermodel->setScale(45);
-        newtowermodel->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 50);
-
-
+        Model* newTowerModel = new Model(this->center_->getContext());
+        newTowerModel->setMeshSource("Tower.mesh");
+        newTowerModel->setScale(45);
+        newTowerModel->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 50);
 
         //Creates tower
@@ -318,7 +370,7 @@
         //Reduce credit
          this->buyTower(towerCost);
-         towerModelMatrix [x][y]= newtowermodel;
+         towerModelMatrix [x][y]= newTowerModel;
          towerTurretMatrix [x][y]= towernew;
-    }
+    }    
 
     bool TowerDefense::hasEnoughCreditForTower(int towerCost)
