mirror of
https://github.com/vcmi/vcmi.git
synced 2025-05-13 22:06:58 +02:00
* CHexFieldControl renamed to CClickableHex * CCreatureAnimation.cpp/.h moved to BattleInterface/CCreatureAnimation.cpp/.h * Removed unused project files * Added VCMI_client filters file for VS 2010 * Gathered common parts of StdInc.h in Global.h * Boost.Spirit has been included in PCH for ERM project * StopWatch renamed to CStopWatch * GuiBase.cpp split up in UIFramework/...
100 lines
1.9 KiB
C++
100 lines
1.9 KiB
C++
#include "StdInc.h"
|
|
#include "CReverseAnimation.h"
|
|
|
|
#include "CCreatureAnimation.h"
|
|
#include "../../lib/BattleState.h"
|
|
#include "CBattleInterface.h"
|
|
#include "CClickableHex.h"
|
|
|
|
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;
|
|
}
|
|
|
|
CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * stack, SBattleHex dest, bool _priority)
|
|
: 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;
|
|
}
|
|
|
|
SPoint coords = CClickableHex::getXYUnitAnim(hex, owner->creDir[stack->ID], stack, owner);
|
|
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();
|
|
} |