Files
Fishing2/Assets/Scripts/UI/Fishing/FishingPanel.cs
2025-06-04 00:00:18 +08:00

81 lines
2.2 KiB
C#

// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using System.Globalization;
using UnityEngine;
using NBC;
namespace NBF
{
public partial class FishingPanel : UIPanel
{
public override string UIPackName => "Fishing";
public override string UIResName => "FishingPanel";
protected override void OnInit()
{
IsShowCursor = false;
IsDontBack = true;
}
protected override void OnShow()
{
InputManager.OnUICanceled += OnUICanceled;
InputManager.OnInteractiveObjectAction += OnInteractiveObjectAction;
InputManager.OnPlayerCanceled += OnPlayerCanceled;
// InputManager.OnUseAction += OnUseAction;
// InputManager.OnUse2Action += OnUse2Action;
}
protected override void OnUpdate()
{
if (!SceneSettings.Instance) return;
TextFPS.text = SceneSettings.Instance.FPS.ToString(CultureInfo.InvariantCulture);
}
private void OnInteractiveObjectAction(InteractiveObject interactiveObject)
{
if (interactiveObject != null)
{
Interactive.visible = true;
Interactive.SetData(interactiveObject);
}
else
{
Interactive.visible = false;
}
}
private void OnUICanceled(string action)
{
if (action == InputDef.UI.Back)
{
if (!IsTop) return;
UI.Inst.OpenUI<HomePanel>();
}
}
private void OnPlayerCanceled(string action)
{
if (Interactive.visible)
{
if (action == "Use1")
{
Interactive.Use1();
}
else if (action == "Use2")
{
Interactive.Use2();
}
}
}
protected override void OnHide()
{
base.OnHide();
InputManager.OnUICanceled -= OnUICanceled;
InputManager.OnInteractiveObjectAction -= OnInteractiveObjectAction;
InputManager.OnUICanceled -= OnPlayerCanceled;
}
}
}