拿起放下物品
This commit is contained in:
@@ -44,6 +44,8 @@ namespace NBF
|
||||
else if (action == InputDef.Player.ToBag)
|
||||
{
|
||||
//取消手持物品
|
||||
Log.Info($"取消手持物品");
|
||||
Game.Instance.StartCoroutine(UnUseItem());
|
||||
}
|
||||
else if (action.StartsWith(InputDef.Player.QuickStarts))
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ using NBF.Fishing2;
|
||||
using NBF.Utils;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
@@ -28,6 +29,9 @@ namespace NBF
|
||||
public readonly List<FRod> Tackles = new List<FRod>();
|
||||
public FRod Rod { get; private set; }
|
||||
|
||||
public event Action<FHandItem> OnFishingSetEquiped;
|
||||
public event Action OnFishingSetUnequip;
|
||||
|
||||
protected override void OnAwake()
|
||||
{
|
||||
Character = gameObject.GetComponent<CharacterMovement>();
|
||||
@@ -81,9 +85,24 @@ namespace NBF
|
||||
}
|
||||
|
||||
Rod =
|
||||
item.Config.InstantiateAndComponent<FRod>(SceneSettings.Instance.GearNode, Vector3.zero, Quaternion.identity);
|
||||
item.Config.InstantiateAndComponent<FRod>(SceneSettings.Instance.GearNode, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
yield return Rod.InitRod(this, item);
|
||||
Tackles.Add(Rod);
|
||||
OnFishingSetEquiped?.Invoke(Rod);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator UnUseItem()
|
||||
{
|
||||
OnFishingSetUnequip?.Invoke();
|
||||
if (Rod != null)
|
||||
{
|
||||
yield return new WaitForSeconds(0.35f);
|
||||
yield return Rod.Destroy();
|
||||
Destroy(Rod.gameObject);
|
||||
Tackles.Remove(Rod);
|
||||
Rod = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,24 +58,18 @@ namespace NBF
|
||||
_Animator.keepAnimatorStateOnDisable = true;
|
||||
_IK = GetComponent<PlayerIK>();
|
||||
_isInit = true;
|
||||
|
||||
Player.OnFishingSetEquiped += OnFishingSetEquiped_OnRaised;
|
||||
Player.OnFishingSetUnequip += OnFishingSetUnequip;
|
||||
Player.Data.OnStateChange += PlayerFSMState_OnValueChanged;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Player.OnFishingSetEquiped -= OnFishingSetEquiped_OnRaised;
|
||||
Player.OnFishingSetUnequip -= OnFishingSetUnequip;
|
||||
Player.Data.OnStateChange += PlayerFSMState_OnValueChanged;
|
||||
}
|
||||
|
||||
// private void OnEnable()
|
||||
// {
|
||||
// playerFSMState.OnValueChanged += PlayerFSMState_OnValueChanged;
|
||||
// }
|
||||
//
|
||||
// private void OnDisable()
|
||||
// {
|
||||
// playerFSMState.OnValueChanged -= PlayerFSMState_OnValueChanged;
|
||||
// }
|
||||
|
||||
private void OnFishingSetUnequip()
|
||||
{
|
||||
@@ -99,12 +93,18 @@ namespace NBF
|
||||
// }
|
||||
}
|
||||
|
||||
// private void OnFishingSetEquiped_OnRaised(FishingSetController set)
|
||||
// {
|
||||
// _isTorsoLayerEnabled = true;
|
||||
// var reel = Player.Rod.Reel;
|
||||
// // _IK.SetBipedLeftHandIK(enabled: false, reel.FingersIKAnchor);
|
||||
// }
|
||||
private void OnFishingSetEquiped_OnRaised(FHandItem item)
|
||||
{
|
||||
if (item is FRod rod)
|
||||
{
|
||||
_isTorsoLayerEnabled = true;
|
||||
// var reel = Player.Rod.Reel;
|
||||
// _IK.SetBipedLeftHandIK(enabled: false, reel.FingersIKAnchor);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayAnimation(string state, string layer)
|
||||
{
|
||||
@@ -233,40 +233,5 @@ namespace NBF
|
||||
SetLayerWeight(Torso,
|
||||
Mathf.MoveTowards(layerWeight, _isTorsoLayerEnabled ? 1f : 0f, Time.deltaTime * 3f));
|
||||
}
|
||||
|
||||
|
||||
// private void LateUpdate()
|
||||
// {
|
||||
// if (!_isInit) return;
|
||||
// UpdateAnimator();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private void UpdateAnimator()
|
||||
// {
|
||||
// Animator.SetBool(OnGround, Player.Data.IsGrounded);
|
||||
// float value3 = Mathf.Lerp(Animator.GetFloat(Forward), Player.Data.Speed / 5f, Time.deltaTime * 20f);
|
||||
// Animator.SetFloat(Forward, value3);
|
||||
//
|
||||
// // 平滑处理
|
||||
// // float smoothedTurn = Mathf.SmoothDamp(Animator.GetFloat(Turn),
|
||||
// // MapUnit.RotationSpeed,
|
||||
// // ref turnSmoothVelocity,
|
||||
// // smoothingTime
|
||||
// // );
|
||||
//
|
||||
// float smoothedTurn = Mathf.Lerp(Animator.GetFloat(Turn), Player.Data.RotationSpeed, Time.deltaTime * 10f);
|
||||
// Animator.SetFloat(Turn, smoothedTurn);
|
||||
//
|
||||
//
|
||||
// float layerWeight = Animator.GetLayerWeight(Animator.GetLayerIndex(Torso));
|
||||
// SetLayerWeight(Torso,
|
||||
// Mathf.MoveTowards(layerWeight, _isTorsoLayerEnabled ? 1f : 0f, Time.deltaTime * 3f));
|
||||
// }
|
||||
//
|
||||
// public void SetLayerWeight(string layer, float weight)
|
||||
// {
|
||||
// Animator.SetLayerWeight(Animator.GetLayerIndex(layer), weight);
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user