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/src/modules/towerdefense
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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 */
Note: See TracChangeset for help on using the changeset viewer.