1
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITFALL.Player.Movement;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using BITKit.StateMachine;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -28,16 +31,46 @@ namespace BITFALL.Entities.Equipment.Melee
|
||||
[Serializable]
|
||||
public sealed class Idle:PlayerMeleeControllerState
|
||||
{
|
||||
|
||||
}
|
||||
[Serializable]
|
||||
public sealed class Run:PlayerMeleeControllerState
|
||||
{
|
||||
|
||||
[Inject]
|
||||
private IEntityMovement _movement;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_movement.OnStateChanged += OnMovementStateChanged;
|
||||
}
|
||||
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
meleeController.animator.CrossFade(BITConstant.Player.Idle,1f);
|
||||
}
|
||||
|
||||
public override void OnStateUpdate(float deltaTime)
|
||||
{
|
||||
base.OnStateUpdate(deltaTime);
|
||||
meleeController.animator.animator.SetBool(BITConstant.Player.IsRunning,_movement.CurrentState is IPlayerRunState or IPlayerSprintState);
|
||||
meleeController.animator.animator.SetBool(BITConstant.Player.IsGrounded,_movement.IsGrounded);
|
||||
meleeController.animator.animator.SetBool(BITConstant.Player.IsCrouched,_movement.CurrentState is IPlayerCrouchState);
|
||||
}
|
||||
|
||||
private void OnMovementStateChanged(IEntityMovementState arg1, IEntityMovementState arg2)
|
||||
{
|
||||
switch (arg2)
|
||||
{
|
||||
case IPlayerClimbState:
|
||||
case IPlayerLinkState:
|
||||
meleeController.animator.Play(BITConstant.Player.Climb);
|
||||
break;
|
||||
}
|
||||
|
||||
if (Enabled is false) return;
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
public sealed class Attack:PlayerMeleeControllerState
|
||||
{
|
||||
[Inject]
|
||||
private IEntityMovement _movement;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -47,31 +80,40 @@ namespace BITFALL.Entities.Equipment.Melee
|
||||
meleeController.TransitionState<Idle>();
|
||||
};
|
||||
}
|
||||
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
meleeController.animator.Play(BITConstant.Player.Attack);
|
||||
}
|
||||
public override void OnStateUpdate(float deltaTime)
|
||||
{
|
||||
base.OnStateUpdate(deltaTime);
|
||||
_movement.ExecuteCommand<PlayerCancelRunCommand>();
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
public sealed class Charging:PlayerMeleeControllerState
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
}
|
||||
[Inject]
|
||||
private IEntityMovement _movement;
|
||||
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
meleeController.animator.Play(BITConstant.Player.Charging);
|
||||
|
||||
}
|
||||
public override void OnStateUpdate(float deltaTime)
|
||||
{
|
||||
base.OnStateUpdate(deltaTime);
|
||||
_movement.ExecuteCommand<PlayerCancelRunCommand>();
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
public sealed class HeavyAttack:PlayerMeleeControllerState
|
||||
{
|
||||
[Inject]
|
||||
private IPlayerMovement _playerMovement;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -80,12 +122,33 @@ namespace BITFALL.Entities.Equipment.Melee
|
||||
if(Enabled && state is BITConstant.Player.HeavyAttack)
|
||||
meleeController.TransitionState<Idle>();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
meleeController.animator.Play(BITConstant.Player.HeavyAttack);
|
||||
_playerMovement.Stamina -= meleeController.melee.HeavyAttackStaminaCost;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class Blocking : PlayerMeleeControllerState
|
||||
{
|
||||
public bool AllowBlockStun => _interval.AllowUpdateWithoutReset is false;
|
||||
private readonly IntervalUpdate _interval = new(0.32f);
|
||||
[Inject]
|
||||
private IEntityMovement _movement;
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
_interval.Reset();
|
||||
meleeController.animator.Play(BITConstant.Player.Blocking);
|
||||
}
|
||||
public override void OnStateUpdate(float deltaTime)
|
||||
{
|
||||
base.OnStateUpdate(deltaTime);
|
||||
_movement.ExecuteCommand<PlayerCancelRunCommand>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user