Added basic action animation

This commit is contained in:
jonathan
2025-09-30 17:36:28 +02:00
parent 0e315396c9
commit 9bf25640f6
8 changed files with 120 additions and 23 deletions
+41 -16
View File
@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using Babushka.scripts.CSharp.Common.Fight.ActionDetails;
using Godot;
using Godot.Collections;
@@ -67,31 +68,55 @@ public partial class FighterVisual : Node2D
}
// Animations
public void AttackAnimation(FightAttack attack)
//public void AttackAnimation(FightAttack attack)
//{
// EmitSignalAttacking();
// var tween = GetTree().CreateTween();
// tween.TweenProperty(this, "global_position", attack.target.GlobalPosition, 0.15);
// tween.TweenCallback(Callable.From(() => attack.target?.HitAnimation(attack)));
// tween.TweenProperty(this, "position", new Vector2(0, 0), 0.7)
// .SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
//}
public async Task AnimatePosToTarget(FighterVisual targetVisual, double duration = 0.15)
{
EmitSignalAttacking();
var tween = GetTree().CreateTween();
tween.TweenProperty(this, "global_position", attack.target.GlobalPosition, 0.15);
tween.TweenCallback(Callable.From(() => attack.target?.HitAnimation(attack)));
tween.TweenProperty(this, "position", new Vector2(0, 0), 0.7)
.SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
tween.TweenProperty(_visualParent, "global_position", targetVisual.GlobalPosition, 0.15);
await ToSignal(tween, "finished");
}
private void HitAnimation(FightAttack attack)
public async Task AnimatePosToBase(double duration = 0.7)
{
var tween = GetTree().CreateTween();
tween.TweenProperty(_visualParent, "position", new Vector2(0, 0), 0.15);
await ToSignal(tween, "finished");
}
public async Task AnimateHit()
{
EmitSignalDamageTaken();
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)
.SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
await ToSignal(tween, "finished");
}
public void HealAnimation()
{
EmitSignalHealed();
var tween = GetTree().CreateTween();
tween.TweenProperty(this, "scale", new Vector2(0.6f, 1.4f), 0.15);
tween.TweenProperty(this, "scale", new Vector2(1, 1), 0.4)
.SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
}
//private void HitAnimation(FightAttack attack)
//{
// EmitSignalDamageTaken();
// 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)
// .SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
//}
//
//public void HealAnimation()
//{
// EmitSignalHealed();
// var tween = GetTree().CreateTween();
// tween.TweenProperty(this, "scale", new Vector2(0.6f, 1.4f), 0.15);
// tween.TweenProperty(this, "scale", new Vector2(1, 1), 0.4)
// .SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
//}
}