Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 16, 2015, 4:24:41 PM (10 years ago)
Author:
erbj
Message:

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

Location:
code/branches/towerdefenseFS15
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/towerdefenseFS15/data/levels/towerDefense.oxw

    r10335 r10368  
    2929  <Pawn team=1>
    3030    <camerapositions>
    31       <CameraPosition position="-2000,0,1500"/>
     31      <CameraPosition position="0,0,1500"/>
    3232    </camerapositions>
    3333  </Pawn>
     
    5959
    6060    <!-- Spawns the camera, attached to a crate -->
    61     <SpawnPoint team=1 position="2000,0,0" pawndesign=centerpointmark />
     61    <SpawnPoint team=1 position="0,0,0" pawndesign=centerpointmark />
    6262    <!--TeamSpawnPoint team=1 position="-7,7,4" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff /-->
    6363
  • code/branches/towerdefenseFS15/src/modules/objects/controllers/TurretController.cc

    r10262 r10368  
    104104        {
    105105            Pawn* entity = orxonox_cast<Pawn*>(*it);
    106             if (!entity || FormationController::sameTeam(this->getControllableEntity(), entity, this->getGametype()))
     106            if (!entity || FormationController::sameTeam(turret, entity, this->getGametype()))
    107107                continue;
    108108            tempScore = turret->isInRange(entity);
     
    196196            if(this->isLookingAtTargetNew(Degree(5).valueRadians()))
    197197            {
     198                orxout() << target_->getIdentifier()->getName() << " / " << target_->getWorldPosition() << " / " << target_->getHealth() << " / " << target_->getTeam() << " / " << this->getTeam() << " / " << turret->getTeam() << endl;
     199                if (target_->getController())
     200                        orxout() << target_->getController()->getIdentifier()->getName() << " / " << target_->getController()->getTeam() << endl;
    198201                this->getControllableEntity()->fire(0);
    199202            }
  • code/branches/towerdefenseFS15/src/modules/towerdefense/CMakeLists.txt

    r10319 r10368  
    77  TDCoordinate.cc
    88  TowerDefenseEnemy.cc
     9 # TowerDefenseSelecter.cc
    910
    1011)
  • code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.cc

    r10351 r10368  
    9898    RegisterUnloadableClass(TowerDefense);
    9999
    100     TowerDefense::TowerDefense(Context* context) : Deathmatch(context)
     100    TowerDefense::TowerDefense(Context* context) : TeamDeathmatch(context)
    101101    {
    102102        RegisterObject(TowerDefense);
     
    108108        }*/
    109109
     110        selectedPos = new TDCoordinate(0,0);
     111//        TowerDefenseSelecter Selecter = new TowerDefenseSelecter();
    110112
    111113
    112114        this->setHUDTemplate("TowerDefenseHUD");
     115        this->nextwaveTimer_.setTimer(10, false, createExecutor(createFunctor(&TowerDefense::nextwave, this)));
     116        this->nextwaveTimer_.stopTimer();
     117        this->waves_ = 0;
     118        this->time = 0;
     119        this->credit_ = 0;
     120        this->lifes_ = 0;
    113121
    114122        //this->stats_ = new TowerDefensePlayerStats();
     
    138146    {
    139147
    140         Deathmatch::start();
     148        TeamDeathmatch::start();
    141149
    142150// Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path
     
    220228    {
    221229
    222         Deathmatch::end();
     230        TeamDeathmatch::end();
    223231        ChatManager::message("Match is over! Gameover!");
    224232
     
    330338        std::vector<TDCoordinate*> path;
    331339        path.push_back(coord1);
    332         if(time>1 && TowerDefenseEnemyvector.size() < 30)
     340        if(time>=TowerDefenseEnemyvector.size() && TowerDefenseEnemyvector.size() < 30)
    333341        {
    334342            //adds different types of enemys depending on the WaveNumber
    335343            addTowerDefenseEnemy(path, this->getWaveNumber() % 3 +1 );
    336             time = time-1;
    337344        }
    338345
     
    359366            }
    360367        }
     368
    361369        //goes thorugh vector to see if an enemy is still alive. if not next wave is launched
    362370        int count= 0;
     
    369377        }
    370378
     379        if (count == 0 && !this->nextwaveTimer_.isActive())
     380            this->nextwaveTimer_.startTimer();
     381
     382/*            time2 +=dt;
    371383        if(count== 0)
    372384        {
    373             time2 +=dt;
    374385            if(time2 > 10)
    375386            {
     
    380391            }
    381392        }
    382 
     393*/
    383394
    384395    }
     
    425436    void TowerDefense::playerEntered(PlayerInfo* player)
    426437    {
    427         Deathmatch::playerEntered(player);
     438        TeamDeathmatch::playerEntered(player);
    428439
    429440        const std::string& message = player->getName() + " entered the game";
     
    433444    bool TowerDefense::playerLeft(PlayerInfo* player)
    434445    {
    435         bool valid_player = Deathmatch::playerLeft(player);
     446        bool valid_player = TeamDeathmatch::playerLeft(player);
    436447
    437448        if (valid_player)
     
    463474        }
    464475
    465         Deathmatch::pawnKilled(victim, killer);
     476        TeamDeathmatch::pawnKilled(victim, killer);
    466477    }
    467478
  • code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h

    r10351 r10368  
    3939#include "TDCoordinate.h"
    4040#include "towerdefense/TowerDefensePrereqs.h"
    41 #include "gametypes/Deathmatch.h"
     41#include "gametypes/TeamDeathmatch.h"
    4242#include "TowerDefenseEnemy.h"
    4343#include "util/Output.h"
     
    4646namespace orxonox
    4747{
    48     class _TowerDefenseExport TowerDefense : public Deathmatch
     48    class _TowerDefenseExport TowerDefense : public TeamDeathmatch
    4949    {
    5050    public:
     
    7070        void buyTower(int cost){ credit_ -= cost;}
    7171        void addCredit(int credit) { credit_+=credit; }
    72         void nextwave(){ waves_++;}
     72        void nextwave(){ TowerDefenseEnemyvector.clear(); waves_++; time=0;}
    7373        int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; }
     74        TDCoordinate* selectedPos;
    7475
    7576        //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
     
    9596        TowerDefenseCenterpoint *center_;
    9697        float time;
    97         float time2;
     98//        float time2;
    9899        int credit_;
    99100        int waves_;
    100101        int lifes_;
     102        Timer nextwaveTimer_;
    101103
    102104        /* handles stats */
  • code/branches/towerdefenseFS15/src/orxonox/controllers/FormationController.cc

    r10335 r10368  
    987987        }
    988988
    989         TeamDeathmatch* tdm = orxonox_cast<TeamDeathmatch*>(gametype);
     989        TeamGametype* tdm = orxonox_cast<TeamGametype*>(gametype);
    990990        if (tdm)
    991991        {
     
    995995            if (entity2->getPlayer())
    996996                team2 = tdm->getTeam(entity2->getPlayer());
    997         }
    998 
    999         Mission* miss = orxonox_cast<Mission*>(gametype);
    1000         if (miss)
    1001         {
    1002             if (entity1->getPlayer())
    1003                 team1 = miss->getTeam(entity1->getPlayer());
    1004 
    1005             if (entity2->getPlayer())
    1006                 team2 = miss->getTeam(entity2->getPlayer());
    1007997        }
    1008998
Note: See TracChangeset for help on using the changeset viewer.