Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 4, 2015, 12:18:01 PM (9 years ago)
Author:
landauf
Message:

merged branch towerdefenseFS15

Location:
code/branches/presentationFS15merge
Files:
4 deleted
15 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentationFS15merge

  • code/branches/presentationFS15merge/src/modules/objects/Turret.cc

    r10262 r10615  
    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/presentationFS15merge/src/modules/objects/Turret.h

    r10262 r10615  
    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/presentationFS15merge/src/modules/objects/controllers/TurretController.cc

    r10262 r10615  
    104104        {
    105105            Pawn* entity = orxonox_cast<Pawn*>(*it);
    106             if (!entity || FormationController::sameTeam(this->getControllableEntity(), entity, this->getGametype()))
     106            if (!entity || FormationController::sameTeam(turret, entity, this->getGametype()))
    107107                continue;
    108108            tempScore = turret->isInRange(entity);
     
    196196            if(this->isLookingAtTargetNew(Degree(5).valueRadians()))
    197197            {
     198
    198199                this->getControllableEntity()->fire(0);
    199200            }
  • code/branches/presentationFS15merge/src/modules/tetris/Tetris.h

    r9833 r10615  
    9090            void clearRow(unsigned int row);
    9191
    92 
    9392            PlayerInfo* player_;
    9493
  • code/branches/presentationFS15merge/src/modules/towerdefense/CMakeLists.txt

    r10258 r10615  
    22  TowerDefense.cc
    33  TowerDefenseTower.cc
    4   TowerTurret.cc
    54  TowerDefenseCenterpoint.cc
    65  TowerDefenseHUDController.cc
     
    87  TDCoordinate.cc
    98  TowerDefenseEnemy.cc
    10 
     9  TowerDefenseSelecter.cc
    1110)
    1211
     
    1716    orxonox
    1817    overlays
     18    objects
    1919  SOURCE_FILES ${TOWERDEFENSE_SRC_FILES}
    2020)
  • code/branches/presentationFS15merge/src/modules/towerdefense/TDCoordinate.cc

    r10258 r10615  
    1717    {
    1818        //RegisterObject(TDCoordinate);
    19         x=0;
    20         y=0;
     19        Set(0,0);
    2120
    2221    }
    2322
    2423    TDCoordinate::TDCoordinate(int x, int y)
    25     {
    26         this->x=x;
    27         this->y=y;
     24    {       
     25        Set(x,y);
     26    }
     27
     28    void TDCoordinate::Set(int x, int y)
     29    {       
     30        if (x < 0)
     31        {
     32            _x = 0;
     33        }
     34        else if (x > 15)
     35        {
     36            _x = 15;
     37        }
     38        else
     39        {
     40            _x = x;
     41        }
     42
     43        if (y < 0)
     44        {
     45            _y = 0;
     46        }
     47        else if (y > 15)
     48        {
     49            _y = 15;
     50        }
     51        else
     52        {
     53            _y = y;
     54        }
     55    }
     56
     57    int TDCoordinate::GetX()
     58    {       
     59        return _x;
     60    }
     61
     62    int TDCoordinate::GetY()
     63    {       
     64        return _y;
    2865    }
    2966
     
    3471
    3572        Vector3 *coord = new Vector3();
    36         coord->x= (x-8) * tileScale;
    37         coord->y= (y-8) * tileScale;
     73        coord->x= (_x-8) * tileScale;
     74        coord->y= (_y-8) * tileScale;
    3875        coord->z=100;
    3976
  • code/branches/presentationFS15merge/src/modules/towerdefense/TDCoordinate.h

    r10258 r10615  
    1616    {
    1717        public:
    18             int x;
    19             int y;
     18            TDCoordinate();
     19            TDCoordinate(int x, int y);
     20            virtual ~TDCoordinate() {};
     21            virtual void Set(int x, int y);
     22            virtual int GetX();
     23            virtual int GetY();
     24            virtual Vector3 get3dcoordinate();
    2025
    21             TDCoordinate();
    22 
    23             Vector3 get3dcoordinate();
    24 
    25             virtual ~TDCoordinate() {};
    26 
    27             TDCoordinate(int x, int y);
     26        private:
     27            int _x;
     28            int _y;
    2829    };
    2930
  • code/branches/presentationFS15merge/src/modules/towerdefense/TowerDefense.cc

    r10258 r10615  
    3737 *
    3838 *
    39  *
    4039 *TIPP: Eclipse hilft euch schnell auf bereits vorhanden Funktionen zuzugreifen:
    4140 * einfach "this->" eingeben und kurz warten. Dann tauch eine Liste mit Vorschlägen auf. Wenn ihr jetzt weiter
     
    7776#include "TowerDefenseCenterpoint.h"
    7877//#include "TDCoordinate.h"
    79 #include "TowerTurret.h"
    8078#include "worldentities/SpawnPoint.h"
    8179#include "worldentities/pawns/Pawn.h"
     
    8886/* Part of a temporary hack to allow the player to add towers */
    8987#include "core/command/ConsoleCommand.h"
     88#include <cmath>
     89
    9090
    9191namespace orxonox
    9292{
     93    static const std::string __CC_addTower_name  = "addTower";
     94    static const std::string __CC_upgradeTower_name = "upgradeTower";
     95    static const int upgradeCost = 20;
     96    static const int towerCost = 20;
     97    unsigned int maxspaceships = 30;
     98    int maxspaceshipsstandard = 30;
     99
     100
     101
     102    SetConsoleCommand("TowerDefense", __CC_addTower_name,  &TowerDefense::addTower ).addShortcut().defaultValues(1);
     103    SetConsoleCommand("TowerDefense", __CC_upgradeTower_name, &TowerDefense::upgradeTower).addShortcut().defaultValues(0);
     104
    93105    RegisterUnloadableClass(TowerDefense);
    94106
    95     TowerDefense::TowerDefense(Context* context) : Deathmatch(context)
     107    TowerDefense::TowerDefense(Context* context) : TeamDeathmatch(context)
    96108    {
    97109        RegisterObject(TowerDefense);
     
    103115        }*/
    104116
     117        //Timer for the waves (10 seconds between the waves)
     118        selecter = NULL;
     119        this->player_ = NULL;       
    105120        this->setHUDTemplate("TowerDefenseHUD");
    106 
    107         //this->stats_ = new TowerDefensePlayerStats();
    108 
    109         /* Temporary hack to allow the player to add towers and upgrade them */
    110         this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
    111         this->dedicatedUpgradeTower_ = createConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) );
     121        this->nextwaveTimer_.setTimer(10, false, createExecutor(createFunctor(&TowerDefense::nextwave, this)));
     122        this->nextwaveTimer_.stopTimer();
     123        this->waves_ = 0;
     124        this->time = 0;
     125        this->credit_ = 0;
     126        this->lifes_ = 0;
     127        this->timeSetTower_ = 0;
     128        spaceships =15;
     129        eggs=3;
     130        ufos=7;
     131        randomships=5;
     132
     133
     134        ModifyConsoleCommand(__CC_addTower_name).setObject(this);
     135        ModifyConsoleCommand(__CC_upgradeTower_name).setObject(this);
    112136    }
    113137
     
    117141        if (this->isInitialized())
    118142        {
    119             if( this->dedicatedAddTower_ )
    120                 delete this->dedicatedAddTower_;
     143            ModifyConsoleCommand(__CC_addTower_name).setObject(NULL);
     144            ModifyConsoleCommand(__CC_upgradeTower_name).setObject(NULL);
    121145        }
    122146    }
     
    131155    void TowerDefense::start()
    132156    {
    133 
    134         Deathmatch::start();
    135 
    136 // Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path
    137         for (int i=0; i < 16 ; i++){
    138             for (int j = 0; j< 16 ; j++){
    139                 towermatrix[i][j] = false;
     157        if (center_ != NULL) // There needs to be a TowerDefenseCenterpoint, i.e. the area the game takes place.
     158        {
     159            if (selecter == NULL)
     160            {
     161                selecter = new TowerDefenseSelecter(this->center_->getContext());               
    140162            }
    141         }
    142 
     163            selecter->addTemplate(center_->getSelecterTemplate());
     164            center_->attach(selecter);
     165        }
     166        else // If no centerpoint was specified, an error is thrown and the level is exited.
     167        {
     168            orxout(internal_error) << "Jump: No Centerpoint specified." << endl;
     169            return;
     170        }
     171
     172        TeamDeathmatch::start();
     173
     174        // Waypoints: [1,3] [10,3] [10,11] [13,11] -> add the points to a matrix so the player cant place towers on the path
     175        for (int i=0; i < 16 ; i++)
     176        {
     177            for (int j = 0; j< 16 ; j++)
     178            {
     179                towerModelMatrix[i][j] = NULL;
     180                towerTurretMatrix[i][j] = NULL;
     181            }
     182        }
     183
     184       
     185
     186        if (player_ != NULL)
     187        {
     188            //this->player_->startControl(selecter);
     189        }
     190        else
     191        {
     192            orxout() << "player=NULL" << endl;
     193        }
     194
     195
     196        Model* dummyModel = new Model(this->center_->getContext());
     197
     198        //the path of the spacehips has to be blocked, so that no towers can be build there
    143199        for (int k=0; k<3; k++)
    144             towermatrix[1][k]=true;
     200            towerModelMatrix[1][k]=dummyModel;
    145201        for (int l=1; l<11; l++)
    146             towermatrix[l][3]=true;
     202                towerModelMatrix[l][3]=dummyModel;
    147203        for (int m=3; m<12; m++)
    148             towermatrix[10][m]=true;
     204                towerModelMatrix[10][m]=dummyModel;
    149205        for (int n=10; n<14; n++)
    150             towermatrix[n][11]=true;
     206                towerModelMatrix[n][11]=dummyModel;
    151207        for (int o=13; o<16; o++)
    152             towermatrix[13][o]=true;
     208                towerModelMatrix[13][o]=dummyModel;
     209
    153210
    154211        //set initial credits, lifes and WaveNumber
    155         this->setCredit(200);
    156         this->setLifes(50);
     212        this->setCredit(100);
     213        this->setLifes(100);
    157214        this->setWaveNumber(0);
    158215        time=0.0;
    159216
     217        /*
    160218        //adds initial towers
    161219        for (int i=0; i <7; i++){
    162220            addTower(i+3,4);
    163         }/*
    164         for (int j=0; j < 7; j++){
    165             addTower(9,j+5);
    166         }*/
     221        }
     222                */
    167223    }
    168224
     
    178234            en1->addTemplate("enemytowerdefense1");
    179235            en1->setScale(3);
    180             en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
     236            en1->lookAt(Vector3(0,0,100000));
     237            en1->setHealth(en1->getHealth() +50 + this->getWaveNumber()*4);
    181238            break;
    182239
     
    184241            en1->addTemplate("enemytowerdefense2");
    185242            en1->setScale(2);
    186             en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
     243            en1->lookAt(Vector3(0,0,100000));
     244            en1->roll(Degree(120));
     245            en1->setHealth(en1->getHealth() -30 + this->getWaveNumber()*4);
    187246            //  en1->setShieldHealth(en1->getShield() = this->getWaveNumber()*2))
    188247            break;
     
    191250            en1->addTemplate("enemytowerdefense3");
    192251            en1->setScale(1);
    193             en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
     252            en1->lookAt(Vector3(0,0,100000));
     253            en1->roll(Degree(120));
     254            en1->setHealth(en1->getHealth() -10 + this->getWaveNumber()*4);
    194255            break;
    195256        }
    196257
     258        en1->setTeam(2);
    197259        en1->getController();
    198         en1->setPosition(path.at(0)->get3dcoordinate());
     260        en1->setPosition(path.at(0)->get3dcoordinate());       
    199261        TowerDefenseEnemyvector.push_back(en1);
    200262
     
    209271    {
    210272
    211         Deathmatch::end();
     273        TeamDeathmatch::end();
    212274        ChatManager::message("Match is over! Gameover!");
    213275
     276    }
     277
     278    void TowerDefense::spawnPlayer(PlayerInfo* player)
     279    {
     280        assert(player);
     281        this->player_ = player;
     282
     283        if (selecter->getPlayer() == NULL)
     284        {
     285            this->player_ = player;
     286            player->startControl(selecter);
     287            players_[player].state_ = PlayerState::Alive;
     288        }
     289    }
     290
     291    /**
     292    @brief
     293        Get the player.
     294    @return
     295        Returns a pointer to the player. If there is no player, NULL is returned.
     296    */
     297    PlayerInfo* TowerDefense::getPlayer(void) const
     298    {
     299        return this->player_;
    214300    }
    215301
    216302    //not working yet
    217303    void TowerDefense::upgradeTower(int x,int y)
    218     {/*
    219         const int upgradeCost = 20;
     304    {
     305        TDCoordinate* coord = new TDCoordinate(x,y);
     306        x = coord->GetX();
     307        y = coord->GetY();
     308       
    220309
    221310        if (!this->hasEnoughCreditForTower(upgradeCost))
     
    225314        }
    226315
    227         if (towermatrix [x][y] == NULL)
     316
     317        Model* dummyModel2 = new Model(this->center_->getContext());
     318
     319        if (towerModelMatrix [x][y] == NULL || (towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource())
    228320        {
    229321            orxout() << "no tower on this position" << endl;
     
    233325        else
    234326        {
    235             (towermatrix [x][y])->upgradeTower();
    236         }*/
     327            (towerTurretMatrix [x][y])->upgradeTower();
     328            switch(towerTurretMatrix[x][y]->upgrade)
     329                   {
     330                   case 1 :
     331                           towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh");
     332                           break;
     333
     334                   case 2 :
     335                           towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh");
     336                           break;
     337                   case 3 :
     338                           towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh");
     339                           break;
     340                   case 4 :
     341                           towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh");
     342                           break;
     343
     344                   }
     345
     346            this->buyTower(upgradeCost);
     347        }
    237348    }
    238349
    239350    /*adds Tower at Position (x,y) and reduces credit and adds the point to the towermatrix. template ("towerturret")
    240351    so towers have ability if the turrets
    241 
    242352    */
     353
    243354    void TowerDefense::addTower(int x, int y)
    244     {
    245         const int towerCost = 20;
     355    {       
     356        TDCoordinate* coord = new TDCoordinate(x,y);
     357        x = coord->GetX();
     358        y = coord->GetY();
     359
    246360
    247361        if (!this->hasEnoughCreditForTower(towerCost))
     
    251365        }
    252366
    253         if (towermatrix [x][y]==true)
     367        if (towerModelMatrix [x][y]!=NULL)
    254368        {
    255369            orxout() << "not possible to put tower here!!" << endl;
     
    264378        int tileScale = (int) this->center_->getTileScale();
    265379
    266         if (x > 15 || y > 15 || x < 0 || y < 0)
     380        /*if (x > 15 || y > 15 || x < 0 || y < 0)
    267381        {
    268382            //Hard coded: TODO: let this depend on the centerpoint's height, width and fieldsize (fieldsize doesn't exist yet)
    269383            orxout() << "Can not add Tower: x and y should be between 0 and 15" << endl;
    270384            return;
    271         }
    272 
    273         orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
    274 
    275        //Reduce credit
    276         this->buyTower(towerCost);
    277         towermatrix [x][y]=true;
     385        }*/
     386
     387        //orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
     388        orxout() << "Will add tower at (" << x << "," << y << ")" << endl;
     389
     390
     391        //Create Model
     392        Model* newTowerModel = new Model(this->center_->getContext());
     393        newTowerModel->setMeshSource("TD_T1.mesh");
     394        newTowerModel->setScale(30);
     395        newTowerModel->pitch(Degree(90));
     396        newTowerModel->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 80);
    278397
    279398        //Creates tower
    280399        TowerDefenseTower* towernew = new TowerDefenseTower(this->center_->getContext());
    281         towernew->addTemplate("towerturret");
    282         towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 75);
     400        towernew->setPosition(static_cast<float>((x-8) * tileScale), static_cast<float>((y-8) * tileScale), 275);
    283401        towernew->setGame(this);
    284     }
     402        towernew->setTeam(1);
     403
     404        //Reduce credit
     405         this->buyTower(towerCost);
     406         towerModelMatrix [x][y]= newTowerModel;
     407         towerTurretMatrix [x][y]= towernew;
     408    }   
    285409
    286410    bool TowerDefense::hasEnoughCreditForTower(int towerCost)
     
    296420
    297421 
     422    void TowerDefense::nextwave()
     423    {
     424
     425        orxout() << "newwave" << endl;
     426        TowerDefenseEnemyvector.clear();
     427        waves_++;
     428        //maxspaceships = round(maxspaceshipsstandard + 0.25*(waves_));
     429        time=0;
     430
     431        int helpnumber = 40 -(waves_);
     432        if(helpnumber <= 0) {helpnumber =1;}
     433        float numSpaceships = std::abs((rand() % 100)*5*(helpnumber));
     434        float numEggs = std::abs((rand() % 100)*1*(waves_));
     435        float numUfos = std::abs((rand() % 100)*1.5*(0.5*(waves_))) ;
     436
     437        float totalnumber = (numSpaceships + numEggs + numUfos)*1.3;
     438
     439        int newspaceships = (int)(maxspaceships* numSpaceships / totalnumber);
     440        int neweggs = (int)(maxspaceships*numEggs / totalnumber);
     441        int newufos = (int)(maxspaceships*numUfos / totalnumber);
     442        int newrandomships = maxspaceships -newspaceships - neweggs - newufos;
     443        spaceships =newspaceships;
     444        eggs=neweggs;
     445        ufos=newufos;
     446        randomships=newrandomships;
     447
     448        orxout() << spaceships << endl;
     449        orxout() << eggs << endl;
     450        orxout() << ufos << endl;
     451        orxout() << randomships << endl;
     452
     453
     454
     455
     456
     457    }
     458
    298459    void TowerDefense::tick(float dt)
    299460    {
    300461        SUPER(TowerDefense, tick, dt);
    301462        time +=dt;
     463        timeSetTower_ +=dt;
     464
     465        //Check if tower has to be set (because TowerDefenseSelecter asks for it)
     466        if(timeSetTower_ >= 0.25)
     467        {
     468                timeSetTower_ =0;
     469                        if(selecter != NULL && selecter->firePressed_)
     470                        {
     471
     472                                int x = selecter->selectedPos_->GetX();
     473                                int y = selecter->selectedPos_->GetY();
     474                                Model* dummyModel2 = new Model(this->center_->getContext());
     475
     476
     477
     478                                if(towerModelMatrix[x][y] == NULL)
     479                                {
     480                                        addTower(x,y);
     481                                }
     482                                else
     483                                {
     484                                        if(!((towerModelMatrix [x][y])->getMeshSource() == dummyModel2->getMeshSource()))
     485                                        {
     486                                                towerTurretMatrix[x][y]->upgradeTower();
     487                                        if(towerTurretMatrix[x][y]->upgrade < towerTurretMatrix[x][y]->upgradeMax)
     488                                        {
     489                                                int specificupgradecost = (int)(upgradeCost*(std::pow(1.5,towerTurretMatrix[x][y]->upgrade)));
     490                                                if(this->credit_ >= specificupgradecost)
     491                                                {
     492                                                        this->buyTower(specificupgradecost);
     493                                                                switch(towerTurretMatrix[x][y]->upgrade)
     494                                                           {
     495                                                                   case 1 :
     496                                                                           towerModelMatrix[x][y]->setMeshSource("TD_T2.mesh");
     497                                                                           break;
     498
     499                                                                   case 2 :
     500                                                                           towerModelMatrix[x][y]->setMeshSource("TD_T3.mesh");
     501                                                                           break;
     502                                                   case 3 :
     503                                                           towerModelMatrix[x][y]->setMeshSource("TD_T4.mesh");
     504                                                           break;
     505                                                   case 4 :
     506                                                           towerModelMatrix[x][y]->setMeshSource("TD_T5.mesh");
     507                                                           break;
     508
     509                                                           }
     510                                                }
     511
     512
     513                                        }
     514                                        }
     515                                }
     516                                selecter->firePressed_ = false;
     517                        }
     518        }
    302519
    303520        TDCoordinate* coord1 = new TDCoordinate(1,1);
    304521        std::vector<TDCoordinate*> path;
    305522        path.push_back(coord1);
    306         if(time>1 && TowerDefenseEnemyvector.size() < 30)
    307         {
    308             //adds different types of enemys depending on the WaveNumber
    309             addTowerDefenseEnemy(path, this->getWaveNumber() % 3 +1 );
    310             time = time-1;
    311         }
     523
     524
     525
     526
     527
     528        if(time>=TowerDefenseEnemyvector.size() && TowerDefenseEnemyvector.size() < maxspaceships)
     529                {
     530
     531                //adds different types of enemys depending on the WaveNumber progressively making the combination of enemys more difficult
     532                if(spaceships>0)
     533                {
     534                        addTowerDefenseEnemy(path, 1);
     535                        spaceships--;
     536
     537                }else if(ufos>0)
     538                {
     539                        addTowerDefenseEnemy(path, 3);
     540                        ufos--;
     541                }else if(eggs>0)
     542                {
     543                        addTowerDefenseEnemy(path, 2);
     544                        eggs--;
     545                }else if(randomships>0)
     546                {
     547                        addTowerDefenseEnemy(path, rand() % 3 +1);
     548                        randomships--;
     549
     550                }
     551
     552                }
     553
    312554
    313555        Vector3* endpoint = new Vector3(500, 700, 150);
     
    317559            if(TowerDefenseEnemyvector.at(i) != NULL && TowerDefenseEnemyvector.at(i)->isAlive())
    318560            {
    319                 //destroys enemys at the end of teh path and reduces the life by 1. no credits gifted
     561                //destroys enemys at the end of the path and reduces the life by 1. no credits gifted
    320562
    321563                Vector3 ship = TowerDefenseEnemyvector.at(i)->getRVWorldPosition();
     
    333575            }
    334576        }
     577
    335578        //goes thorugh vector to see if an enemy is still alive. if not next wave is launched
    336579        int count= 0;
     
    343586        }
    344587
     588        if (count == 0 && !this->nextwaveTimer_.isActive())
     589            this->nextwaveTimer_.startTimer();
     590
     591/*            time2 +=dt;
    345592        if(count== 0)
    346593        {
    347             time2 +=dt;
    348594            if(time2 > 10)
    349595            {
     
    354600            }
    355601        }
    356 
    357 
    358     }
     602*/
     603
     604    }
     605
    359606
    360607    // Function to test if we can add waypoints using code only. Doesn't work yet
     
    399646    void TowerDefense::playerEntered(PlayerInfo* player)
    400647    {
    401         Deathmatch::playerEntered(player);
     648        TeamDeathmatch::playerEntered(player);
    402649
    403650        const std::string& message = player->getName() + " entered the game";
     
    407654    bool TowerDefense::playerLeft(PlayerInfo* player)
    408655    {
    409         bool valid_player = Deathmatch::playerLeft(player);
     656        bool valid_player = TeamDeathmatch::playerLeft(player);
    410657
    411658        if (valid_player)
     
    437684        }
    438685
    439         Deathmatch::pawnKilled(victim, killer);
     686        TeamDeathmatch::pawnKilled(victim, killer);
    440687    }
    441688
  • code/branches/presentationFS15merge/src/modules/towerdefense/TowerDefense.h

    r10258 r10615  
    3838#define _TowerDefense_H__
    3939#include "TDCoordinate.h"
     40#include "TowerDefenseSelecter.h"
    4041#include "towerdefense/TowerDefensePrereqs.h"
    41 #include "gametypes/Deathmatch.h"
     42#include "gametypes/TeamDeathmatch.h"
    4243#include "TowerDefenseEnemy.h"
    4344#include "util/Output.h"
    4445#include "core/object/WeakPtr.h"
     46#include "TowerDefenseSelecter.h"
     47#include "graphics/Camera.h"   
     48
    4549
    4650namespace orxonox
    4751{
    48     class _TowerDefenseExport TowerDefense : public Deathmatch
     52    class _TowerDefenseExport TowerDefense : public TeamDeathmatch
    4953    {
    5054    public:
     
    5357
    5458        std::vector<orxonox::WeakPtr<TowerDefenseEnemy> > TowerDefenseEnemyvector;
    55         bool towermatrix[16][16];
     59        Model* towerModelMatrix[16][16];
     60        TowerDefenseTower* towerTurretMatrix[16][16];
    5661        void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr);
    5762        virtual void start(); //<! The function is called when the gametype starts
    5863        virtual void end();
    5964        virtual void tick(float dt);
    60         //virtual void playerEntered(PlayerInfo* player);
    61         //virtual bool playerLeft(PlayerInfo* player);
    62         //Player Stats (set,get, reduce)
     65        virtual void spawnPlayer(PlayerInfo* player);
     66        PlayerInfo* getPlayer(void) const;
    6367        int getCredit(){ return this->credit_; }
    6468        int getLifes(){ return this->lifes_; }
     
    6973        void buyTower(int cost){ credit_ -= cost;}
    7074        void addCredit(int credit) { credit_+=credit; }
    71         void nextwave(){ waves_++;}
     75        void nextwave();
    7276        int reduceLifes(int NumberofLifes){ return lifes_-=NumberofLifes; }
     77        TowerDefenseSelecter* selecter;
     78        int spaceships;
     79        int eggs;
     80        int ufos;
     81        int randomships;
     82
    7383
    7484        //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
     
    8393        /* Adds a tower at x, y in the playfield */
    8494        void addTower(int x, int y);
    85 
    8695        void upgradeTower(int x, int y);
    87         /* Part of a temporary hack to allow the player to add towers */
    88         ConsoleCommand* dedicatedAddTower_;
    89         ConsoleCommand* dedicatedUpgradeTower_;
    9096
    9197        //TODO: void spawnNewWave()
     
    96102    private:
    97103        TowerDefenseCenterpoint *center_;
     104        PlayerInfo* player_;
    98105        float time;
    99         float time2;
     106        float timeSetTower_;
     107//        float time2;
    100108        int credit_;
    101109        int waves_;
    102110        int lifes_;
     111        Timer nextwaveTimer_;
    103112
    104113        /* handles stats */
    105114        bool hasEnoughCreditForTower(int towerCost);
    106115        bool hasEnoughCreditForUpgrade();
    107 
    108 
    109 
    110         std::vector<TowerTurret*> towers_;
    111116    };
    112117}
  • code/branches/presentationFS15merge/src/modules/towerdefense/TowerDefenseCenterpoint.cc

    r9667 r10615  
    5353        this->width_ = 15;
    5454        this->height_ = 15;
    55         this->towerTemplate_ = "";
    5655
    5756        //this->setCollisionType(Static);
     
    7271        XMLPortParam(TowerDefenseCenterpoint, "height", setHeight, getHeight, xmlelement, mode);
    7372        XMLPortParam(TowerDefenseCenterpoint, "tileScale", setTileScale, getTileScale, xmlelement, mode);
    74         XMLPortParam(TowerDefenseCenterpoint, "towerTemplate", setTowerTemplate, getTowerTemplate, xmlelement, mode);
     73        XMLPortParam(TowerDefenseCenterpoint, "selecterTemplate", setSelecterTemplate, getSelecterTemplate, xmlelement, mode);
    7574
    7675        //TODO: add XMLPortObject(TowerDefenseCenterpoint, WorldEntity, "waypoints", addWaypoint, getWaypoint,  xmlelement, mode);
  • code/branches/presentationFS15merge/src/modules/towerdefense/TowerDefenseCenterpoint.h

    r9667 r10615  
    6060            void setWidth(unsigned int width)
    6161                { this->width_ = width; }
    62 
    6362            unsigned int getWidth(void) const
    6463                { return this->width_; }
    65 
    6664            void setHeight(unsigned int height)
    6765                { this->height_ = height; }
    68 
    6966            unsigned int getHeight(void) const
    7067                { return this->height_; }
    71 
     68            void setSelecterTemplate(const std::string& newTemplate)
     69                { this->selecterTemplate_ = newTemplate; }
     70            const std::string& getSelecterTemplate() const
     71                { return this->selecterTemplate_; }   
    7272            /**
    7373                @brief How to convert to world coordinates, e.g. that 0,15 is not at -8,-8 but at -80,-80 (if scale would be 10)
     
    7979                { return this->tileScale_; }
    8080
    81             /**
    82             @brief Set the template for the towers.
    83             @param template The template name to be applied to each tower.
    84             */
    85             void setTowerTemplate(const std::string& templateName)
    86                 { this->towerTemplate_ = templateName; }
    87 
    88             const std::string& getTowerTemplate(void) const
    89                 { return this->towerTemplate_; }
    90 
    9181        private:
    9282            void checkGametype();
    9383
     84            std::string selecterTemplate_;
    9485            unsigned int width_;
    9586            unsigned int height_;
    9687            unsigned int tileScale_;
    97 
    98             std::string towerTemplate_;
    9988    };
    10089}
  • code/branches/presentationFS15merge/src/modules/towerdefense/TowerDefenseEnemy.cc

    r10258 r10615  
    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/presentationFS15merge/src/modules/towerdefense/TowerDefenseTower.cc

    r10258 r10615  
    2222        Constructor. Registers and initializes the object.
    2323    */
    24     TowerDefenseTower::TowerDefenseTower(Context* context) : Pawn(context)
     24    TowerDefenseTower::TowerDefenseTower(Context* context) : Turret(context)
    2525    {
    2626        RegisterObject(TowerDefenseTower);
     27        game_ =NULL;
     28        this->setCollisionType(WorldEntity::None);
     29        upgrade = 0;
     30        this->addTemplate("towerdefensetower");
    2731
    28         this->setCollisionType(WorldEntity::Dynamic);
    29         upgrade = 0;
     32        upgradeMax = 5;
     33
    3034
    3135        //this->removeAllEngines();
     
    3842    }
    3943
     44    /*
    4045    void TowerDefenseTower::setOrientation(const Quaternion& orientation)
    4146    {
     
    5358    {
    5459    }
     60    */
    5561
    5662    bool TowerDefenseTower::upgradeTower()
    5763    {
    58         if(upgrade < 3)
     64        if(upgrade < upgradeMax)
    5965        {
    6066            upgrade++;
    6167            float reloadrate = getReloadRate();
    6268            float reloadwaittime = getReloadWaitTime();
    63             this->setDamageMultiplier(5000);
    64 
    65             reloadrate = 0.5f*reloadrate;
    66             reloadwaittime = 0.5f*reloadwaittime;
     69            this->setDamageMultiplier((upgrade+1)*1.5);
     70            this->setRotationThrust(2*this->getRotationThrust());
     71            reloadrate = 0.7f*reloadrate;
     72            reloadwaittime = 0.7f*reloadwaittime;
    6773            setReloadRate(reloadrate);
    6874            setReloadWaitTime(reloadwaittime);
    69             this->addTemplate("towerturret1");
     75            //this->addTemplate("towerturret1");
    7076        }
    7177        else
  • code/branches/presentationFS15merge/src/modules/towerdefense/TowerDefenseTower.h

    r10258 r10615  
    2020#include "towerdefense/TowerDefensePrereqs.h"
    2121#include "worldentities/pawns/SpaceShip.h"
     22#include "objects/Turret.h"
    2223
    2324
    2425namespace orxonox
    2526{
    26     class _TowerDefenseExport TowerDefenseTower : public Pawn
     27    class _TowerDefenseExport TowerDefenseTower : public Turret
    2728    {
    2829    public:
     
    3738
    3839        // Overriding these to stop TowerDefenseTowers from spasing out
     40        /*
    3941        void setOrientation(const Quaternion& orientation);
    4042        virtual void rotateYaw(const Vector2& value);
    4143        virtual void rotatePitch(const Vector2& value);
    4244        virtual void rotateRoll(const Vector2& value);
     45        */
    4346        virtual bool upgradeTower();
    4447
     
    4649        void setGame(TowerDefense* Towerdefense)
    4750        { assert(Towerdefense); game_ = Towerdefense; }
     51        int upgrade;
     52        int upgradeMax;
    4853    private:
    4954        TowerDefense* game_;
    50         int upgrade;
     55
    5156    };
    5257}
Note: See TracChangeset for help on using the changeset viewer.