CMovementEndAnimation.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "StdInc.h"
  2. #include "CMovementEndAnimation.h"
  3. #include "CCreatureAnimation.h"
  4. #include "../CMusicHandler.h"
  5. #include "../CGameInfo.h"
  6. #include "../../lib/BattleState.h"
  7. #include "../CCursorHandler.h"
  8. bool CMovementEndAnimation::init()
  9. {
  10. if( !isEarliest(true) )
  11. return false;
  12. if(!stack || myAnim()->framesInGroup(CCreatureAnim::MOVE_END) == 0 ||
  13. myAnim()->getType() == CCreatureAnim::DEATH)
  14. {
  15. endAnim();
  16. return false;
  17. }
  18. CCS->soundh->playSound(battle_sound(stack->getCreature(), endMoving));
  19. myAnim()->setType(CCreatureAnim::MOVE_END);
  20. return true;
  21. }
  22. void CMovementEndAnimation::nextFrame()
  23. {
  24. if(myAnim()->onLastFrameInGroup())
  25. {
  26. endAnim();
  27. }
  28. }
  29. void CMovementEndAnimation::endAnim()
  30. {
  31. CBattleAnimation::endAnim();
  32. if(myAnim()->getType() != CCreatureAnim::DEATH)
  33. myAnim()->setType(CCreatureAnim::HOLDING); //resetting to default
  34. CCS->curh->show();
  35. delete this;
  36. }
  37. CMovementEndAnimation::CMovementEndAnimation(CBattleInterface * _owner, const CStack * _stack, SBattleHex destTile)
  38. : CBattleStackAnimation(_owner, _stack), destinationTile(destTile)
  39. {
  40. }