Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2014, 3:43:28 PM (10 years ago)
Author:
maxima
Message:

Changes of Nico. Upgrading the towers included.

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

Legend:

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

    r10151 r10158  
    106106        /* Temporary hack to allow the player to add towers */
    107107        this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
     108        this->dedicatedUpgradeTower_ = createConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) );
    108109    }
    109110
     
    130131
    131132        Deathmatch::start();
     133        credits = 5000;
     134        life = 20;
     135        waves = 0;
     136        time=0.0;
    132137
    133138// Waypoints: [1,3] [10,3] [10,11] [13,11]
     
    234239    }
    235240
     241    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.";
     248            return;
     249        }
     250
     251        if (towermatrix [x][y] == NULL)
     252        {
     253            orxout() << "no tower on this position" << endl;
     254            return;
     255        }
     256
     257        else
     258        {
     259                (towermatrix [x][y])->upgradeTower();
     260        }
     261    }
    236262
    237263
     
    287313    {
    288314        return ((this->stats_->getCredit()) >= towerCost);
     315    }
     316
     317    bool TowerDefense::hasEnoughCreditForUpgrade()
     318    {
     319        return true;
    289320    }
    290321
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h

    r10151 r10158  
    7878        void addTower(int x, int y);
    7979
     80        void upgradeTower(int x, int y);
    8081        /* Part of a temporary hack to allow the player to add towers */
    8182        ConsoleCommand* dedicatedAddTower_;
     83        ConsoleCommand* dedicatedUpgradeTower_;
    8284
    8385        //TODO: void spawnNewWave()
     
    9496        TowerDefensePlayerStats *stats_;
    9597        bool hasEnoughCreditForTower(TowerCost towerCost);
     98        bool hasEnoughCreditForUpgrade();
    9699
    97100        std::vector<TowerTurret*> towers_;
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc

    r10151 r10158  
    4242        SUPER(TowerDefenseEnemy, tick, dt);
    4343
     44        //ArtificialController* controller = (ArtificialController*)this->getController();
     45        Vector3 ship = this->getRVWorldPosition();
     46        Vector3* endpoint = new Vector3(500, 700, 150);
     47
     48        float distance = ship.distance(*endpoint);
     49
     50        //orxout() << "distance" << distance << endl;
     51        if(distance <50){
     52                orxout() << "ENEMY KILLED!!!!" << endl;
     53                this->destroy(); }
    4454    }
    4555
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefensePlayerStats.h

    r10142 r10158  
    4444    typedef enum _TowerCosts {
    4545        // Set to 0 for debug...
    46         TDDefaultTowerCost = 20
     46        TDDefaultTowerCost = 20 ,
     47        TDDefaultUpgradeCost = 15
    4748    } TowerCost;
    4849
     
    6768            { waveNumber_++; }
    6869
     70        inline void upgradeTower(int upgradecost)
     71                { credit_ -= upgradecost;}
     72
     73
     74
    6975    private:
    7076        int credit_;
    7177        int waveNumber_;
     78        int upgradecost;
    7279        //int baseHealth_;
    7380    };
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseTower.cc

    r10142 r10158  
    2727
    2828        this->setCollisionType(WorldEntity::Dynamic);
     29        upgrade = 0;
    2930
    3031        //this->removeAllEngines();
     
    6061        //orxout() << "rotateRoll" << ++roll << endl;
    6162    }
     63
     64    bool TowerDefenseTower::upgradeTower()
     65       {
     66        if(upgrade < 3)
     67        {
     68                upgrade++;
     69                float reloadrate = getReloadRate();
     70                float reloadwaittime = getReloadWaitTime();
     71                this->setDamageMultiplier(5000);
     72
     73                reloadrate = 0.5*reloadrate;
     74                reloadwaittime = 0.5*reloadwaittime;
     75                setReloadRate(reloadrate);
     76                setReloadWaitTime(reloadwaittime);
     77                this->addTemplate("towerturret1");
     78        }
     79        else
     80        {
     81                orxout() << "Tower fully upgraded" << endl;
     82                return false;
     83        }
     84        return true;
     85       }
    6286
    6387    // This function is called whenever a player presses the up or the down key.
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseTower.h

    r10142 r10158  
    4141        virtual void rotatePitch(const Vector2& value);
    4242        virtual void rotateRoll(const Vector2& value);
     43        virtual bool upgradeTower();
     44
    4345
    4446        void setGame(TowerDefense* Towerdefense)
     
    4648    private:
    4749        TowerDefense* game_;
     50        int upgrade;
    4851    };
    4952}
Note: See TracChangeset for help on using the changeset viewer.