Better action system
This commit is contained in:
1 parent
2bd71f8dc5
commit
71bb4c3b5b
110 files changed
+73523
-86288
No files matched your search
@@ -1,64 +1,64 @@
|
||||
using System.Linq;
|
||||
using Code.Infrastructure.Utils;
|
||||
using Code.OfficeGame.BattleMode.HitBoxes;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
public class BattleActionStugger : BattleAction
|
||||
{
|
||||
private Animator _animator;
|
||||
private EntityHitBoxes _entityHitBoxes;
|
||||
private int EntryStateHash => Animator.StringToHash("WalkBlend");
|
||||
private int StuggerStateHash => Animator.StringToHash("Stugger");
|
||||
|
||||
private BattleActionParameters _actionParameters;
|
||||
|
||||
private int _currentFrame;
|
||||
|
||||
[Inject]
|
||||
public void Construct(MultipleConfig<BattleActionParameters> actionData)
|
||||
{
|
||||
_animator = GetComponentInChildren<Animator>();
|
||||
_entityHitBoxes = GetComponent<EntityHitBoxes>();
|
||||
_actionParameters = actionData.Configs.SingleOrDefault(x => x.ActionType == ActionType);
|
||||
}
|
||||
public override async UniTask<BattleActionDecisionResult> DecideAction()
|
||||
{
|
||||
await UniTask.Yield();
|
||||
|
||||
_currentFrame = 0;
|
||||
Finished = false;
|
||||
|
||||
return new() { ResultCode = BattleActionDecisionResultCode.Decided, FrameDuration = _actionParameters.TotalFrames};
|
||||
|
||||
}
|
||||
|
||||
public override BattleActionType ActionType => BattleActionType.Stugger;
|
||||
|
||||
public override void Tick(float tickDelta)
|
||||
{
|
||||
if (Finished) return;
|
||||
|
||||
if (_currentFrame == 0)
|
||||
{
|
||||
_animator.Play(StuggerStateHash, 0, 0f);
|
||||
}
|
||||
|
||||
_currentFrame++;
|
||||
|
||||
if (_currentFrame >= _actionParameters.TotalFrames)
|
||||
{
|
||||
CompleteOrInterruptAction();
|
||||
}
|
||||
}
|
||||
|
||||
public void CompleteOrInterruptAction()
|
||||
{
|
||||
_animator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
|
||||
Finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// using System.Linq;
|
||||
// using Code.Infrastructure.Utils;
|
||||
// using Code.OfficeGame.BattleMode.HitBoxes;
|
||||
// using Cysharp.Threading.Tasks;
|
||||
// using Reflex.Attributes;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace Code.OfficeGame.BattleMode.Actions
|
||||
// {
|
||||
// public class BattleActionStugger : BattleAction
|
||||
// {
|
||||
// private Animator _animator;
|
||||
// private EntityHitBoxes _entityHitBoxes;
|
||||
// private int EntryStateHash => Animator.StringToHash("WalkBlend");
|
||||
// private int StuggerStateHash => Animator.StringToHash("Stugger");
|
||||
//
|
||||
// private BattleActionParameters _actionParameters;
|
||||
//
|
||||
// private int _currentFrame;
|
||||
//
|
||||
// [Inject]
|
||||
// public void Construct(MultipleConfig<BattleActionParameters> actionData)
|
||||
// {
|
||||
// _animator = GetComponentInChildren<Animator>();
|
||||
// _entityHitBoxes = GetComponent<EntityHitBoxes>();
|
||||
// _actionParameters = actionData.Configs.SingleOrDefault(x => x.ActionType == ActionType);
|
||||
// }
|
||||
// public override async UniTask<BattleActionDecisionResult> DecideAction()
|
||||
// {
|
||||
// await UniTask.Yield();
|
||||
//
|
||||
// _currentFrame = 0;
|
||||
// Finished = false;
|
||||
//
|
||||
// return new() { ResultCode = BattleActionDecisionResultCode.Decided, FrameDuration = _actionParameters.TotalFrames};
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public override BattleActionType ActionType => BattleActionType.Stugger;
|
||||
//
|
||||
// public override bool Tick(float tickDelta, EntityProperties entity)
|
||||
// {
|
||||
// if (Finished) return;
|
||||
//
|
||||
// if (_currentFrame == 0)
|
||||
// {
|
||||
// _animator.Play(StuggerStateHash, 0, 0f);
|
||||
// }
|
||||
//
|
||||
// _currentFrame++;
|
||||
//
|
||||
// if (_currentFrame >= _actionParameters.TotalFrames)
|
||||
// {
|
||||
// CompleteOrInterruptAction();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void CompleteOrInterruptAction()
|
||||
// {
|
||||
// _animator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
|
||||
// Finished = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
Reference in new issue
Block a user