Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TDEnemy.h
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TDEnemy.h	(revision 10159)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TDEnemy.h	(revision 10172)
@@ -5,5 +5,5 @@
  *      Author: weigeltm
  */
-
+/*
 #ifndef TDENEMY_H_
 #define TDENEMY_H_
@@ -24,3 +24,3 @@
 
 
-#endif /* TDENEMY_H_ */
+#endif  TDENEMY_H_ */
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc	(revision 10159)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc	(revision 10172)
@@ -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 "TowerDefenseTower.h"
-#include "TowerTurret.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,4 +96,10 @@
     {
         RegisterObject(TowerDefense);
+/*
+        for (int i=0; i < 16 ; i++){
+        	for (int j = 0; j< 16 ; j++){
+        		towermatrix[i][j] = NULL;
+        	}
+        }*/
 
         this->setHUDTemplate("TowerDefenseHUD");
@@ -104,5 +107,5 @@
         //this->stats_ = new TowerDefensePlayerStats();
 
-        /* Temporary hack to allow the player to add towers */
+        /* 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) ) );
@@ -128,13 +131,8 @@
     void TowerDefense::start()
     {
-    	orxout() << "test0" << endl;
 
         Deathmatch::start();
-        /*credits = 5000;
-        life = 20;
-        waves = 0;
-        time=0.0;*/
-
-// Waypoints: [1,3] [10,3] [10,11] [13,11]
+
+// 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++){
@@ -142,4 +140,5 @@
         	}
         }
+
         for (int k=0; k<3; k++)
         	towermatrix[1][k]=true;
@@ -153,33 +152,21 @@
                 towermatrix[13][o]=true;
 
-
+//set initial credits, lifes and WaveNumber
         this->setCredit(200);
-        this->setLifes(10);
+        this->setLifes(50);
         this->setWaveNumber(0);
         time=0.0;
 
- 	const int kInitialTowerCount = 3;
-
-        for (int i = 0; i < kInitialTowerCount; i++)
-        {
-            addTower(i+4,i+5);
-        }
-
-
-
-        //add some TowerDefenseEnemys
-
-
-
-
-
-        //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
-    }
-
+//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());
@@ -190,42 +177,29 @@
 		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); 
-	        break; 
+	    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)));
-        }
-
-
-       /*
-        WaypointController *newController = new WaypointController(en1->getContext());//
-        newController->setAccuracy(3);
-
-        for(int i =0; i < path.size(); ++i)
-        {
-
-            Model *wayPoint = new Model(en1->getContext());
-            wayPoint->setMeshSource("cube.mesh");
-            wayPoint->setPosition(path.at(i)->get3dcoordinate());
-            wayPoint->setScale(0.2);
-            newController->addWaypoint(wayPoint);
-        }*/
+        	{
+            	en1->addWaypoint((path.at(i)));
+        	}
     }
 
