Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2014, 4:27:06 PM (10 years ago)
Author:
maxima
Message:

Changes of Hannes. Upgrading towers does not work yet.

Location:
code/branches/towerdefenseHS14/src/modules/towerdefense
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc

    r10158 r10159  
    102102        this->setHUDTemplate("TowerDefenseHUD");
    103103
    104         this->stats_ = new TowerDefensePlayerStats();
     104        //this->stats_ = new TowerDefensePlayerStats();
    105105
    106106        /* Temporary hack to allow the player to add towers */
     
    131131
    132132        Deathmatch::start();
    133         credits = 5000;
     133        /*credits = 5000;
    134134        life = 20;
    135135        waves = 0;
    136         time=0.0;
     136        time=0.0;*/
    137137
    138138// Waypoints: [1,3] [10,3] [10,11] [13,11]
     
    154154
    155155
    156         credits = 5000;
    157         life = 20;
    158         waves = 0;
     156        this->setCredit(200);
     157        this->setLifes(10);
     158        this->setWaveNumber(0);
    159159        time=0.0;
    160160
     
    236236        Deathmatch::end();
    237237
    238         ChatManager::message("Match is over");
     238        ChatManager::message("Match is over! Gameover!");
    239239    }
    240240
    241241    void TowerDefense::upgradeTower(int x,int y)
    242     {
    243         const TowerCost upgraeCost = TDDefaultUpgradeCost;
    244 
    245         if (!this->hasEnoughCreditForTower(upgraeCost))
    246         {
    247             orxout() << "not enough credit: " << (this->stats_->getCredit()) << " available, " << TDDefaultTowerCost << " needed.";
     242    {/*
     243        const TowerCost upgradeCost = TDDefaultUpgradeCost;
     244
     245        if (!this->hasEnoughCreditForTower(upgradeCost))
     246        {
     247            orxout() << "not enough credit: " << (this->getCredit()) << " available, " << upgradeCost << " needed.";
    248248            return;
    249249        }
     
    258258        {
    259259                (towermatrix [x][y])->upgradeTower();
    260         }
     260        }*/
    261261    }
    262262
     
    264264    void TowerDefense::addTower(int x, int y)
    265265    {
    266         const TowerCost towerCost = TDDefaultTowerCost;
     266        const int towerCost = 20;
    267267
    268268        if (!this->hasEnoughCreditForTower(towerCost))
    269269        {
    270             orxout() << "not enough credit: " << (this->stats_->getCredit()) << " available, " << TDDefaultTowerCost << " needed.";
     270            orxout() << "not enough credit: " << (this->getCredit()) << " available, " << towerCost << " needed.";
    271271            return;
    272272        }
     
    278278        }
    279279
    280 
     280/*
    281281        unsigned int width = this->center_->getWidth();
    282282        unsigned int height = this->center_->getHeight();
    283 
     283*/
    284284
    285285        int tileScale = (int) this->center_->getTileScale();
     
    297297
    298298       //Reduce credit
    299         this->stats_->buyTower(towerCost);
    300 
    301         orxout() << "Credit: " << this->stats_->getCredit() << endl;
     299        this->buyTower(towerCost);
     300
     301        towermatrix [x][y]=true;
     302
    302303
    303304  //    Create tower
     
    307308        towernew->setGame(this);
    308309
    309         towermatrix[x][y]=true;
    310     }
    311 
    312     bool TowerDefense::hasEnoughCreditForTower(TowerCost towerCost)
    313     {
    314         return ((this->stats_->getCredit()) >= towerCost);
     310    }
     311
     312    bool TowerDefense::hasEnoughCreditForTower(int towerCost)
     313    {
     314        return ((this->getCredit()) >= towerCost);
    315315    }
    316316
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h

    r10158 r10159  
    6262        //virtual void playerEntered(PlayerInfo* player);
    6363        //virtual bool playerLeft(PlayerInfo* player);
     64        //Player Stats (set,get, reduce)
     65        int getCredit(){        return this->credit_;   }
     66        int getLifes(){         return this->lifes_;    }
     67        int getWaveNumber(){    return this->waves_;    }
     68        void setCredit(int credit){ credit_ = credit; }
     69        void setLifes(int lifes){ lifes_ = lifes; }
     70        void setWaveNumber(int wavenumber){waves_=wavenumber;   }
     71        void buyTower(int cost){ credit_ -= cost;}
     72        void addCredit(int credit) {    credit_+=credit;        }
     73        void nextwave(){ waves_++;}
     74        int reduceLifes(int NumberofLifes){     return lifes_-=NumberofLifes;   }
    6475
    65         int credits;
    66         int life;
    67         int waves;
    6876        //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
    6977        //virtual void playerScored(PlayerInfo* player, int score);
     
    92100        float time;
    93101        float time2;
     102        int credit_;
     103        int waves_;
     104        int lifes_;
    94105
    95106        /* handles stats */
    96         TowerDefensePlayerStats *stats_;
    97         bool hasEnoughCreditForTower(TowerCost towerCost);
     107        bool hasEnoughCreditForTower(int towerCost);
    98108        bool hasEnoughCreditForUpgrade();
    99109
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc

    r10158 r10159  
    2929
    3030        this->setCollisionType(WorldEntity::Dynamic);
     31        this->td = orxonox_cast<TowerDefense*>(this->getGametype().get());
     32        once_ = false;
    3133
    3234    }
     35
     36    TowerDefenseEnemy::~TowerDefenseEnemy(){this->td->addCredit(20);}
    3337
    3438    void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord)
     
    4953
    5054        //orxout() << "distance" << distance << endl;
    51         if(distance <50){
     55        if(distance < 50 && once_ == false){
     56                this->td->reduceLifes(1);
     57                once_=true;
    5258                orxout() << "ENEMY KILLED!!!!" << endl;
    53                 this->destroy(); }
     59                this->td->buyTower(20);
     60                if (this->td->getLifes()==0)
     61                {
     62                    this->td->end();
     63                }
     64
     65        }
    5466    }
    5567
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.h

    r10132 r10159  
    2323#include "util/Output.h"
    2424#include "controllers/ArtificialController.h"
     25#include "TowerDefense.h"
    2526
    2627namespace orxonox
     
    3536
    3637                TowerDefenseEnemy(Context* context);
    37         virtual ~TowerDefenseEnemy() {};
     38        virtual ~TowerDefenseEnemy();
    3839
    3940        //health gibt es unter: health_
     
    4748        private:
    4849
     50        TowerDefense* td;
     51        bool once_;
    4952        std::vector<TDCoordinate*> Waypointsvector_;
    5053
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseHUDController.cc

    r10140 r10159  
    3939    {
    4040        RegisterObject(TowerDefenseHUDController);
     41        this->td = 0;
    4142    }
    4243
     
    4950    {
    5051        SUPER(TowerDefenseHUDController, tick, dt);
     52        const std::string& lifes = multi_cast<std::string>(this->td->getLifes());
     53        const std::string& credits = multi_cast<std::string>(this->td->getCredit());
     54        const std::string& waves = multi_cast<std::string>(this->td->getWaveNumber());
    5155
    5256        if(showlives == true)
    53           this->setCaption(multi_cast<std::string>(this->td->life));
     57          this->setCaption(multi_cast<std::string>(lifes));
    5458        else if(showcredits == true)
    55           this->setCaption(multi_cast<std::string>(this->td->credits));
     59          this->setCaption(multi_cast<std::string>(credits));
    5660        else if(showwaves == true)
    57           this->setCaption(multi_cast<std::string>(this->td->waves));
     61          this->setCaption(multi_cast<std::string>(waves));
    5862
    5963
     
    7478            SUPER(TowerDefenseHUDController, changedOwner);
    7579
    76             td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype().get());
    77 
     80            if (this->getOwner() && this->getOwner()->getGametype())
     81                    {
     82                        this->td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype().get());
     83                    }
     84                    else
     85                    {
     86                        this->td = 0;
     87                    }
     88                }
    7889            /*if (this->getOwner() != NULL && this->getOwner()->getGametype())
    7990            {
     
    8697        }
    8798
    88 }
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseHUDController.h

    r10140 r10159  
    3939
    4040#include "towerdefense/TowerDefensePrereqs.h"
    41 
     41#include "TowerDefensePlayerStats.h"
    4242#include "tools/interfaces/Tickable.h"
    4343#include "overlays/OverlayText.h"
     
    7373    private:
    7474        TowerDefense* td;
    75 
    7675        bool showcredits;
    7776        bool showlives;
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.cc

    r9272 r10159  
    2525 *      ...
    2626 */
    27 
     27/*
    2828#include "TowerDefensePlayerStats.h"
    2929
     
    3131{
    3232    const int kDefaultCredit = 200;
    33 
     33    const int kDefaultLifes=20;
    3434    TowerDefensePlayerStats::TowerDefensePlayerStats()
    3535    {
    3636        this->credit_ = kDefaultCredit;
    3737        this->waveNumber_ = 0;
     38        this->lifes_=kDefaultLifes;
    3839    }
    39     /*
     40
    4041    TowerDefensePlayerStats::~TowerDefensePlayerStats()
    4142    {
    4243    }
    43     */
     44
    4445}
     46*/
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.h

    r10158 r10159  
    6868            { waveNumber_++; }
    6969
     70        inline int getLifes()
     71                {return lifes_; }
     72
     73        inline void reduceLifes(int NumberofLifes)
     74        {lifes_-=NumberofLifes; }
     75
    7076        inline void upgradeTower(int upgradecost)
    7177                { credit_ -= upgradecost;}
     
    7783        int waveNumber_;
    7884        int upgradecost;
     85        int lifes_;
    7986        //int baseHealth_;
    8087    };
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePrereqs.h

    r10142 r10159  
    6666{
    6767    class TowerDefense;
     68
    6869    class TowerDefenseTower;
     70
    6971    class TowerDefenseCenterpoint;
    7072    class TowerDefenseHUDController;
     
    7375    class TDCoordinate;
    7476    class TowerTurret;
     77    class TowerDefenseTower;
    7578}
    7679
Note: See TracChangeset for help on using the changeset viewer.