Index: code/branches/towerdefenseHS14/data/levels/includes/weaponSettingsTurret1.oxi
===================================================================
--- code/branches/towerdefenseHS14/data/levels/includes/weaponSettingsTurret1.oxi	(revision 10158)
+++ code/branches/towerdefenseHS14/data/levels/includes/weaponSettingsTurret1.oxi	(revision 10158)
@@ -0,0 +1,22 @@
+    <weaponslots>
+      <WeaponSlot position="0,0,0" />
+    </weaponslots>
+    <weaponsets>
+      <WeaponSet firemode=0 />
+    </weaponsets>
+    <weapons>
+      <WeaponPack>
+        <links>
+          <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+        </links>
+        <Weapon>
+          <!-- <attached>
+            <Model mesh="sphere.mesh" position="1.7,1.7,-24.5" scale=0.6 />
+          </attached> -->
+          <HsW01 mode=0 munitionpershot=0 delay=0 damage=20 material="Flares/point_lensflare" muzzleoffset="1.7, 1.7,-30" />
+          <HsW01 mode=0 munitionpershot=0 delay=0 damage=20 material="Flares/point_lensflare" muzzleoffset="1.7, -1.7,-30" />
+          <HsW01 mode=0 munitionpershot=0 delay=0 damage=20 material="Flares/point_lensflare" muzzleoffset="-1.7, 1.7,-30" />
+          <HsW01 mode=0 munitionpershot=0 delay=0 damage=20 material="Flares/point_lensflare" muzzleoffset="-1.7, -1.7,-30" />
+        </Weapon>
+      </WeaponPack>
+    </weapons>
Index: code/branches/towerdefenseHS14/data/levels/templates/tower.oxt
===================================================================
--- code/branches/towerdefenseHS14/data/levels/templates/tower.oxt	(revision 10151)
+++ code/branches/towerdefenseHS14/data/levels/templates/tower.oxt	(revision 10158)
@@ -47,6 +47,6 @@
    explosionchunks        = 6
 
-   reloadrate          = 3
-   reloadwaittime      = 1
+   reloadrate          = 10
+   reloadwaittime      = 5
 
    collisionType     = "dynamic"
@@ -59,5 +59,5 @@
     <Model position="0,0,0" scale=45 mesh="Tower.mesh" />
 
-    <Turret collisionType="dynamic" position="0,0,10" direction="0,0,1" pitch="0" yaw="0" roll="0" angularDamping=0.999999 mass=100 maxPitch=90 maxYaw=90 maxAttackRadius=1000 minAttackRadius=30>
+    <Turret reloadrate=10 reloadwaittime=5 collisionType="dynamic" position="0,0,10" direction="0,0,1" pitch="0" yaw="0" roll="0" angularDamping=0.999999 mass=100 maxPitch=90 maxYaw=90 maxAttackRadius=1000 minAttackRadius=30>
 
       <controller>
@@ -83,2 +83,46 @@
   </TowerDefenseTower>
 </Template>
+
+
+
+<Template name=towerturret1>
+  <TowerDefenseTower
+
+
+   explosionchunks        = 6
+
+   reloadrate          = 10
+   reloadwaittime      = 5
+
+   collisionType     = "dynamic"
+   team = 1
+
+
+  >
+  <attached>
+
+
+    <Turret reloadrate=10 reloadwaittime=5 collisionType="dynamic" position="0,0,10" direction="0,0,1" pitch="0" yaw="0" roll="0" angularDamping=0.999999 mass=100 maxPitch=90 maxYaw=90 maxAttackRadius=1000 minAttackRadius=30>
+
+      <controller>
+        <TurretController/>
+      </controller>
+      <?lua
+        include("../includes/weaponSettingsTurret1.oxi")
+      ?>
+    </Turret>
+    
+  </attached>
+    
+
+
+
+    <!--collisionShapes>
+
+    </collisionShapes-->
+
+<?lua
+  include("../includes/towerWeaponSettings.oxi")
+?>
+  </TowerDefenseTower>
+</Template>
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc	(revision 10151)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc	(revision 10158)
@@ -106,4 +106,5 @@
         /* Temporary hack to allow the player to add towers */
         this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
+	this->dedicatedUpgradeTower_ = createConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) );
     }
 
