Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12190 for code/trunk/src


Ignore:
Timestamp:
Feb 21, 2019, 3:02:00 PM (6 years ago)
Author:
merholzl
Message:

TD merge

Location:
code/trunk
Files:
8 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/towerdefense/CMakeLists.txt

    r10629 r12190  
    1010  TowerDefenseField.cc
    1111  TDCoordinate.cc
     12  TowerDefenseController.cc
     13  TowerDefenseRangeViewer.cc
    1214)
    1315
  • code/trunk/src/modules/towerdefense/TowerDefense.cc

    r11716 r12190  
    7676#include "TowerDefenseCenterpoint.h"
    7777#include "worldentities/SpawnPoint.h"
    78 #include "controllers/WaypointController.h"
     78#include "worldentities/StaticEntity.h"
     79#include "TowerDefenseController.h" //muss ich noch in den richtigen Ordner verschieben
    7980#include "graphics/Model.h"
    8081#include "infos/PlayerInfo.h"
     
    8283#include "core/CoreIncludes.h"
    8384#include "Highscore.h"
     85#include "util/Output.h"
     86#include "TowerDefenseRangeViewer.h"
     87
    8488
    8589namespace orxonox
     
    9296
    9397        selecter = nullptr;
     98        rangeViewer = nullptr;
    9499        this->player_ = nullptr;
    95100        this->setHUDTemplate("TowerDefenseHUD");
     
    124129                selecter = new TowerDefenseSelecter(this->center_->getContext());               
    125130            }
     131            if(rangeViewer == nullptr){
     132                rangeViewer = new TowerDefenseRangeViewer(this->center_->getContext());
     133            }
    126134            selecter->addTemplate(center_->getSelecterTemplate());
     135            rangeViewer->addTemplate("therangeviewer");
     136            rangeViewer->setPosition(-10000,0,-500);
    127137            center_->attach(selecter);
     138            center_->attach(rangeViewer);
    128139        }
    129140        else // If no centerpoint was specified, an error is thrown and the level is exited.
     
    136147
    137148        createFields();
     149
    138150        TeamDeathmatch::start();
    139151
     
    157169            en1->addTemplate("enemytowerdefense1");
    158170            en1->setScale(3);
    159             en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
     171            en1->setHealth(en1->getHealth() + this->getWaveNumber()*1/3*0.5*(en1->getHealth()));
     172            en1->setShieldHealth(en1->getShieldHealth() + this->getWaveNumber()*1/3*0.5*(en1->getShieldHealth()));
    160173            break;
    161174
     
    163176            en1->addTemplate("enemytowerdefense2");
    164177            en1->setScale(2);
    165             en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
     178            en1->setHealth(en1->getHealth() + this->getWaveNumber()*1/3*0.3*(en1->getHealth()));
    166179            break;
    167180
     
    169182            en1->addTemplate("enemytowerdefense3");
    170183            en1->setScale(1);
    171             en1->setHealth(en1->getHealth() + this->getWaveNumber()*4);
     184            en1->setHealth(en1->getHealth() + this->getWaveNumber()*1/3*0.2*(en1->getHealth()));
     185            en1->setShieldHealth(en1->getShieldHealth() + this->getWaveNumber()*1/3*0.5*(en1->getShieldHealth()));
    172186            break;
    173187        }       
     
    175189        en1->setTeam(2);
    176190
    177         WaypointController* controller = (WaypointController*)(en1->getXMLController());
    178 
    179         if (controller != nullptr && waypoints_.size() > 1)
     191        //Jedem Enemy wird ein eigener Controller uebergeben
     192        TowerDefenseController* controller = new TowerDefenseController(this->center_->getContext());
     193        controller->setControllableEntity(en1);
     194        en1->setController(controller);
     195
     196        if (waypoints_.size() > 1)
    180197        {
    181198            en1->setPosition(waypoints_.at(0)->getPosition() + offset_);
     
    192209        }
    193210
    194         enemies_.push_back(en1);
     211        auto pair = std::make_pair(orxonox::WeakPtr<TowerDefenseEnemy>(en1), controller);
     212        enemies_.push_back(pair);
    195213    }
    196214
     
    277295        timeSinceLastSpawn_ += dt;
    278296
     297        if(selecter != nullptr && getField(selecter->selectedPos_)->canUpgrade() == true ){
     298            rangeViewer->setPosition(((selecter->selectedPos_->GetX())-8)*100, ((selecter->selectedPos_->GetY())-8)*100, 200);
     299        } else {
     300            rangeViewer->setPosition(-10000,0,-500);
     301        }
     302
    279303        //build/upgrade tower at selecter position
    280304        if (selecter != nullptr && selecter->buildTower_ == true)
     
    291315            }           
    292316        }
     317               
    293318       
    294         for (std::list<WeakPtr<TowerDefenseEnemy>>::iterator it = enemies_.begin(); it != enemies_.end(); )
    295         {
    296             if (*it == nullptr)
    297             {
    298                 // the enemy was destroyed by a tower - remove it from the list
    299                 enemies_.erase(it++);
    300                 addCredit(1);
     319        for (EnemyList::iterator it = enemies_.begin(); it != enemies_.end(); )
     320        {
     321            WeakPtr<TowerDefenseEnemy> enemy = it->first;
     322            TowerDefenseController* ctrl = it->second;
     323
     324            if (enemy == nullptr)
     325            {
     326
     327                // the enemy was destroyed by a tower - remove it from the list AND destroy the corresponding controler
     328                ctrl->destroy();
     329                it = enemies_.erase(it);
     330               
     331                int currentType = this->getWaveNumber() % 3 + 1;
     332                switch (currentType){ //Entscheidet, wie viele Credits vergeben werden sollen
     333                    case 1: //currently boss wave
     334                        addCredit(100);
     335                        if (this->getLifes() <= 90)
     336                        {
     337                            this->setLifes(this->getLifes() + 10);
     338                        }
     339                        break;
     340
     341                    case 2: //currently mass wave
     342                        addCredit(5);
     343                        break;
     344
     345                    case 3: //currently moderate wave
     346                        addCredit(10);
     347                        break;
     348                }
    301349            }
    302350            else
    303351            {
    304352                //if ships are at the end they get destroyed
    305                 Vector3 ship = (*it)->getRVWorldPosition();
     353                Vector3 ship = enemy->getRVWorldPosition();
    306354                float distance = ship.distance(endpoint_);
    307355                if(distance < 40)
    308356                {
    309                     (*it)->destroy();
    310                     enemies_.erase(it++);
     357                    enemy->getController()->destroy();
     358                    enemy->destroy();
     359
     360                    it = enemies_.erase(it);
    311361                    this->reduceLifes(1);
    312362                    if (this->getLifes() == 0)
     
    328378            timeSinceLastSpawn_ -= 1.0;
    329379            -- waveSize_;
    330             addTowerDefenseEnemy(this->getWaveNumber() % 3 + 1);
     380            addTowerDefenseEnemy(this->getWaveNumber() % 3 + 1); //Gegnertyp rotiert durch die 3 moeglichen, er beginnt bei Typ 2!!!
    331381        }
    332382        else if (timeUntilNextWave_ <= 0.0 && waveSize_ <= 0)
    333383        {
     384            int currentType = this->getWaveNumber() % 3 + 1;
    334385            //New wave
    335386            ++ waveNumber_;
     
    337388
    338389            timeUntilNextWave_ = waveNumber_+20.0f;
    339             waveSize_ = waveNumber_+5;
     390            // Entscheidung, wie gross die einzelnen waves sein sollen.
     391            switch (currentType){
     392                case 1: //currently boss wave
     393                    waveSize_ = waveNumber_+10;
     394                    break;
     395
     396                case 2: //currently mass wave
     397                    waveSize_ = (waveNumber_+10)/2;
     398                    break;
     399
     400                case 3: //currently moderate wave
     401                    waveSize_ = 1;
     402                    break;
     403            }
    340404        }
    341405
     
    349413        std::string fields = center_->getFields();
    350414        int pos = 0;
    351         for (int j = 15; j >= 0; --j)
    352         {
    353             for (int i = 0; i < 16; ++i)
     415        for (int j = 15; j >= 0; --j) //Vertical number of rows
     416        {
     417            for (int i = 0; i <= 15; ++i) //Horizontal number of rows
    354418            {
    355419                coord.Set(i,j);
     
    412476        }
    413477
     478        //Falls kein anliegender Weg gefunden wurde.
    414479        delete nextCoord;
    415480        return nullptr;
  • code/trunk/src/modules/towerdefense/TowerDefense.h

    r11099 r12190  
    3232#include "TDCoordinate.h"
    3333#include "TowerDefenseSelecter.h"
     34#include "TowerDefenseController.h"
    3435#include "towerdefense/TowerDefensePrereqs.h"
    3536#include "gametypes/TeamDeathmatch.h"
     
    3738#include "util/Output.h"
    3839#include "TowerDefenseField.h"
     40#include "TowerDefenseRangeViewer.h"
    3941
    4042namespace orxonox
    4143{
     44    using EnemyList = std::list<std::pair<orxonox::WeakPtr<TowerDefenseEnemy>, TowerDefenseController*>>;
     45
    4246    /**
    4347    @brief
     
    7377        virtual TDCoordinate* getNextStreetCoord(TDCoordinate*);
    7478       
    75         TowerDefenseSelecter* selecter;       
     79        TowerDefenseSelecter* selecter;   
     80        TowerDefenseRangeViewer* rangeViewer;     
    7681
    7782    private:
     
    8691        int waveNumber_;
    8792        int lifes_;
    88         std::list<orxonox::WeakPtr<TowerDefenseEnemy>> enemies_;
     93        EnemyList enemies_;
    8994        TowerDefenseField* fields_[16][16];
    9095        std::vector<orxonox::WeakPtr<TowerDefenseField>> waypoints_;
  • code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc

    r11099 r12190  
    2929    TowerDefenseEnemy::~TowerDefenseEnemy()
    3030    {
    31 
    3231    }
    3332
  • code/trunk/src/modules/towerdefense/TowerDefenseField.cc

    r11071 r12190  
     1
    12/*
    23 *   ORXONOX - the hottest 3D action shooter ever to exist
     
    282283                }
    283284            }
     285           
    284286        }                           
    285287    }
  • code/trunk/src/modules/towerdefense/TowerDefensePrereqs.h

    r10258 r12190  
    6868
    6969    class TowerDefenseTower;
    70 
     70    class TowerDefenseRangeViewer;
    7171    class TowerDefenseCenterpoint;
    7272    class TowerDefenseHUDController;
  • code/trunk/src/modules/towerdefense/towerdefensereadme.txt

    r9271 r12190  
    1212Represents a Tower
    1313I'm not actually sure if you have to code C++ in order to have your result. I would suggest to simply create a new spaceship template or maybe better a
    14 new template for a pawn. (The tower don't need to be spaceships; pawn is just fine.)
     14new template for a pawn. (The towers don't need to be spaceships; pawn is just fine.)
    1515Example for a template: /data/levels/templates/assff.oxt && /data/levels/include/weaponSettingsAssff.oxi
    1616@ assff.oxt: you don't need an engine (or your towers could fly away :-) and probably no Cameras. (just try what happens if you leave them out.)
Note: See TracChangeset for help on using the changeset viewer.