Stagger now
This commit is contained in:
1 parent
e61fcb78cf
commit
c8626a9806
718 files changed
+93824
-212081
No files matched your search
@@ -1,21 +1,11 @@
|
||||
using Code.Infrastructure.Generators;
|
||||
using Code.OfficeGame.BattleMode.HitBoxes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions.Attacks
|
||||
{
|
||||
[Config("Configs/AttackAction", true)]
|
||||
[CreateAssetMenu(fileName = "AttackActionConfig", menuName = "Configs/AttackAction")]
|
||||
public class AttackActionConfig : ScriptableObject
|
||||
public class AttackActionConfig : BattleActionParameters
|
||||
{
|
||||
public BattleActionType ActionType;
|
||||
|
||||
public AnimationClip AnimationClip;
|
||||
|
||||
public int StateHash => Animator.StringToHash(AnimationClip.name);
|
||||
|
||||
public int TotalFrames;
|
||||
|
||||
public int HitboxStartFrame;
|
||||
|
||||
public int HitboxEndFrame;
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace Code.OfficeGame.BattleMode.Actions.Attacks
|
||||
private int _currentFrame;
|
||||
|
||||
[Inject]
|
||||
public void Construct(MultipleConfig<AttackActionConfig> attackData)
|
||||
public void Construct(MultipleConfig<BattleActionParameters> attackData)
|
||||
{
|
||||
_animator = GetComponentInChildren<Animator>();
|
||||
_entityHitBoxes = GetComponent<EntityHitBoxes>();
|
||||
_attackData = attackData.Configs.SingleOrDefault(x=>x.ActionType == ActionType);
|
||||
_attackData = (AttackActionConfig) attackData.Configs.SingleOrDefault(x=>x.ActionType == ActionType);
|
||||
}
|
||||
|
||||
public override async UniTask<BattleActionDecisionResultCode> DecideAction()
|
||||
@@ -64,6 +64,9 @@ namespace Code.OfficeGame.BattleMode.Actions.Attacks
|
||||
private void OnEnemyHit(Collider enemyCollider)
|
||||
{
|
||||
Debug.Log($"Попадание в {enemyCollider.name} на {_currentFrame}-м кадре! Урон: {_attackData.Damage}");
|
||||
var entityActor = enemyCollider.GetComponentInParent<EntityTimelineActor>();
|
||||
entityActor.ForceDecideAction(BattleActionType.Stugger);
|
||||
|
||||
}
|
||||
|
||||
public void CompleteOrInterruptAction()
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using Code.Infrastructure.Generators;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
[Config("Configs/BattleAction", true)]
|
||||
[CreateAssetMenu(fileName = "BattleActionConfig", menuName = "Configs/BattleAction")]
|
||||
public class BattleActionParameters: ScriptableObject
|
||||
{
|
||||
public BattleActionType ActionType;
|
||||
|
||||
public AnimationClip AnimationClip;
|
||||
|
||||
public int StateHash => Animator.StringToHash(AnimationClip.name);
|
||||
|
||||
public int TotalFrames;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c9ef585559248f0ba66635a85a6c829
|
||||
timeCreated: 1793025207
|
||||
@@ -0,0 +1,61 @@
|
||||
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<BattleActionDecisionResultCode> DecideAction()
|
||||
{
|
||||
_currentFrame = 0;
|
||||
Finished = false;
|
||||
|
||||
return BattleActionDecisionResultCode.Decided;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91ff2d61ed324b62957ec67153dcfcd5
|
||||
timeCreated: 1793024093
|
||||
@@ -5,6 +5,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
None,
|
||||
Wait,
|
||||
Move,
|
||||
PlayerAttackMMA
|
||||
PlayerAttackMMA,
|
||||
Stugger
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
public bool Finished => CurrentAction == null || CurrentAction.Finished;
|
||||
|
||||
public abstract UniTask DecideAction(CancellationToken ctx);
|
||||
public abstract void ForceDecideAction(BattleActionType actionType);
|
||||
|
||||
[DoNotSerialize] public Animator animator;
|
||||
|
||||
|
||||
@@ -41,5 +41,11 @@ namespace Code.OfficeGame.BattleMode.Actions.Player
|
||||
}
|
||||
CurrentAction = BattleActions[decidedAction];
|
||||
}
|
||||
|
||||
public override void ForceDecideAction(BattleActionType actionType)
|
||||
{
|
||||
CurrentAction = BattleActions[actionType];
|
||||
CurrentAction.DecideAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.HitBoxes
|
||||
{
|
||||
// TODO Добавить меотды отключения,чтобы не получать урон во время стаггера
|
||||
public class EntityHitBoxes : MonoBehaviour
|
||||
{
|
||||
[Serializable]
|
||||
|
||||
Reference in new issue
Block a user