Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 2, 2015, 3:57:34 PM (10 years ago)
Author:
erbj
Message:

Tower upgrade now implemented and towers are now saved in the towerTurretMatrix and the Models in the towerModelMatrix

File:
1 edited

Legend:

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

    r10335 r10340  
    102102        }*/
    103103
     104
     105
    104106        this->setHUDTemplate("TowerDefenseHUD");
    105107
     
    136138        for (int i=0; i < 16 ; i++){
    137139            for (int j = 0; j< 16 ; j++){
    138                 towermatrix[i][j] = false;
    139             }
    140         }
     140                towerModelMatrix[i][j] = NULL;
     141                towerTurretMatrix[i][j] = NULL;
     142            }
     143        }
     144
     145        Model* dummyModel = new Model(this->center_->getContext());
    141146
    142147        //the path of the spacehips has to be blocked, so that no towers can be build there
    143148        for (int k=0; k<3; k++)
    144             towermatrix[1][k]=true;
     149            towerModelMatrix[1][k]=dummyModel;
    145150        for (int l=1; l<11; l++)
    146             towermatrix[l][3]=true;
     151                towerModelMatrix[l][3]=dummyModel;
    147152        for (int m=3; m<12; m++)
    148             towermatrix[10][m]=true;
     153                towerModelMatrix[10][m]=dummyModel;
    149154        for (int n=10; n<14; n++)
    150             towermatrix[n][11]=true;
     155                towerModelMatrix[n][11]=dummyModel;
    151156        for (int o=13; o<16; o++)
    152             towermatrix[13][o]=true;
     157                towerModelMatrix[13][o]=dummyModel;
     158
    153159
    154160        //set initial credits, lifes and WaveNumber
     
    158164        time=0.0;
    159165
     166        /*
    160167        //adds initial towers
    161         /*
    162168        for (int i=0; i <7; i++){
    163169            addTower(i+3,4);
    164170        }
    165         */
     171                */
    166172    }
    167173
     
    216222    //not working yet
    217223    void TowerDefense::upgradeTower(int x,int y)
    218     {/*
     224    {
    219225        const int upgradeCost = 20;
    220226
     
    225231        }
    226232
    227         if (towermatrix [x][y] == NULL)
     233
     234        Model* dummyModel2 = new Model(this->center_->getContext());
     235
     236        if (towerModelMatrix [x][y] == NULL || (towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource())
    228237        {
    229238            orxout() << "no tower on this position" << endl;
     
    233242        else
    234243        {
    235             (towermatrix [x][y])->upgradeTower();
    236         }*/
     244            (towerTurretMatrix [x][y])->upgradeTower();
     245            this->buyTower(upgradeCost);
     246        }
    237247    }
    238248
     
    251261        }
    252262
    253         if (towermatrix [x][y]==true)
     263        if (towerModelMatrix [x][y]!=NULL)
    254264        {
    255265            orxout() << "not possible to put tower here!!" << endl;
     
    273283        orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
    274284
    275        //Reduce credit
    276         this->buyTower(towerCost);
    277         towermatrix [x][y]=true;
     285
    278286
    279287        //Create Model
     
    290298        towernew->setGame(this);
    291299        towernew->setTeam(1);
     300
     301        //Reduce credit
     302         this->buyTower(towerCost);
     303         towerModelMatrix [x][y]= newtowermodel;
     304         towerTurretMatrix [x][y]= towernew;
    292305    }
    293306
     
    325338            if(TowerDefenseEnemyvector.at(i) != NULL && TowerDefenseEnemyvector.at(i)->isAlive())
    326339            {
    327                 //destroys enemys at the end of teh path and reduces the life by 1. no credits gifted
     340                //destroys enemys at the end of the path and reduces the life by 1. no credits gifted
    328341
    329342                Vector3 ship = TowerDefenseEnemyvector.at(i)->getRVWorldPosition();
Note: See TracChangeset for help on using the changeset viewer.