✨Added damage fly number
This commit is contained in:
@@ -60,6 +60,12 @@ public class AllyAttackAction : FighterAction
|
||||
|
||||
await currentFighterVisual.AnimatePosToTarget(targetFighterVisual);
|
||||
_ = targetFighterVisual.AnimateHit();
|
||||
|
||||
foreach (var hit in minigameDetail.damageHits!)
|
||||
{
|
||||
targetFighterVisual.SpawnDamageIndicatorNumber(hit);
|
||||
}
|
||||
|
||||
await currentFighterVisual.AnimatePosToBase();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,9 @@ namespace Babushka.scripts.CSharp.Common.Fight.Actions;
|
||||
|
||||
public class BlobAttackAction : FighterAction
|
||||
{
|
||||
// settings
|
||||
private const int Damage = 3;
|
||||
|
||||
public override Variant<float, Func<bool>> GetAnimationEnd()
|
||||
{
|
||||
return 1;
|
||||
@@ -18,7 +21,7 @@ public class BlobAttackAction : FighterAction
|
||||
|
||||
public override void ExecuteAction()
|
||||
{
|
||||
FightWorld.Instance.allyFighters.vesnaFighter.AddHealth(-3);
|
||||
FightWorld.Instance.allyFighters.vesnaFighter.AddHealth(-Damage);
|
||||
}
|
||||
|
||||
public override async Task AnimateAction(AllFightersVisual allFightersVisual)
|
||||
@@ -31,6 +34,7 @@ public class BlobAttackAction : FighterAction
|
||||
|
||||
await currentFighterVisual.AnimatePosToTarget(targetFighterVisual);
|
||||
_ = targetFighterVisual.AnimateHit();
|
||||
targetFighterVisual.SpawnDamageIndicatorNumber(Damage);
|
||||
await currentFighterVisual.AnimatePosToBase();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class FighterDamageIndicatorFlyingNumber : Node2D
|
||||
{
|
||||
[Export] private Label _label;
|
||||
|
||||
public void Initialize(int number)
|
||||
{
|
||||
_label.Text = number.ToString();
|
||||
|
||||
var tween = CreateTween();
|
||||
var xMovement = GD.RandRange(-150, 150);
|
||||
var yMovement = GD.RandRange(-400, -250);
|
||||
tween.Parallel().TweenProperty(this, "position:x", xMovement, .6);
|
||||
tween.Parallel().TweenProperty(this, "position:y", yMovement, .6)
|
||||
.SetEase(Tween.EaseType.Out).SetTrans(Tween.TransitionType.Quad);
|
||||
tween.Chain().TweenCallback(Callable.From(QueueFree));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://b5i41b6502xam
|
||||
@@ -0,0 +1,16 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class FighterDamageIndicatorVisual : Node2D
|
||||
{
|
||||
[Export] private PackedScene _flyingNumberPrefab;
|
||||
|
||||
|
||||
public void SpawnFlyingNumber(int number)
|
||||
{
|
||||
var flyingNumberInstance = _flyingNumberPrefab.Instantiate<FighterDamageIndicatorFlyingNumber>();
|
||||
AddChild(flyingNumberInstance);
|
||||
flyingNumberInstance.Initialize(number);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c250yp2mdq83e
|
||||
@@ -19,7 +19,11 @@ public partial class FighterVisual : Node2D
|
||||
[ExportCategory("References")]
|
||||
[Export] private Node2D _visualParent = null!;
|
||||
[Export] private Node2D _targetSelectionParent = null!;
|
||||
[Export] private Node2D _squashParent = null!;
|
||||
[Export] public FighterHealthBarVisual healthBarVisual = null!;
|
||||
[Export] private FighterDamageIndicatorVisual _fighterDamageIndicatorVisual;
|
||||
|
||||
|
||||
|
||||
|
||||
private FightWorld.Fighter _boundFighter;
|
||||
@@ -75,8 +79,8 @@ public partial class FighterVisual : Node2D
|
||||
public async Task AnimateHit()
|
||||
{
|
||||
var tween = GetTree().CreateTween();
|
||||
tween.TweenProperty(this, "scale", new Vector2(1.4f, 0.6f), 0.15);
|
||||
tween.TweenProperty(this, "scale", new Vector2(1, 1), 0.4)
|
||||
tween.TweenProperty(_squashParent, "scale", new Vector2(1.4f, 0.6f), 0.15);
|
||||
tween.TweenProperty(_squashParent, "scale", new Vector2(1, 1), 0.4)
|
||||
.SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
|
||||
await ToSignal(tween, "finished");
|
||||
}
|
||||
@@ -90,4 +94,8 @@ public partial class FighterVisual : Node2D
|
||||
// tween.TweenProperty(this, "scale", new Vector2(1, 1), 0.4)
|
||||
// .SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
|
||||
//}
|
||||
public void SpawnDamageIndicatorNumber(int number)
|
||||
{
|
||||
_fighterDamageIndicatorVisual.SpawnFlyingNumber(number);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user