119 lines
3.2 KiB
C#
119 lines
3.2 KiB
C#
using RootMotion.FinalIK;
|
|
using UnityEngine;
|
|
|
|
public partial class FPlayer
|
|
{
|
|
/// <summary>
|
|
/// 把鱼线放手上
|
|
/// </summary>
|
|
/// <param name="lHandPoint"></param>
|
|
/// <param name="speed"></param>
|
|
public bool PutLineToLeftHandHelper(Transform lHandPoint, float speed = 1f)
|
|
{
|
|
var pin = Gears.Rod.lineHandler.pinchController;
|
|
if (!pin.isPinched)
|
|
{
|
|
pin.StartPinch(lHandPoint, speed);
|
|
}
|
|
|
|
if (pin.isPinched && Vector3.Distance(pin.transform.position, lHandPoint.position) < 0.1f)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
public float GetPlayerHandPower()
|
|
{
|
|
if (!Gears.Rod)
|
|
{
|
|
return 1f;
|
|
}
|
|
|
|
if (!Gears.Rod.lineHandler)
|
|
{
|
|
return 1f;
|
|
}
|
|
|
|
float num2 = 0f;
|
|
|
|
float value = 0.85f + num2;
|
|
value = Mathf.Clamp(value, 0.5f, 1.2f);
|
|
var num = (Gears.Rod.currentFish
|
|
? (1f - Mathf.Clamp01(Gears.Rod.currentLineTension * value))
|
|
: (1f - Mathf.Clamp01(Gears.Rod.linelenghtDiferent * 0.2f)));
|
|
return Mathf.Clamp(num, 0.2f, 1.2f);
|
|
}
|
|
|
|
private void MoveTowardsInteraction()
|
|
{
|
|
if (!interactionCCDIK)
|
|
{
|
|
return;
|
|
}
|
|
|
|
interactionCCDIK.solver.SetIKPositionWeight(Mathf.MoveTowards(interactionCCDIK.solver.IKPositionWeight,
|
|
interactionTargetWeight, Time.deltaTime * 2f));
|
|
if (Mathf.Approximately(interactionCCDIK.solver.IKPositionWeight, interactionTargetWeight))
|
|
{
|
|
if (interactionTargetWeight == 0f)
|
|
{
|
|
interactionCCDIK.solver.target = null;
|
|
// SetHandArmature(lHandPlayer, armatureLHandPosterIdle);
|
|
}
|
|
|
|
interactionCCDIK = null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 控制手和线轴交互
|
|
/// </summary>
|
|
/// <param name="interactiveObject"></param>
|
|
public void InteractiveMainHand(Transform interactiveObject)
|
|
{
|
|
if (!MainArm.TryGetComponent<CCDIK>(out var component))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (interactiveObject == null)
|
|
{
|
|
interactionTargetWeight = 0f;
|
|
interactionCCDIK = component;
|
|
if (Gears.Reel)
|
|
{
|
|
Data.isHandOnHandle = false;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
switch (interactiveObject.tag)
|
|
{
|
|
case "Reel":
|
|
component.solver.target = Gears.Reel.reelAsset.handle;
|
|
interactionTargetWeight = 1f;
|
|
interactionCCDIK = component;
|
|
if ((bool)Gears.Rod && (bool)Gears.Reel)
|
|
{
|
|
Data.isHandOnHandle = true;
|
|
}
|
|
|
|
break;
|
|
case "ReelUnlock":
|
|
// SetHandArmature(lHandPlayer, Gears.Reel.armatureLHandUnlockPoster);
|
|
// component.solver.target = Gears.Reel.reelAsset.koblagHandle;
|
|
interactionTargetWeight = 1f;
|
|
interactionCCDIK = component;
|
|
if ((bool)Gears.Rod && (bool)Gears.Reel)
|
|
{
|
|
Data.isHandOnHandle = false;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
} |