Lil improvements
This commit is contained in:
1 parent
31850e77bc
commit
d00ce7bb0e
59 files changed
+79385
-23141
No files matched your search
@@ -0,0 +1,25 @@
|
||||
namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
public class AttackBattleActionData : BattleActionData
|
||||
{
|
||||
public int CurrentFrame;
|
||||
public override BattleActionData GetSnapshot()
|
||||
{
|
||||
var snapshot = new AttackBattleActionData()
|
||||
{
|
||||
TotalFrames = TotalFrames,
|
||||
CurrentFrame = CurrentFrame
|
||||
};
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public override void RestoreSnapshot(BattleActionData snapshot)
|
||||
{
|
||||
if (snapshot is not AttackBattleActionData neededSnapshot) return;
|
||||
|
||||
TotalFrames = neededSnapshot.TotalFrames;
|
||||
CurrentFrame = neededSnapshot.CurrentFrame;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64cdf1d355ea44ea8435dd8c4e2584d4
|
||||
timeCreated: 1793402627
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
public class StuggerActionData : BattleActionData
|
||||
{
|
||||
public int CurrentFrame;
|
||||
public override BattleActionData GetSnapshot()
|
||||
{
|
||||
var snapshot = new AttackBattleActionData()
|
||||
{
|
||||
TotalFrames = TotalFrames,
|
||||
CurrentFrame = CurrentFrame
|
||||
};
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public override void RestoreSnapshot(BattleActionData snapshot)
|
||||
{
|
||||
if (snapshot is not AttackBattleActionData neededSnapshot) return;
|
||||
|
||||
TotalFrames = neededSnapshot.TotalFrames;
|
||||
CurrentFrame = neededSnapshot.CurrentFrame;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 596b5dfe5898472e9bcd44bf1050209a
|
||||
timeCreated: 1793404253
|
||||
@@ -1,147 +1,81 @@
|
||||
// using System.Linq;
|
||||
// using System.Threading;
|
||||
// using Code.Infrastructure.Input;
|
||||
// using Code.Infrastructure.Utils;
|
||||
// using Code.OfficeGame.BattleMode.Actions.Deciders;
|
||||
// using Code.OfficeGame.BattleMode.Actions.HoloCopy;
|
||||
// using Code.OfficeGame.BattleMode.HitBoxes;
|
||||
// using Cysharp.Threading.Tasks;
|
||||
// using Reflex.Attributes;
|
||||
// using UnityEngine;
|
||||
// using UnityEngine.InputSystem;
|
||||
//
|
||||
// namespace Code.OfficeGame.BattleMode.Actions.Attacks
|
||||
// {
|
||||
// public class BattleActionPlayerAttackMMA : BattleAction
|
||||
// {
|
||||
// [SerializeField] private HoloCop holoCop;
|
||||
// [SerializeField] private Animator animator;
|
||||
// private EntityHitBoxes _entityHitBoxes;
|
||||
// private AttackActionConfig _attackData;
|
||||
// public int EntryStateHash => Animator.StringToHash("WalkBlend");
|
||||
//
|
||||
// private int _currentFrame;
|
||||
// private IInputService _inputService;
|
||||
// private CancellationTokenSource _waitForEnterTokenSource;
|
||||
// private BattleActionDecisionResultCode _decisionResultCode;
|
||||
//
|
||||
// [Inject]
|
||||
// public void Construct(MultipleConfig<BattleActionParameters> attackData, IInputService inputService)
|
||||
// {
|
||||
// _inputService = inputService;
|
||||
//
|
||||
// _entityHitBoxes = GetComponent<EntityHitBoxes>();
|
||||
//
|
||||
// _attackData = (AttackActionConfig) attackData.Configs.SingleOrDefault(x=>x.ActionType == ActionType);
|
||||
// }
|
||||
//
|
||||
// public override async UniTask<BattleActionDecisionResult> DecideAction()
|
||||
// {
|
||||
// _currentFrame = 0;
|
||||
// Finished = false;
|
||||
//
|
||||
// _waitForEnterTokenSource = new CancellationTokenSource();
|
||||
// _decisionResultCode = BattleActionDecisionResultCode.CancelDecision;
|
||||
//
|
||||
// _inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Confirm,
|
||||
// ConfirmAttack);
|
||||
// _inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Cancel,
|
||||
// CancelAttack);
|
||||
//
|
||||
// holoCop.Simulate(TickHoloCopy, _waitForEnterTokenSource.Token).Forget();
|
||||
//
|
||||
// await UniTask.WaitUntilCanceled(_waitForEnterTokenSource.Token).SuppressCancellationThrow();
|
||||
//
|
||||
// _inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Confirm,
|
||||
// ConfirmAttack);
|
||||
// _inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Cancel,
|
||||
// CancelAttack);
|
||||
//
|
||||
// _currentFrame = 0;
|
||||
//
|
||||
// return new() { ResultCode = _decisionResultCode, FrameDuration = _attackData.TotalFrames};
|
||||
// }
|
||||
//
|
||||
// private void CancelAttack(InputAction.CallbackContext obj)
|
||||
// {
|
||||
// _decisionResultCode = BattleActionDecisionResultCode.CancelDecision;
|
||||
// _waitForEnterTokenSource?.Cancel();
|
||||
// }
|
||||
//
|
||||
// private void ConfirmAttack(InputAction.CallbackContext obj)
|
||||
// {
|
||||
// _decisionResultCode = BattleActionDecisionResultCode.Decided;
|
||||
// _waitForEnterTokenSource?.Cancel();
|
||||
// }
|
||||
//
|
||||
// public override BattleActionType ActionType => BattleActionType.PlayerAttackMMA;
|
||||
//
|
||||
// public override bool Tick(float tickDelta, EntityProperties entity)
|
||||
// {
|
||||
// if (Finished) return;
|
||||
//
|
||||
// if (_currentFrame == 0)
|
||||
// {
|
||||
// // TODO Root Motion не должен быть использован в нормальных анимациях
|
||||
// animator.applyRootMotion = true;
|
||||
// animator.Play(_attackData.StateHash, 0, 0f);
|
||||
// }
|
||||
//
|
||||
// _currentFrame++;
|
||||
//
|
||||
// if (_currentFrame >= _attackData.HitboxStartFrame && _currentFrame <= _attackData.HitboxEndFrame)
|
||||
// {
|
||||
// _entityHitBoxes.CheckHitsForCurrentFrame(OnEnemyHit, HitBoxPartType.LArm);
|
||||
// }
|
||||
//
|
||||
// if (_currentFrame >= _attackData.TotalFrames)
|
||||
// {
|
||||
// CompleteOrInterruptAction();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public override DeciderType DeciderType => DeciderType.Position;
|
||||
//
|
||||
// private void OnEnemyHit(Collider enemyCollider)
|
||||
// {
|
||||
// Debug.Log($"Попадание в {enemyCollider.name} на {_currentFrame}-м кадре! Урон: {_attackData.Damage}");
|
||||
// var entityActor = enemyCollider.GetComponentInParent<EntityTimelineActor>();
|
||||
// entityActor.ForceDecideAction(BattleActionType.Stugger);
|
||||
// }
|
||||
//
|
||||
// public void CompleteOrInterruptAction()
|
||||
// {
|
||||
// animator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
|
||||
// animator.Update(0f);
|
||||
//
|
||||
// // TODO С нормальными анимациями не нужен будет рут моушен√
|
||||
// animator.applyRootMotion = false;
|
||||
// animator.transform.localPosition = Vector3.zero;
|
||||
// animator.transform.localRotation = Quaternion.identity;
|
||||
//
|
||||
// Finished = true;
|
||||
// }
|
||||
//
|
||||
// // HoloCopy
|
||||
//
|
||||
// private bool TickHoloCopy(HoloCop holoCop, float tickDelta)
|
||||
// {
|
||||
// if (_currentFrame == 0)
|
||||
// {
|
||||
// holoCop.Animator.applyRootMotion = true;
|
||||
// holoCop.Animator.Play(_attackData.StateHash, 0, 0f);
|
||||
// }
|
||||
//
|
||||
// _currentFrame++;
|
||||
//
|
||||
// if(_currentFrame >= _attackData.TotalFrames)
|
||||
// {
|
||||
// _currentFrame = 0;
|
||||
// holoCop.Animator.applyRootMotion = false;
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
using System.Linq;
|
||||
using Code.Infrastructure.Utils;
|
||||
using Code.OfficeGame.BattleMode.Actions.Deciders;
|
||||
using Code.OfficeGame.BattleMode.HitBoxes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions.Attacks
|
||||
{
|
||||
public class BattleActionPlayerAttackMMA : BattleAction
|
||||
{
|
||||
private AttackActionConfig _attackData;
|
||||
public int EntryStateHash => Animator.StringToHash("WalkBlend");
|
||||
|
||||
public BattleActionPlayerAttackMMA(MultipleConfig<BattleActionParameters> attackData)
|
||||
{
|
||||
_attackData = (AttackActionConfig)
|
||||
attackData.Configs.SingleOrDefault(x=>x.ActionType == ActionType);
|
||||
}
|
||||
public override BattleActionType ActionType => BattleActionType.PlayerAttackMMA;
|
||||
|
||||
public override bool Tick(float tickDelta,
|
||||
EntityProperties entity,
|
||||
BattleActionDecisionResult battleActionDecisionResult,
|
||||
BattleActionData battleActionData)
|
||||
{
|
||||
if (battleActionData is not AttackBattleActionData actionData) return true;
|
||||
|
||||
if (actionData.CurrentFrame == 0)
|
||||
{
|
||||
var entityAnimator = entity.animator;
|
||||
|
||||
// TODO Root Motion не должен быть использован в нормальных анимациях
|
||||
entityAnimator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
|
||||
entityAnimator.Update(0f);
|
||||
|
||||
entityAnimator.applyRootMotion = false;
|
||||
entityAnimator.transform.localPosition = Vector3.zero;
|
||||
entityAnimator.transform.localRotation = Quaternion.identity;
|
||||
|
||||
entityAnimator.applyRootMotion = true;
|
||||
entityAnimator.Play(_attackData.StateHash, 0, 0f);
|
||||
}
|
||||
|
||||
actionData.CurrentFrame++;
|
||||
|
||||
if (actionData.CurrentFrame >= _attackData.HitboxStartFrame
|
||||
&& actionData.CurrentFrame <= _attackData.HitboxEndFrame)
|
||||
{
|
||||
entity.EntityHitBoxes.CheckHitsForCurrentFrame(OnEnemyHit, HitBoxPartType.LArm);
|
||||
}
|
||||
|
||||
if (actionData.CurrentFrame >= _attackData.TotalFrames)
|
||||
{
|
||||
var entityAnimator = entity.animator;
|
||||
|
||||
entityAnimator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
|
||||
entityAnimator.Update(0f);
|
||||
|
||||
// TODO С нормальными анимациями не нужен будет рут моушен√
|
||||
entityAnimator.applyRootMotion = false;
|
||||
entityAnimator.transform.localPosition = Vector3.zero;
|
||||
entityAnimator.transform.localRotation = Quaternion.identity;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override DeciderType DeciderType => DeciderType.Position;
|
||||
public override BattleActionData MountAndGetFrames(EntityProperties entity, BattleActionDecisionResult result)
|
||||
{
|
||||
return new AttackBattleActionData() { TotalFrames = _attackData.TotalFrames };
|
||||
}
|
||||
|
||||
private void OnEnemyHit(Collider enemyCollider)
|
||||
{
|
||||
Debug.Log($"Попадание в {enemyCollider.name}! Урон: {_attackData.Damage}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +1,52 @@
|
||||
// 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;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
using System.Linq;
|
||||
using Code.Infrastructure.Utils;
|
||||
using Code.OfficeGame.BattleMode.Actions.Deciders;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
public class BattleActionStugger : BattleAction
|
||||
{
|
||||
private int EntryStateHash => Animator.StringToHash("WalkBlend");
|
||||
private int StuggerStateHash => Animator.StringToHash("Stugger");
|
||||
|
||||
private BattleActionParameters _actionParameters;
|
||||
|
||||
[Inject]
|
||||
public void Construct(MultipleConfig<BattleActionParameters> actionData)
|
||||
{
|
||||
_actionParameters = actionData.Configs.SingleOrDefault(x => x.ActionType == ActionType);
|
||||
}
|
||||
|
||||
public override BattleActionType ActionType => BattleActionType.Stugger;
|
||||
public override DeciderType DeciderType => DeciderType.AsIs;
|
||||
public override BattleActionData MountAndGetFrames(EntityProperties entity, BattleActionDecisionResult result)
|
||||
{
|
||||
return new StuggerActionData { TotalFrames = _actionParameters.TotalFrames};
|
||||
}
|
||||
|
||||
public override bool Tick(float tickDelta,
|
||||
EntityProperties entity,
|
||||
BattleActionDecisionResult battleActionDecisionResult,
|
||||
BattleActionData battleActionData)
|
||||
{
|
||||
if (battleActionData is not StuggerActionData stuggerActionData) return true;
|
||||
|
||||
if (stuggerActionData.CurrentFrame == 0)
|
||||
{
|
||||
entity.animator.Play(StuggerStateHash, 0, 0f);
|
||||
}
|
||||
|
||||
stuggerActionData.CurrentFrame++;
|
||||
|
||||
if (stuggerActionData.CurrentFrame >= _actionParameters.TotalFrames)
|
||||
{
|
||||
entity.animator.Play(EntryStateHash, 0, 0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Code.Game.Gameplay.Player;
|
||||
using Code.OfficeGame.BattleMode.HitBoxes;
|
||||
using KinematicCharacterController;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -11,5 +12,6 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
|
||||
public MovementController MovementController;
|
||||
public KinematicCharacterMotor KinematicCharacterMotor;
|
||||
public EntityHitBoxes EntityHitBoxes;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user