home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 06 General Architectures / 04 Christian / damaged.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-03  |  641 b   |  45 lines

  1.  
  2. #include "character.h"
  3. #include "Damaged.h"
  4. #include "gametime.h"
  5. #include "util.h"
  6.  
  7. Damaged::Damaged()
  8. {
  9.     m_name      = "Damaged";
  10.     m_owner     = NULL;
  11. }
  12.  
  13. void Damaged::init   ( IEOwner * owner )
  14. {
  15.     m_owner = dynamic_cast<Character *> (owner);
  16.  
  17.     m_lastHealth = m_owner->getHealth();
  18. }
  19.  
  20.  
  21. bool Damaged::update () 
  22. {
  23.     int curHealth = m_owner->getHealth();
  24.  
  25.     if ( curHealth != m_lastHealth )
  26.     {
  27.         m_lastHealth = curHealth;
  28.         return true;
  29.     }
  30.     else
  31.         return false;
  32. }
  33.  
  34.  
  35. IEOwner * Damaged::getOwner ()
  36. {
  37.     return m_owner;
  38. }
  39.  
  40. const char * Damaged::getName()
  41. {
  42.     return m_name.c_str();
  43. }
  44.  
  45.