CMovementStartAnimation.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "StdInc.h"
  2. #include "CMovementStartAnimation.h"
  3. #include "../CMusicHandler.h"
  4. #include "CBattleInterface.h"
  5. #include "../CGameInfo.h"
  6. #include "CCreatureAnimation.h"
  7. #include "../../lib/BattleState.h"
  8. #include "../CPlayerInterface.h"
  9. bool CMovementStartAnimation::init()
  10. {
  11. if( !isEarliest(false) )
  12. return false;
  13. if(!stack || myAnim()->getType() == 5)
  14. {
  15. CMovementStartAnimation::endAnim();
  16. return false;
  17. }
  18. CCS->soundh->playSound(battle_sound(stack->getCreature(), startMoving));
  19. myAnim()->setType(CCreatureAnim::MOVE_START);
  20. return true;
  21. }
  22. void CMovementStartAnimation::nextFrame()
  23. {
  24. if(myAnim()->onLastFrameInGroup())
  25. {
  26. endAnim();
  27. }
  28. else
  29. {
  30. if((owner->animCount+1)%(4/owner->curInt->sysOpts.animSpeed)==0)
  31. myAnim()->incrementFrame();
  32. }
  33. }
  34. void CMovementStartAnimation::endAnim()
  35. {
  36. CBattleAnimation::endAnim();
  37. delete this;
  38. }
  39. CMovementStartAnimation::CMovementStartAnimation(CBattleInterface * _owner, const CStack * _stack)
  40. : CBattleStackAnimation(_owner, _stack)
  41. {
  42. }