1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fixed 3206 Bugged 'Start Walking' animation

This commit is contained in:
Evgeniy Meshcheryakov 2022-08-12 11:38:09 +03:00 committed by Andrii Danylchenko
parent c0825149cf
commit ff00747ecf
4 changed files with 18 additions and 19 deletions

View File

@ -420,22 +420,6 @@ void CMeleeAttackAnimation::endAnim()
delete this;
}
bool CMovementAnimation::shouldRotate()
{
Point begPosition = CClickableHex::getXYUnitAnim(oldPos, stack, owner);
Point endPosition = CClickableHex::getXYUnitAnim(nextHex, stack, owner);
if((begPosition.x > endPosition.x) && owner->creDir[stack->ID] == true)
{
return true;
}
else if ((begPosition.x < endPosition.x) && owner->creDir[stack->ID] == false)
{
return true;
}
return false;
}
bool CMovementAnimation::init()
{
if( !isEarliest(false) )
@ -456,7 +440,7 @@ bool CMovementAnimation::init()
}
//reverse unit if necessary
if(shouldRotate())
if(owner->shouldRotate(stack, oldPos, nextHex))
{
// it seems that H3 does NOT plays full rotation animation here in most situations
// Logical since it takes quite a lot of time

View File

@ -118,8 +118,6 @@ public:
class CMovementAnimation : public CBattleStackAnimation
{
private:
bool shouldRotate();
std::vector<BattleHex> destTiles; //full path, includes already passed hexes
ui32 curentMoveIndex; // index of nextHex in destTiles

View File

@ -1559,6 +1559,19 @@ CPlayerInterface *CBattleInterface::getCurrentPlayerInterface() const
return curInt.get();
}
bool CBattleInterface::shouldRotate(const CStack * stack, const BattleHex & oldPos, const BattleHex & nextHex)
{
Point begPosition = CClickableHex::getXYUnitAnim(oldPos,stack, this);
Point endPosition = CClickableHex::getXYUnitAnim(nextHex, stack, this);
if((begPosition.x > endPosition.x) && creDir[stack->ID])
return true;
else if((begPosition.x < endPosition.x) && !creDir[stack->ID])
return true;
return false;
}
void CBattleInterface::setActiveStack(const CStack *stack)
{
if (activeStack) // update UI
@ -1926,6 +1939,9 @@ void CBattleInterface::startAction(const BattleAction* action)
{
pendingAnims.push_back(std::make_pair(new CMovementStartAnimation(this, stack), false));
}
if(shouldRotate(stack, stack->getPosition(), actionTarget.at(0).hexValue))
pendingAnims.push_back(std::make_pair(new CReverseAnimation(this, stack, stack->getPosition(), true), false));
}
redraw(); // redraw after deactivation, including proper handling of hovered hexes

View File

@ -294,6 +294,7 @@ public:
void setAnimSpeed(int set); //speed of animation; range 1..100
int getAnimSpeed() const; //speed of animation; range 1..100
CPlayerInterface *getCurrentPlayerInterface() const;
bool shouldRotate(const CStack * stack, const BattleHex & oldPos, const BattleHex & nextHex);
std::vector<std::shared_ptr<CClickableHex>> bfield; //11 lines, 17 hexes on each
SDL_Surface *cellBorder, *cellShade;