Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 15, 2014, 3:58:14 PM (10 years ago)
Author:
maxima
Message:

towerdefenseHS14 merged.

Location:
code/branches/presentationHS14
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentationHS14

  • code/branches/presentationHS14/src/modules/towerdefense/TowerDefenseEnemy.cc

    r10180 r10181  
    3030        //needed to keep track of the PlayerStats coded in TowerDefense.h
    3131        this->td = orxonox_cast<TowerDefense*>(this->getGametype().get());
     32        once_=false;
    3233
    3334    }
    3435    //add credit if enemy is destroyed
    3536    TowerDefenseEnemy::~TowerDefenseEnemy(){
    36                 this->td->addCredit(1);
     37                //this->td->addCredit(1);
    3738    }
    3839
     
    4849    }
    4950
     51    WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
     52    {
     53        if (game == NULL)
     54        {
     55            for (ObjectList<TowerDefense>::iterator it = ObjectList<TowerDefense>::begin(); it != ObjectList<TowerDefense>::end(); ++it)
     56                game = *it;
     57        }
     58        return game;
     59    }
     60
     61    void TowerDefenseEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
     62    {
     63        Pawn::damage(damage, healthdamage, shielddamage, originator);
     64        if (getGame() && once_ == false && getHealth() <= 0)
     65        {
     66            getGame()->addCredit(1);
     67            once_ = true;
     68        }
     69    }
    5070/*
    5171    void TowerDefenseEnemy::popWaypoint()
Note: See TracChangeset for help on using the changeset viewer.