[Orxonox-commit 5708] r10368 - in code/branches/towerdefenseFS15: data/levels src/modules/objects/controllers src/modules/towerdefense src/orxonox/controllers

erbj at orxonox.net erbj at orxonox.net
Thu Apr 16 16:24:42 CEST 2015


Author: erbj
Date: 2015-04-16 16:24:41 +0200 (Thu, 16 Apr 2015)
New Revision: 10368

Modified:
   code/branches/towerdefenseFS15/data/levels/towerDefense.oxw
   code/branches/towerdefenseFS15/src/modules/objects/controllers/TurretController.cc
   code/branches/towerdefenseFS15/src/modules/towerdefense/CMakeLists.txt
   code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc
   code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h
   code/branches/towerdefenseFS15/src/orxonox/controllers/FormationController.cc
Log:
added timer in tick function to pause for 10 seconds between waves , trying to solve the problem, that towers are shooting at (0,0,0) (center point). The Problem seems to be in the sameteam function as the turret and the pawn at the position (0,0,0) should have the same team

Modified: code/branches/towerdefenseFS15/data/levels/towerDefense.oxw
===================================================================
--- code/branches/towerdefenseFS15/data/levels/towerDefense.oxw	2015-04-15 20:37:17 UTC (rev 10367)
+++ code/branches/towerdefenseFS15/data/levels/towerDefense.oxw	2015-04-16 14:24:41 UTC (rev 10368)
@@ -28,7 +28,7 @@
 <Template name=centerpointmarkcamera defaults=0>
   <Pawn team=1>
     <camerapositions>
-      <CameraPosition position="-2000,0,1500"/>
+      <CameraPosition position="0,0,1500"/>
     </camerapositions>
   </Pawn>
 </Template>
@@ -58,7 +58,7 @@
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
 
     <!-- Spawns the camera, attached to a crate -->
-    <SpawnPoint team=1 position="2000,0,0" pawndesign=centerpointmark />
+    <SpawnPoint team=1 position="0,0,0" pawndesign=centerpointmark />
     <!--TeamSpawnPoint team=1 position="-7,7,4" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff /-->
 
     <!--SpawnPoint team=1 position="0,0,10" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff  /-->

Modified: code/branches/towerdefenseFS15/src/modules/objects/controllers/TurretController.cc
===================================================================
--- code/branches/towerdefenseFS15/src/modules/objects/controllers/TurretController.cc	2015-04-15 20:37:17 UTC (rev 10367)
+++ code/branches/towerdefenseFS15/src/modules/objects/controllers/TurretController.cc	2015-04-16 14:24:41 UTC (rev 10368)
@@ -103,7 +103,7 @@
         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
         {
             Pawn* entity = orxonox_cast<Pawn*>(*it);
-            if (!entity || FormationController::sameTeam(this->getControllableEntity(), entity, this->getGametype()))
+            if (!entity || FormationController::sameTeam(turret, entity, this->getGametype()))
                 continue;
             tempScore = turret->isInRange(entity);
             if(tempScore != -1.f)
@@ -195,6 +195,9 @@
             turret->aimAtPosition(target_->getWorldPosition());
             if(this->isLookingAtTargetNew(Degree(5).valueRadians()))
             {
+            	orxout() << target_->getIdentifier()->getName() << " / " << target_->getWorldPosition() << " / " << target_->getHealth() << " / " << target_->getTeam() << " / " << this->getTeam() << " / " << turret->getTeam() << endl;
+            	if (target_->getController())
+            		orxout() << target_->getController()->getIdentifier()->getName() << " / " << target_->getController()->getTeam() << endl;
                 this->getControllableEntity()->fire(0);
             }
         }

Modified: code/branches/towerdefenseFS15/src/modules/towerdefense/CMakeLists.txt
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/CMakeLists.txt	2015-04-15 20:37:17 UTC (rev 10367)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/CMakeLists.txt	2015-04-16 14:24:41 UTC (rev 10368)
@@ -6,6 +6,7 @@
   TowerDefensePlayerStats.cc
   TDCoordinate.cc
   TowerDefenseEnemy.cc
+ # TowerDefenseSelecter.cc
 
 )
 

Modified: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc	2015-04-15 20:37:17 UTC (rev 10367)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc	2015-04-16 14:24:41 UTC (rev 10368)
@@ -97,7 +97,7 @@
 
     RegisterUnloadableClass(TowerDefense);
 
