Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Changes of Nico. Upgrading the towers included.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.