✨Added flying beet to the ui when used
This commit is contained in:
@@ -11,11 +11,11 @@ public partial class ActionAnimationController : Node
|
||||
#endregion
|
||||
|
||||
[Export] private AllFightersVisual _allFightersVisual = null!;
|
||||
|
||||
[Export] private FightHappeningAnimationContext _animationContext = null!;
|
||||
|
||||
public void StateEnter()
|
||||
{
|
||||
_ = HappeningData.actionStaging!.AnimateAction(_allFightersVisual);
|
||||
_ = HappeningData.actionStaging!.AnimateAction(_allFightersVisual,_animationContext);
|
||||
}
|
||||
|
||||
public void StateExit()
|
||||
|
||||
@@ -50,7 +50,8 @@ public class AllyAttackAction : FighterAction
|
||||
targetSelect.GetTarget().ChangeHealth(-totalDamage);
|
||||
}
|
||||
|
||||
public override async Task AnimateAction(AllFightersVisual allFightersVisual)
|
||||
public override async Task AnimateAction(AllFightersVisual allFightersVisual,
|
||||
FightHappeningAnimationContext animationContext)
|
||||
{
|
||||
var currentFighter = HappeningData.fighterTurn.Current;
|
||||
var targetFighter = targetSelect.GetTarget();
|
||||
|
||||
@@ -21,7 +21,8 @@ public class BlobAttackAction(int damage = 3) : FighterAction
|
||||
FightWorld.Instance.allyFighters.vesnaFighter.ChangeHealth(-damage);
|
||||
}
|
||||
|
||||
public override async Task AnimateAction(AllFightersVisual allFightersVisual)
|
||||
public override async Task AnimateAction(AllFightersVisual allFightersVisual,
|
||||
FightHappeningAnimationContext animationContext)
|
||||
{
|
||||
var currentFighter = HappeningData.fighterTurn.Current;
|
||||
var targetFighter = FightWorld.Instance.allyFighters.vesnaFighter;
|
||||
|
||||
@@ -21,11 +21,13 @@ public class EatBeetrootAction : FighterAction
|
||||
{ blueprint = FightWorld.Instance.itemBeetrootToEatForHealth });
|
||||
}
|
||||
|
||||
public override async Task AnimateAction(AllFightersVisual allFightersVisual)
|
||||
public override async Task AnimateAction(AllFightersVisual allFightersVisual,
|
||||
FightHappeningAnimationContext animationContext)
|
||||
{
|
||||
var fighter = HappeningData.fighterTurn.Current;
|
||||
var fighterVisual = allFightersVisual.GetVisualForFighter(fighter);
|
||||
fighterVisual.SpawnDamageIndicatorNumber($"+{HealAmount}");
|
||||
animationContext.useHealItemIndicator.SpawnIndicator();
|
||||
await fighterVisual.AnimateHeal();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class FightHappeningAnimationContext : Node
|
||||
{
|
||||
[Export] public UsedItemIndicatorVisual useHealItemIndicator = null!;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cdrjvgm82pxoj
|
||||
@@ -59,7 +59,9 @@ public abstract class FighterAction
|
||||
/// Animates the action.
|
||||
/// </summary>
|
||||
/// <param name="allFightersVisual"></param>
|
||||
public virtual async Task AnimateAction(AllFightersVisual allFightersVisual)
|
||||
/// <param name="animationContext"></param>
|
||||
public virtual async Task AnimateAction(AllFightersVisual allFightersVisual,
|
||||
FightHappeningAnimationContext animationContext)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class FighterDamageIndicatorVisual : Node2D
|
||||
{
|
||||
[Export] private PackedScene _flyingNumberPrefab;
|
||||
[Export] private PackedScene _flyingNumberPrefab = null!;
|
||||
|
||||
|
||||
public void SpawnFlyingNumber(string text)
|
||||
{
|
||||
var flyingNumberInstance = _flyingNumberPrefab.Instantiate<FighterDamageIndicatorFlyingNumber>();
|
||||
var flyingNumberInstance = _flyingNumberPrefab.Instantiate<FlyingIndicator>();
|
||||
AddChild(flyingNumberInstance);
|
||||
flyingNumberInstance.Initialize(text);
|
||||
}
|
||||
|
||||
+11
-5
@@ -3,13 +3,19 @@ using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class FighterDamageIndicatorFlyingNumber : Node2D
|
||||
public partial class FlyingIndicator : Node2D
|
||||
{
|
||||
[Export] private Label _label;
|
||||
|
||||
public void Initialize(string text)
|
||||
[Export] private Label _label = null!;
|
||||
[Export] private TextureRect _sprite = null!;
|
||||
|
||||
|
||||
public void Initialize(string? text = null, Texture2D? icon = null)
|
||||
{
|
||||
_label.Text = text;
|
||||
_label.Visible = text != null;
|
||||
_sprite.Visible = icon != null;
|
||||
|
||||
if (text != null) _label.Text = text;
|
||||
if (icon != null) _sprite.Texture = icon;
|
||||
|
||||
var tween = CreateTween();
|
||||
var xMovement = GD.RandRange(-150, 150);
|
||||
@@ -0,0 +1,17 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class UsedItemIndicatorVisual : Node2D
|
||||
{
|
||||
[Export] private PackedScene _flyingIndicatorPrefab = null!;
|
||||
[Export] private Texture2D _itemTexture = null!;
|
||||
|
||||
|
||||
public void SpawnIndicator()
|
||||
{
|
||||
var flyingNumberInstance = _flyingIndicatorPrefab.Instantiate<FlyingIndicator>();
|
||||
AddChild(flyingNumberInstance);
|
||||
flyingNumberInstance.Initialize(icon: _itemTexture);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://6nniwfxye8ss
|
||||
Reference in New Issue
Block a user