-    TowerDefense::TowerDefense(Context* context) : Deathmatch(context)
+    TowerDefense::TowerDefense(Context* context) : TeamDeathmatch(context)
     {
         RegisterObject(TowerDefense);
 /*
@@ -107,9 +107,17 @@
             }
         }*/
 
+        selectedPos = new TDCoordinate(0,0);
+//        TowerDefenseSelecter Selecter = new TowerDefenseSelecter();
 
 
         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();
 
@@ -137,7 +145,7 @@
     void TowerDefense::start()
     {
 
-        Deathmatch::start();
+        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
         for (int i=0; i < 16 ; i++){
@@ -219,7 +227,7 @@
     void TowerDefense::end()
     {
 
-        Deathmatch::end();
+        TeamDeathmatch::end();
         ChatManager::message("Match is over! Gameover!");
 
     }
@@ -329,11 +337,10 @@
         TDCoordinate* coord1 = new TDCoordinate(1,1);
         std::vector<TDCoordinate*> path;
         path.push_back(coord1);
-        if(time>1 && TowerDefenseEnemyvector.size() < 30)
+        if(time>=TowerDefenseEnemyvector.size() && TowerDefenseEnemyvector.size() < 30)
         {
             //adds different types of enemys depending on the WaveNumber
             addTowerDefenseEnemy(path, this->getWaveNumber() % 3 +1 );
-            time = time-1;
         }
 
         Vector3* endpoint = new Vector3(500, 700, 150);
@@ -358,6 +365,7 @@
                 }
             }
         }
+
         //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)
@@ -368,9 +376,12 @@
             }
         }
 
+        if (count == 0 && !this->nextwaveTimer_.isActive())
+            this->nextwaveTimer_.startTimer();
+
+/*            time2 +=dt;
         if(count== 0)
         {
-            time2 +=dt;
             if(time2 > 10)
             {
                 TowerDefenseEnemyvector.clear();
@@ -379,8 +390,8 @@
                 time2=0;
             }
         }
+*/
 
-
     }
 
     // Function to test if we can add waypoints using code only. Doesn't work yet
@@ -424,7 +435,7 @@
     /*
     void TowerDefense::playerEntered(PlayerInfo* player)
     {
-        Deathmatch::playerEntered(player);
+        TeamDeathmatch::playerEntered(player);
 
         const std::string& message = player->getName() + " entered the game";
         ChatManager::message(message);
@@ -432,7 +443,7 @@
 
     bool TowerDefense::playerLeft(PlayerInfo* player)
     {
-        bool valid_player = Deathmatch::playerLeft(player);
+        bool valid_player = TeamDeathmatch::playerLeft(player);
 
         if (valid_player)
         {
@@ -462,7 +473,7 @@
             ChatManager::message(message);
         }
 
-        Deathmatch::pawnKilled(victim, killer);
+        TeamDeathmatch::pawnKilled(victim, killer);
     }
 
     void TowerDefense::playerScored(PlayerInfo* player, int score)

Modified: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h
===================================================================
--- code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h	2015-04-15 20:37:17 UTC (rev 10367)
+++ code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h	2015-04-16 14:24:41 UTC (rev 10368)
@@ -38,14 +38,14 @@
 #define _TowerDefense_H__
 #include "TDCoordinate.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"
 
 namespace orxonox
 {
-    class _TowerDefenseExport TowerDefense : public Deathmatch
+    class _TowerDefenseExport TowerDefense : public TeamDeathmatch
     {
     public:
         TowerDefense(Context* context);
@@ -69,8 +69,9 @@
         void setWaveNumber(int wavenumber){ waves_=wavenumber; }
         void buyTower(int cost){ credit_ -= cost;}
         void addCredit(int credit) { credit_+=credit; }
-        void nextwave(){ waves_++;}
+        void nextwave(){ TowerDefenseEnemyvector.clear(); waves_++; time=0;}
         int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; }
+        TDCoordinate* selectedPos;
 
         //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
         //virtual void playerScored(PlayerInfo* player, int score);
@@ -94,10 +95,11 @@
     private:
         TowerDefenseCenterpoint *center_;
         float time;
-        float time2;
+//        float time2;
         int credit_;
         int waves_;
         int lifes_;
+        Timer nextwaveTimer_;
 
         /* handles stats */
         bool hasEnoughCreditForTower(int towerCost);

Modified: code/branches/towerdefenseFS15/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/towerdefenseFS15/src/orxonox/controllers/FormationController.cc	2015-04-15 20:37:17 UTC (rev 10367)
+++ code/branches/towerdefenseFS15/src/orxonox/controllers/FormationController.cc	2015-04-16 14:24:41 UTC (rev 10368)
@@ -986,7 +986,7 @@
                 team2 = ac->getTeam();
         }
 
-        TeamDeathmatch* tdm = orxonox_cast<TeamDeathmatch*>(gametype);
+        TeamGametype* tdm = orxonox_cast<TeamGametype*>(gametype);
         if (tdm)
         {
             if (entity1->getPlayer())
@@ -996,16 +996,6 @@
                 team2 = tdm->getTeam(entity2->getPlayer());
         }
 
-        Mission* miss = orxonox_cast<Mission*>(gametype);
-        if (miss)
-        {
-            if (entity1->getPlayer())
-                team1 = miss->getTeam(entity1->getPlayer());
-
-            if (entity2->getPlayer())
-                team2 = miss->getTeam(entity2->getPlayer());
-        }
-
         TeamBaseMatchBase* base = 0;
         base = orxonox_cast<TeamBaseMatchBase*>(entity1);
         if (base)




More information about the Orxonox-commit mailing list