upfste
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using NBC;
|
||||
using NBF;
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
||||
@@ -40,10 +41,10 @@ public partial class FPlayer : MonoBehaviour
|
||||
|
||||
public FPlayerUseGear Gears;
|
||||
|
||||
public LineRenderer LineRenderer;
|
||||
|
||||
public LureTrajectorySimulator LureTrajectorySimulator;
|
||||
|
||||
public Transform Light;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
PlayerAnimatorCtrl = gameObject.GetComponent<PlayerAnimator>();
|
||||
@@ -58,7 +59,6 @@ public partial class FPlayer : MonoBehaviour
|
||||
Gears = gameObject.AddComponent<FPlayerUseGear>();
|
||||
}
|
||||
|
||||
LineRenderer = gameObject.GetComponent<LineRenderer>();
|
||||
LureTrajectorySimulator = gameObject.AddComponent<LureTrajectorySimulator>();
|
||||
|
||||
PlayerAnimatorCtrl.Player = this;
|
||||
@@ -156,17 +156,44 @@ public partial class FPlayer : MonoBehaviour
|
||||
Gears?.Update();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.F))
|
||||
SyncLight();
|
||||
}
|
||||
|
||||
private void SyncLight()
|
||||
{
|
||||
if (Light)
|
||||
{
|
||||
var points = LureTrajectorySimulator.Test(BaseCamera.Main.transform);
|
||||
|
||||
// FishingCastInput exampleInput = FishingCastInput.Default();
|
||||
// points = LureTrajectorySimulator.CalculateTrajectory(exampleInput);
|
||||
|
||||
|
||||
Light.localRotation = BaseCamera.Main.transform.localRotation;
|
||||
if (Light.gameObject.activeSelf != Data.openLight)
|
||||
{
|
||||
Light.gameObject.SetActive(Data.openLight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Tween _fovTween; // 存储当前的Tween动画,方便中断
|
||||
private float _zoomDuration = 0.2f; // 缩放动画时间
|
||||
|
||||
/// <summary>
|
||||
/// 切换望远镜效果(打开/关闭)
|
||||
/// </summary>
|
||||
/// <param name="isZoomIn">true=打开望远镜,false=关闭望远镜</param>
|
||||
public void ToggleTelescope()
|
||||
{
|
||||
// 如果已经有动画在运行,先停止
|
||||
_fovTween?.Kill();
|
||||
|
||||
// 根据传入的参数决定目标FOV
|
||||
float targetFOV = Data.openTelescope ? GameDef.ZoomedFOV : GameDef.NormalFOV;
|
||||
|
||||
// 使用DoTween平滑过渡FOV
|
||||
_fovTween = DOTween.To(
|
||||
() => BaseCamera.Main.fieldOfView, // 获取当前FOV
|
||||
x => BaseCamera.Main.fieldOfView = x, // 设置新FOV
|
||||
targetFOV, // 目标FOV
|
||||
_zoomDuration // 动画时间
|
||||
).SetEase(Ease.InOutQuad); // 使用缓动函数让动画更平滑
|
||||
}
|
||||
|
||||
public bool CanChangeGear()
|
||||
{
|
||||
|
||||
@@ -36,11 +36,15 @@ namespace NBF
|
||||
App.Inst.SetMouseCurrsor(false);
|
||||
|
||||
InputManager.OnQuickIndexAction += OnQuickIndexAction;
|
||||
InputManager.OnUseTorchAction += OnUseTorchAction;
|
||||
InputManager.OnUseTelescopeAction += OnUseTelescopeAction;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
InputManager.OnQuickIndexAction -= OnQuickIndexAction;
|
||||
InputManager.OnUseTorchAction -= OnUseTorchAction;
|
||||
InputManager.OnUseTelescopeAction -= OnUseTelescopeAction;
|
||||
}
|
||||
|
||||
private void EnableFirstPersonController()
|
||||
@@ -53,6 +57,23 @@ namespace NBF
|
||||
nextShowSlotIndex = index;
|
||||
}
|
||||
|
||||
private void OnUseTorchAction(bool ret)
|
||||
{
|
||||
if (!ret)
|
||||
{
|
||||
_player.Data.openLight = !_player.Data.openLight;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUseTelescopeAction(bool ret)
|
||||
{
|
||||
if (!ret)
|
||||
{
|
||||
_player.Data.openTelescope = !_player.Data.openTelescope;
|
||||
_player.ToggleTelescope();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var movementAxis = InputManager.GetMovementInput();
|
||||
|
||||
Reference in New Issue
Block a user