@@ -130,4 +131,8 @@
 
         Deathmatch::start();
+        credits = 5000;
+        life = 20;
+        waves = 0;
+        time=0.0;
 
 // Waypoints: [1,3] [10,3] [10,11] [13,11]
@@ -234,4 +239,25 @@
     }
 
+    void TowerDefense::upgradeTower(int x,int y)
+    {
+    	const TowerCost upgraeCost = TDDefaultUpgradeCost;
+
+        if (!this->hasEnoughCreditForTower(upgraeCost))
+        {
+            orxout() << "not enough credit: " << (this->stats_->getCredit()) << " available, " << TDDefaultTowerCost << " needed.";
+            return;
+        }
+
+        if (towermatrix [x][y] == NULL)
+        {
+            orxout() << "no tower on this position" << endl;
+            return;
+        }
+
+        else
+        {
+        	(towermatrix [x][y])->upgradeTower();
+        }
+    }
 
 
@@ -287,4 +313,9 @@
     {
         return ((this->stats_->getCredit()) >= towerCost);
+    }
+
+    bool TowerDefense::hasEnoughCreditForUpgrade()
+    {
+    	return true;
     }
 
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h	(revision 10151)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h	(revision 10158)
@@ -78,6 +78,8 @@
         void addTower(int x, int y);
 
+        void upgradeTower(int x, int y);
         /* Part of a temporary hack to allow the player to add towers */
         ConsoleCommand* dedicatedAddTower_;
+        ConsoleCommand* dedicatedUpgradeTower_;
 
         //TODO: void spawnNewWave()
@@ -94,4 +96,5 @@
         TowerDefensePlayerStats *stats_;
         bool hasEnoughCreditForTower(TowerCost towerCost);
+        bool hasEnoughCreditForUpgrade();
 
         std::vector<TowerTurret*> towers_;
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc	(revision 10151)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc	(revision 10158)
@@ -42,4 +42,14 @@
         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){
+        	orxout() << "ENEMY KILLED!!!!" << endl;
+        	this->destroy(); }
     }
 
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.h
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.h	(revision 10151)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.h	(revision 10158)
@@ -44,5 +44,6 @@
     typedef enum _TowerCosts {
         // Set to 0 for debug...
-        TDDefaultTowerCost = 20
+        TDDefaultTowerCost = 20 ,
+        TDDefaultUpgradeCost = 15
     } TowerCost;
 
@@ -67,7 +68,13 @@
             { waveNumber_++; }
 
+        inline void upgradeTower(int upgradecost)
+        	{ credit_ -= upgradecost;}
+
+
+
     private:
         int credit_;
         int waveNumber_;
+        int upgradecost;
         //int baseHealth_;
     };
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseTower.cc
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseTower.cc	(revision 10151)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseTower.cc	(revision 10158)
@@ -27,4 +27,5 @@
 
         this->setCollisionType(WorldEntity::Dynamic);
+        upgrade = 0;
 
         //this->removeAllEngines();
@@ -60,4 +61,27 @@
         //orxout() << "rotateRoll" << ++roll << endl;
     }
+
+    bool TowerDefenseTower::upgradeTower()
+       {
+       	if(upgrade < 3)
+       	{
+       		upgrade++;
+       		float reloadrate = getReloadRate();
+       		float reloadwaittime = getReloadWaitTime();
+       		this->setDamageMultiplier(5000);
+
+       		reloadrate = 0.5*reloadrate;
+       		reloadwaittime = 0.5*reloadwaittime;
+       		setReloadRate(reloadrate);
+       		setReloadWaitTime(reloadwaittime);
+       		this->addTemplate("towerturret1");
+       	}
+       	else
+       	{
+       		orxout() << "Tower fully upgraded" << endl;
+       		return false;
+       	}
+       	return true;
+       }
 
     // This function is called whenever a player presses the up or the down key.
Index: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseTower.h
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseTower.h	(revision 10151)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseTower.h	(revision 10158)
@@ -41,4 +41,6 @@
         virtual void rotatePitch(const Vector2& value);
         virtual void rotateRoll(const Vector2& value);
+        virtual bool upgradeTower();
+
 
         void setGame(TowerDefense* Towerdefense)
@@ -46,4 +48,5 @@
     private:
         TowerDefense* game_;
+        int upgrade;
     };
 }
