Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12125


Ignore:
Timestamp:
Nov 28, 2018, 11:50:56 AM (6 years ago)
Author:
michbaum
Message:

Neuer Gegnercontroller und alle noetigen Aenderungen

Location:
code/branches/TowerDefense_HS18
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/TowerDefense_HS18/data/levels/towerDefense.oxw

    r11052 r12125  
    2323  <TowerDefenseSelecter>
    2424    <camerapositions>
    25       <CameraPosition position="0,0,1300" lookat="0,0,0" absolute=true drag=true mouselook=true/>
     25      <CameraPosition position="0,0,1400" lookat="0,0,0" absolute=true drag=true mouselook=true/>
    2626    </camerapositions>
    2727  </TowerDefenseSelecter>
     
    301301      <BoxCollisionShape position="0,0.1,-19"  halfExtents="1.4, 1, 2" />
    302302    </collisionShapes>
    303     <controller>
    304        <WaypointController accuracy = 50/>
    305     </controller>
     303    <!-- Hier wurde der Controller entfernt-->
    306304  </TowerDefenseEnemy>
    307305</Template>
     
    374372      <BoxCollisionShape position="0,0.1,-19"  halfExtents="1.4, 1, 2" />
    375373    </collisionShapes>
    376     <controller>
    377        <WaypointController accuracy = 50/>
    378     </controller>
    379374  </TowerDefenseEnemy>
    380375</Template>
     
    447442      <BoxCollisionShape position="0,0.1,-19"  halfExtents="1.4, 1, 2" />
    448443    </collisionShapes>
    449     <controller>
    450        <WaypointController accuracy = 50/>
    451     </controller>
    452444  </TowerDefenseEnemy>
    453445</Template>
     
    501493            F1F1F1I2F1F1F1F1F1F1F1F1F1F1F1F1
    502494            F1F1F1I2F1F1F1F1F1F1F1Y1Y1Y1F1F1
    503             F1F1F1R2I3I3I3I3L3F1F1F1F1F1F1F1
    504             F1F1F1F1F1F1F1F1I2F1F1F1F1F1F1F1
    505             F1F1F1F1F1F1F1F1I2F1F1F1F1F1F1F1
    506             X1I1I1I1R0F1F1F1I2F1F1F1F1F1F1F1
    507             F1F1F1F1I0F1F1F1I2F1F1F1F1F1F1F1
    508             F1F1F1F1I0F1F1F1I2F1F1F1F1F1F1F1
    509             F1F1F1F1L1I1I1I1L2F1F1F1F1F1F1F1
     495            F1F1F1R2I3I3I3I3I3I3I3L3F1F1F1F1
     496            F1F1F1F1F1F1F1F1F1F1F1I2F1F1F1F1
     497            F1F1F1F1F1F1F1F1F1F1F1I2F1F1F1F1
     498            X1I1I1I1R0F1F1F1F1F1F1I2F1F1F1F1
     499            F1F1F1F1I0F1F1F1F1F1F1I2F1F1F1F1
     500            F1F1F1F1I0F1F1F1F1F1F1I2F1F1F1F1
     501            F1F1F1F1L1I1I1I1I1I1I1L2F1F1F1F1
    510502            F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1
    511503            F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1F1
  • code/branches/TowerDefense_HS18/src/modules/towerdefense/CMakeLists.txt

    r10629 r12125  
    1010  TowerDefenseField.cc
    1111  TDCoordinate.cc
     12  TowerDefenseController.cc
    1213)
    1314
  • code/branches/TowerDefense_HS18/src/modules/towerdefense/TowerDefense.cc

    r11716 r12125  
    7676#include "TowerDefenseCenterpoint.h"
    7777#include "worldentities/SpawnPoint.h"
    78 #include "controllers/WaypointController.h"
     78#include "TowerDefenseController.h" //muss ich noch in den richtigen Ordner verschieben
    7979#include "graphics/Model.h"
    8080#include "infos/PlayerInfo.h"
     
    175175        en1->setTeam(2);
    176176
    177         WaypointController* controller = (WaypointController*)(en1->getXMLController());
    178 
    179         if (controller != nullptr && waypoints_.size() > 1)
     177        //Jedem Enemy wird ein eigener Controller uebergeben
     178        TowerDefenseController* controller = new TowerDefenseController(this->center_->getContext());
     179        controller->setControllableEntity(en1);
     180        en1->setController(controller);
     181
     182        if (waypoints_.size() > 1)
    180183        {
    181184            en1->setPosition(waypoints_.at(0)->getPosition() + offset_);
     
    192195        }
    193196
    194         enemies_.push_back(en1);
     197        auto pair = std::make_pair(orxonox::WeakPtr<TowerDefenseEnemy>(en1), controller);
     198        enemies_.push_back(pair);
    195199    }
    196200
     
    291295            }           
    292296        }
     297               
    293298       
    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++);
     299        for (EnemyList::iterator it = enemies_.begin(); it != enemies_.end(); )
     300        {
     301            WeakPtr<TowerDefenseEnemy> enemy = it->first;
     302            TowerDefenseController* ctrl = it->second;
     303
     304            if (enemy == nullptr)
     305            {
     306
     307                // the enemy was destroyed by a tower - remove it from the list AND destroy the corresponding controler
     308                ctrl->destroy();
     309                it = enemies_.erase(it);
    300310                addCredit(1);
    301311            }
     
    303313            {
    304314                //if ships are at the end they get destroyed
    305                 Vector3 ship = (*it)->getRVWorldPosition();
     315                Vector3 ship = enemy->getRVWorldPosition();
    306316                float distance = ship.distance(endpoint_);
    307317                if(distance < 40)
    308318                {
    309                     (*it)->destroy();
    310                     enemies_.erase(it++);
     319                    enemy->getController()->destroy();
     320                    enemy->destroy();
     321
     322                    it = enemies_.erase(it);
    311323                    this->reduceLifes(1);
    312324                    if (this->getLifes() == 0)
     
    412424        }
    413425
     426        //Falls kein anliegender Weg gefunden wurde.
    414427        delete nextCoord;
    415428        return nullptr;
  • code/branches/TowerDefense_HS18/src/modules/towerdefense/TowerDefense.h

    r11099 r12125  
    3232#include "TDCoordinate.h"
    3333#include "TowerDefenseSelecter.h"
     34#include "TowerDefenseController.h"
    3435#include "towerdefense/TowerDefensePrereqs.h"
    3536#include "gametypes/TeamDeathmatch.h"
     
    4041namespace orxonox
    4142{
     43    using EnemyList = std::list<std::pair<orxonox::WeakPtr<TowerDefenseEnemy>, TowerDefenseController*>>;
     44
    4245    /**
    4346    @brief
     
    8689        int waveNumber_;
    8790        int lifes_;
    88         std::list<orxonox::WeakPtr<TowerDefenseEnemy>> enemies_;
     91        EnemyList enemies_;
    8992        TowerDefenseField* fields_[16][16];
    9093        std::vector<orxonox::WeakPtr<TowerDefenseField>> waypoints_;
  • code/branches/TowerDefense_HS18/src/modules/towerdefense/TowerDefenseEnemy.cc

    r11099 r12125  
    2929    TowerDefenseEnemy::~TowerDefenseEnemy()
    3030    {
    31 
    3231    }
    3332
Note: See TracChangeset for help on using the changeset viewer.