Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10340


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

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

Location:
code/branches/towerdefenseFS15
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/towerdefenseFS15/data/levels/templates/towerdefensetower.oxt

    r10335 r10340  
    2323  </controller>
    2424 
    25  
    26   <attached>
    27        
    28     <!--Turret
    29    
    30     explosionchunks        = 6
    31         reloadrate=10
    32         reloadwaittime=5
    33         collisionType="none"
    34         maxPitch=90
    35         maxYaw=90
    36         maxAttackRadius=1000
    37         minAttackRadius=30
    38         team = 1
    39     >
    40    
    41          <controller>
    42                 <TurretController/>
    43                 </controller>
    44                
    45                
    46         </Turret-->
    47   </attached>
    4825   
    4926
  • code/branches/towerdefenseFS15/src/modules/objects/Turret.cc

    r10262 r10340  
    223223        XMLPortParam(Turret, "maxYaw", setMaxYaw, getMaxYaw, xmlelement, mode);
    224224        XMLPortParam(Turret, "maxPitch", setMaxPitch, getMaxPitch, xmlelement, mode);
     225        XMLPortParam(Turret, "rotationThrust", setRotationThrust, getRotationThrust, xmlelement, mode);
    225226    }
    226227
  • code/branches/towerdefenseFS15/src/modules/objects/Turret.h

    r10262 r10340  
    102102                { return this->maxYaw_; }
    103103
     104            inline void setRotationThrust(float rotationthrust)
     105                { this->rotationThrust_ = rotationthrust; }
     106
     107            inline float getRotationThrust()
     108                { return this->rotationThrust_; }
     109
    104110        protected:
    105111            Vector3 startDir_; //!< The initial facing direction, in local coordinates.
  • 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();
  • code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefense.h

    r10258 r10340  
    5353
    5454        std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > TowerDefenseEnemyvector;
    55         bool towermatrix[16][16];
     55        Model* towerModelMatrix[16][16];
     56        TowerDefenseTower* towerTurretMatrix[16][16];
    5657        void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr);
    5758        virtual void start(); //<! The function is called when the gametype starts
  • code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseEnemy.cc

    r10258 r10340  
    3535    //add credit if enemy is destroyed
    3636    TowerDefenseEnemy::~TowerDefenseEnemy(){
    37         //this->td->addCredit(1);
     37
     38        if (this->isInitialized())
     39        {
     40                getGame()->addCredit(1);
     41        }
    3842    }
    3943
     
    6468        if (getGame() && once_ == false && getHealth() <= 0)
    6569        {
     70                orxout() << "damagefunctionIF" << endl;
    6671            getGame()->addCredit(1);
    6772            once_ = true;
    6873        }
     74        orxout() << "damagefunction" << endl;
     75
    6976    }
     77
    7078/*
    7179    void TowerDefenseEnemy::popWaypoint()
  • code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseTower.cc

    r10335 r10340  
    6666            float reloadrate = getReloadRate();
    6767            float reloadwaittime = getReloadWaitTime();
    68             this->setDamageMultiplier(5000);
    69 
     68            this->setDamageMultiplier((upgrade+1)*2);
     69            this->setRotationThrust(2*this->getRotationThrust());
    7070            reloadrate = 0.5f*reloadrate;
    7171            reloadwaittime = 0.5f*reloadwaittime;
Note: See TracChangeset for help on using the changeset viewer.