@@ -234,12 +208,14 @@
 
     {
+
         Deathmatch::end();
-
         ChatManager::message("Match is over! Gameover!");
-    }
-
+
+    }
+
+    //not working yet
     void TowerDefense::upgradeTower(int x,int y)
     {/*
-    	const TowerCost upgradeCost = TDDefaultUpgradeCost;
+    	const int upgradeCost = 20;
 
         if (!this->hasEnoughCreditForTower(upgradeCost))
@@ -261,5 +237,8 @@
     }
 
-
+    /*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)
     {
@@ -294,18 +273,13 @@
         orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
 
-        
-
        //Reduce credit
         this->buyTower(towerCost);
-
         towermatrix [x][y]=true;
 
-
-  //    Create tower
+        //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);
-
     }
 
@@ -314,4 +288,5 @@
         return ((this->getCredit()) >= towerCost);
     }
+
 
     bool TowerDefense::hasEnoughCreditForUpgrade()
@@ -329,60 +304,54 @@
         std::vector<TDCoordinate*> path;
         path.push_back(coord1);
-
         if(time>1 && TowerDefenseEnemyvector.size() < 30)
         {
-            addTowerDefenseEnemy(path, rand() %3 +1 );
-            time = time-1;
-        }
-
-        Vector3* endpoint = new Vector3(500, 700, 150);
-
-        for(int i =0; i < TowerDefenseEnemyvector.size(); ++i)
-        {
-
-        	//orxout() << TowerDefenseEnemyvector.at(i) << endl;
-        	//continue;
-
-			//ArtificialController* controller = (ArtificialController*)this->getController();
+        	//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())
-			{
-				orxout() << "Variable i: " << i << endl;
-
-				Vector3 ship = TowerDefenseEnemyvector.at(i)->getRVWorldPosition();
-
-				float distance = ship.distance(*endpoint);
-
-				//orxout() << "distance" << distance << endl;
-				if(distance <50){
-				  //	orxout() << "ENEMY KILLED!!!!" << endl;
-				  TowerDefenseEnemyvector.at(i)->destroy();
+				{
+				//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();
+								}
+					}
 				}
 			}
-			else
+			//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)
 			{
-				//TowerDefenseEnemyvector.erase(TowerDefenseEnemyvector.begin() +i);
+				if(TowerDefenseEnemyvector.at(i)!= NULL)
+				{
+					++count;
+				}
 			}
-		}
-
-        int count= 0;
-        for(int i =0; i < TowerDefenseEnemyvector.size(); ++i)
-        {
-        	if(TowerDefenseEnemyvector.at(i)!= NULL)
-        	{
-        		++count;
-        	}
-        }
-
-        if(count== 0)
-        {
-        	time2 +=dt;
-        	if(time2 > 10)
-        	{
-        		TowerDefenseEnemyvector.clear();
-        		time=0;
-        		time2=0;
-        	}
-        }
-
+
+			if(count== 0)
+			{
+				time2 +=dt;
+				if(time2 > 10)
+				{
+					TowerDefenseEnemyvector.clear();
+					this->nextwave();
+					time=0;
+					time2=0;
+				}
+			}
 
 
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h	(revision 10159)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h	(revision 10172)
@@ -42,7 +42,5 @@
 #include "TowerDefenseEnemy.h"
 #include "util/Output.h"
-
-
- #include "TowerDefensePlayerStats.h"
+#include "core/object/WeakPtr.h"
 
 namespace orxonox
@@ -56,5 +54,5 @@
         std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > TowerDefenseEnemyvector;
         bool towermatrix[16][16];
-        void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr); 
+        void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr);
         virtual void start(); //<! The function is called when the gametype starts
         virtual void end();
@@ -108,4 +106,6 @@
         bool hasEnoughCreditForUpgrade();
 
+
+
         std::vector<TowerTurret*> towers_;
     };
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc	(revision 10159)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc	(revision 10172)
@@ -12,5 +12,4 @@
 */
 #include "TowerDefenseEnemy.h"
-
 #include "core/CoreIncludes.h"
 //#include "core/XMLPort.h"
@@ -29,10 +28,12 @@
 
         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;
 
     }
-
-    TowerDefenseEnemy::~TowerDefenseEnemy(){this->td->addCredit(20);}
+    //add credit if enemy is destroyed
+    TowerDefenseEnemy::~TowerDefenseEnemy(){
+    		this->td->addCredit(1);
+    }
 
     void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord)
@@ -45,23 +46,4 @@
     {
         SUPER(TowerDefenseEnemy, tick, dt);
-
-        //ArtificialController* controller = (ArtificialController*)this->getController();
-        Vector3 ship = this->getRVWorldPosition();
-        Vector3* endpoint = new Vector3(500, 700, 150);
-
-        float distance = ship.distance(*endpoint);
-
-        //orxout() << "distance" << distance << endl;
-        if(distance < 50 && once_ == false){
-        	this->td->reduceLifes(1);
-        	once_=true;
-        	orxout() << "ENEMY KILLED!!!!" << endl;
-        	this->td->buyTower(20);
-        	if (this->td->getLifes()==0)
-		{
-		    this->td->end();
-        	}
-
-        }
     }
 
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.h
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.h	(revision 10159)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.h	(revision 10172)
@@ -32,7 +32,5 @@
 	class _TowerDefenseExport TowerDefenseEnemy : public SpaceShip 
 	{
-
 	public:
-
 		TowerDefenseEnemy(Context* context);
         virtual ~TowerDefenseEnemy();
@@ -47,5 +45,4 @@
 
 	private:
-
         TowerDefense* td;
         bool once_;
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseHUDController.cc
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseHUDController.cc	(revision 10159)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseHUDController.cc	(revision 10172)
@@ -52,5 +52,5 @@
         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& waves = multi_cast<std::string>(this->td->getWaveNumber());
+        const std::string& wave = multi_cast<std::string>(this->td->getWaveNumber());
 
         if(showlives == true)
@@ -59,5 +59,5 @@
           this->setCaption(multi_cast<std::string>(credits));
         else if(showwaves == true)
-          this->setCaption(multi_cast<std::string>(waves));
+          this->setCaption(multi_cast<std::string>(wave));
 
 
@@ -87,12 +87,4 @@
                     }
                 }
-            /*if (this->getOwner() != NULL && this->getOwner()->getGametype())
-            {
-                this->owner_ = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype().get());
-            }
-            else
-            {
-                this->owner_ = NULL;
-            }*/
         }
 
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.h
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.h	(revision 10159)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.h	(revision 10172)
@@ -27,10 +27,10 @@
  */
 
- /**
+ /*
     @brief
         This manages the stats of the player. It is used by 'TowerDefense', the gametype
 
     @ingroup TowerDefense
- */
+
 
 
@@ -88,3 +88,3 @@
 }
 
-#endif /* _TowerDefensePlayerStats_H__ */
+#endif  _TowerDefensePlayerStats_H__ */
