2011-12-13 21:35:28 +00:00
|
|
|
#include "StdInc.h"
|
|
|
|
#include "CReverseAnimation.h"
|
|
|
|
|
2011-12-17 18:59:59 +00:00
|
|
|
#include "CCreatureAnimation.h"
|
2011-12-13 21:35:28 +00:00
|
|
|
#include "../../lib/BattleState.h"
|
|
|
|
#include "CBattleInterface.h"
|
2011-12-17 18:59:59 +00:00
|
|
|
#include "CClickableHex.h"
|
2011-12-13 21:35:28 +00:00
|
|
|
|
|
|
|
bool CReverseAnimation::init()
|
|
|
|
{
|
|
|
|
if(myAnim() == NULL || myAnim()->getType() == 5)
|
|
|
|
{
|
|
|
|
endAnim();
|
|
|
|
|
|
|
|
return false; //there is no such creature
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!priority && !isEarliest(false))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if(myAnim()->framesInGroup(CCreatureAnim::TURN_R))
|
|
|
|
myAnim()->setType(CCreatureAnim::TURN_R);
|
|
|
|
else
|
|
|
|
setupSecondPart();
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReverseAnimation::nextFrame()
|
|
|
|
{
|
|
|
|
if(partOfAnim == 1) //first part of animation
|
|
|
|
{
|
|
|
|
if(myAnim()->onLastFrameInGroup())
|
|
|
|
{
|
|
|
|
partOfAnim = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(partOfAnim == 2)
|
|
|
|
{
|
|
|
|
if(!secondPartSetup)
|
|
|
|
{
|
|
|
|
setupSecondPart();
|
|
|
|
}
|
|
|
|
if(myAnim()->onLastFrameInGroup())
|
|
|
|
{
|
|
|
|
endAnim();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReverseAnimation::endAnim()
|
|
|
|
{
|
|
|
|
CBattleAnimation::endAnim();
|
|
|
|
if( stack->alive() )//don't do that if stack is dead
|
|
|
|
myAnim()->setType(CCreatureAnim::HOLDING);
|
|
|
|
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2011-12-17 18:59:59 +00:00
|
|
|
CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * stack, SBattleHex dest, bool _priority)
|
2011-12-13 21:35:28 +00:00
|
|
|
: CBattleStackAnimation(_owner, stack), partOfAnim(1), secondPartSetup(false), hex(dest), priority(_priority)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CReverseAnimation::setupSecondPart()
|
|
|
|
{
|
|
|
|
owner->creDir[stack->ID] = !owner->creDir[stack->ID];
|
|
|
|
|
|
|
|
if(!stack)
|
|
|
|
{
|
|
|
|
endAnim();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-17 18:59:59 +00:00
|
|
|
SPoint coords = CClickableHex::getXYUnitAnim(hex, owner->creDir[stack->ID], stack, owner);
|
2011-12-13 21:35:28 +00:00
|
|
|
myAnim()->pos.x = coords.x;
|
|
|
|
//creAnims[stackID]->pos.y = coords.second;
|
|
|
|
|
|
|
|
if(stack->doubleWide())
|
|
|
|
{
|
|
|
|
if(stack->attackerOwned)
|
|
|
|
{
|
|
|
|
if(!owner->creDir[stack->ID])
|
|
|
|
myAnim()->pos.x -= 44;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(owner->creDir[stack->ID])
|
|
|
|
myAnim()->pos.x += 44;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
secondPartSetup = true;
|
|
|
|
|
|
|
|
if(myAnim()->framesInGroup(CCreatureAnim::TURN_L))
|
|
|
|
myAnim()->setType(CCreatureAnim::TURN_L);
|
|
|
|
else
|
|
|
|
endAnim();
|
|
|
|
}
|