You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.8 KiB
65 lines
1.8 KiB
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Babushka.scripts.CSharp.Common.Fight.ActionDetails;
|
|
using Babushka.scripts.CSharp.Common.Util;
|
|
using Godot;
|
|
|
|
namespace Babushka.scripts.CSharp.Common.Fight.Actions;
|
|
|
|
public class AllyAttackAction : FighterAction
|
|
{
|
|
// details
|
|
public TargetSelectActionDetail targetSelect = new()
|
|
{
|
|
selectEnemy = true,
|
|
selectAlly = false
|
|
};
|
|
|
|
public MinigameActionDetail minigameDetail = new();
|
|
|
|
public override Variant<float, Func<bool>> GetAnimationEnd()
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
public override bool NextDetail()
|
|
{
|
|
return !targetSelect.DetailComplete() || !minigameDetail.DetailComplete();
|
|
}
|
|
|
|
public override FighterActionDetail CurrentDetail()
|
|
{
|
|
return targetSelect.DetailComplete() ? minigameDetail : targetSelect;
|
|
}
|
|
|
|
public override AllyActionButton BindToActionButton()
|
|
{
|
|
return AllyActionButton.Attack;
|
|
}
|
|
|
|
public override void Reset()
|
|
{
|
|
targetSelect.ResetResult();
|
|
minigameDetail.ResetResult();
|
|
}
|
|
|
|
public override void ExecuteAction()
|
|
{
|
|
var totalDamage = minigameDetail.damageHits!.Sum(dh => dh);
|
|
targetSelect.GetTarget().AddHealth(-totalDamage);
|
|
}
|
|
|
|
public override async Task AnimateAction(AllFightersVisual allFightersVisual)
|
|
{
|
|
var currentFighter = HappeningData.fighterTurn.Current;
|
|
var targetFighter = targetSelect.GetTarget();
|
|
|
|
var currentFighterVisual = allFightersVisual.GetVisualForFighter(currentFighter);
|
|
var targetFighterVisual = allFightersVisual.GetVisualForFighter(targetFighter);
|
|
|
|
await currentFighterVisual.AnimatePosToTarget(targetFighterVisual);
|
|
_ = targetFighterVisual.AnimateHit();
|
|
await currentFighterVisual.AnimatePosToBase();
|
|
}
|
|
} |