Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 26, 2014, 4:30:10 PM (10 years ago)
Author:
maxima
Message:

nhaenni. HUD angepasst.

Location:
code/branches/towerdefenseHS14/src/modules/towerdefense
Files:
5 edited

Legend:

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

    r10134 r10140  
    130130
    131131        Deathmatch::start();
    132 
     132        credits = 5000;
     133        life = 20;
     134        waves = 0;
    133135        time=0.0;
    134136
     
    158160    // Generates a TowerDefenseEnemy. Uses Template "enemytowerdefense". Sets position at first waypoint of path.
    159161
    160     void TowerDefense::addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr){
     162    void TowerDefense::addTowerDefenseEnemy(std::vector<TDCoordinate*> path){
    161163
    162164        TowerDefenseEnemy* en1 = new TowerDefenseEnemy(this->center_->getContext());
    163 
    164         switch(templatenr)
    165         {
    166         case 1 :
    167                 en1->addTemplate("enemytowerdefense1");
    168             en1->setScale(3);
    169                 break;
    170         case 2 :
    171                         en1->addTemplate("enemytowerdefense2");
    172                 en1->setScale(2);
    173                         break;
    174         case 3 :
    175                         en1->addTemplate("enemytowerdefense3");
    176                 en1->setScale(1);
    177                         break;
    178         }
    179 
     165        en1->addTemplate("enemytowerdefense");
     166        en1->setScale(3);
    180167        en1->getController();
    181168
     
    298285            if(time>1 && TowerDefenseEnemyvector.size() < 30)
    299286            {
    300 
    301                 addTowerDefenseEnemy(path, rand() %3 +1 );
     287                addTowerDefenseEnemy(path);
    302288                time = time-1;
    303289            }
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h

    r10134 r10140  
    5656        std::vector<TowerDefenseEnemy*> TowerDefenseEnemyvector;
    5757
    58         void addTowerDefenseEnemy(std::vector<TDCoordinate*> path, int templatenr);
     58        void addTowerDefenseEnemy(std::vector<TDCoordinate*> path);
    5959        virtual void start(); //<! The function is called when the gametype starts
    6060        virtual void end();
     
    6363        //virtual bool playerLeft(PlayerInfo* player);
    6464
     65        int credits;
     66        int life;
     67        int waves;
    6568        //virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
    6669        //virtual void playerScored(PlayerInfo* player, int score);
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseEnemy.cc

    r10134 r10140  
    4848        float distance = ship.distance(*endpoint);
    4949
     50        orxout() << "distance" << distance << endl;
    5051        if(distance <50){
     52                orxout() << "ENEMY KILLED!!!!" << endl;
    5153                this->destroy(); }
    5254    }
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseHUDController.cc

    r9667 r10140  
    3232#include "util/Convert.h"
    3333
    34 
    3534namespace orxonox
    3635{
     
    5049    {
    5150        SUPER(TowerDefenseHUDController, tick, dt);
     51
     52        if(showlives == true)
     53          this->setCaption(multi_cast<std::string>(this->td->life));
     54        else if(showcredits == true)
     55          this->setCaption(multi_cast<std::string>(this->td->credits));
     56        else if(showwaves == true)
     57          this->setCaption(multi_cast<std::string>(this->td->waves));
     58
     59
    5260    }
    5361
     
    5563    {
    5664        SUPER(TowerDefenseHUDController, XMLPort, xmlelement, mode);
     65
     66        XMLPortParam(TowerDefenseHUDController, "showlives", setShowlives, getShowlives, xmlelement, mode);
     67        XMLPortParam(TowerDefenseHUDController, "showcredits", setShowcredits, getShowcredits, xmlelement, mode);
     68        XMLPortParam(TowerDefenseHUDController, "showwaves", setShowwaves, getShowwaves, xmlelement, mode);
     69
    5770    }
    5871
    5972    void TowerDefenseHUDController::changedOwner()
    60     {
    61         SUPER(TowerDefenseHUDController, changedOwner);
    62         /*
    63         if (this->getOwner() != NULL && this->getOwner()->getGametype())
    64             this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get());
    65         else
    66             this->owner_ = 0;
    67         */
    68     }
     73        {
     74            SUPER(TowerDefenseHUDController, changedOwner);
     75
     76            td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype().get());
     77
     78            /*if (this->getOwner() != NULL && this->getOwner()->getGametype())
     79            {
     80                this->owner_ = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype().get());
     81            }
     82            else
     83            {
     84                this->owner_ = NULL;
     85            }*/
     86        }
    6987
    7088}
  • code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefenseHUDController.h

    r9667 r10140  
    4242#include "tools/interfaces/Tickable.h"
    4343#include "overlays/OverlayText.h"
    44 
     44#include "TowerDefense.h"
    4545
    4646namespace orxonox
     
    5252        virtual ~TowerDefenseHUDController();
    5353
     54
    5455        virtual void tick(float dt);
    5556        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5657        virtual void changedOwner();
     58        void setShowlives(bool temp)
     59            { this->showlives = temp; }
     60        unsigned int getShowlives(void) const
     61            { return this->showlives; }
     62
     63        void setShowcredits(bool temp)
     64            { this->showcredits = temp; }
     65        unsigned int getShowcredits(void) const
     66            { return this->showcredits; }
     67
     68        void setShowwaves(bool temp)
     69            { this->showwaves = temp; }
     70        unsigned int getShowwaves(void) const
     71            { return this->showwaves; }
     72
     73    private:
     74        TowerDefense* td;
     75
     76        bool showcredits;
     77        bool showlives;
     78        bool showwaves;
    5779    };
    5880}
Note: See TracChangeset for help on using the changeset viewer.