Skip to content

Commit

Permalink
Fix animation speed for attacks.
Browse files Browse the repository at this point in the history
Fix other players repeat attacking.
  • Loading branch information
ethanmoffat committed Mar 7, 2022
1 parent e84cfe9 commit 82e9d2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
11 changes: 7 additions & 4 deletions EOLib/PacketHandlers/PlayerAttackHandler.cs
Expand Up @@ -42,11 +42,14 @@ public override bool HandlePacket(IPacket packet)
}
catch (InvalidOperationException) { return false; }

var renderProperties = character.RenderProperties.WithDirection(direction);
var newCharacter = character.WithRenderProperties(renderProperties);
if (character.RenderProperties.Direction != direction)
{
var renderProperties = character.RenderProperties.WithDirection(direction);
var newCharacter = character.WithRenderProperties(renderProperties);

_currentMapStateRepository.Characters.Remove(character);
_currentMapStateRepository.Characters.Add(newCharacter);
_currentMapStateRepository.Characters.Remove(character);
_currentMapStateRepository.Characters.Add(newCharacter);
}

foreach (var notifier in _otherCharacterAnimationNotifiers)
notifier.StartOtherCharacterAttackAnimation(playerID);
Expand Down
12 changes: 4 additions & 8 deletions EndlessClient/Rendering/Character/CharacterAnimator.cs
Expand Up @@ -12,8 +12,8 @@ namespace EndlessClient.Rendering.Character
{
public class CharacterAnimator : GameComponent, ICharacterAnimator
{
public const int WALK_FRAME_TIME_MS = 480 / (CharacterRenderProperties.MAX_NUMBER_OF_WALK_FRAMES - 1);
public const int ATTACK_FRAME_TIME_MS = 600 / CharacterRenderProperties.MAX_NUMBER_OF_WALK_FRAMES;
public const int WALK_FRAME_TIME_MS = 120;
public const int ATTACK_FRAME_TIME_MS = 100;

private readonly ICharacterRepository _characterRepository;
private readonly ICurrentMapStateRepository _currentMapStateRepository;
Expand Down Expand Up @@ -116,14 +116,10 @@ public void StartOtherCharacterWalkAnimation(int characterID, byte destinationX,

public void StartOtherCharacterAttackAnimation(int characterID)
{
if (_otherPlayerStartWalkingTimes.ContainsKey(characterID) ||
_otherPlayerStartSpellCastTimes.ContainsKey(characterID))
return;

if (_otherPlayerStartAttackingTimes.TryGetValue(characterID, out var _))
{
ResetCharacterAnimationFrames(characterID);
_otherPlayerStartAttackingTimes.Remove(characterID);
_otherPlayerStartAttackingTimes[characterID].Replay = true;
return;
}

var startAttackingTimeAndID = new RenderFrameActionTime(characterID);
Expand Down

0 comments on commit 82e9d2e

Please sign in to comment.