快捷键重构
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53d4b4ea733e48a3b1324345029f2bc2
|
||||
timeCreated: 1747967959
|
||||
fileFormatVersion: 2
|
||||
guid: 9f40e3fa2b734184858dde08f66c6590
|
||||
timeCreated: 1748091942
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace NBF
|
||||
{
|
||||
public class ListClassifyData
|
||||
{
|
||||
public string Title;
|
||||
|
||||
public ListClassifyData(string title)
|
||||
{
|
||||
this.Title = title;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edbbd6c0c6004af8924e5b8f2ec39039
|
||||
timeCreated: 1747969245
|
||||
46
Assets/Scripts/Data/TabListData.cs
Normal file
46
Assets/Scripts/Data/TabListData.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class TabItemData
|
||||
{
|
||||
public string Name;
|
||||
public string Icon;
|
||||
}
|
||||
|
||||
public class TabSubItemData : TabItemData
|
||||
{
|
||||
public List<object> Items = new List<object>();
|
||||
}
|
||||
|
||||
public class TabListData
|
||||
{
|
||||
public TabItemData Tab;
|
||||
public List<TabSubItemData> SubTab = new List<TabSubItemData>();
|
||||
|
||||
public void AddTestData(int index)
|
||||
{
|
||||
Tab = new TabItemData();
|
||||
Tab.Name = $"标题-{index + 1}";
|
||||
string[] testIcon = { "Globe", "Granade", "Gun" };
|
||||
var count1 = Random.Range(5, 10);
|
||||
var count2 = Random.Range(90, 200);
|
||||
for (int i = 0; i < count1; i++)
|
||||
{
|
||||
TabSubItemData subTab = new TabSubItemData();
|
||||
subTab.Name = $"类型-{i}";
|
||||
subTab.Icon = testIcon[Random.Range(0, testIcon.Length)];
|
||||
// ListData.Add(new ListClassifyData($"Title-{i}"));
|
||||
for (int j = 0; j < count2; j++)
|
||||
{
|
||||
var item = new ShopGearData();
|
||||
item.title = $"Item {index}-{i}-" + j;
|
||||
subTab.Items.Add(item);
|
||||
}
|
||||
|
||||
SubTab.Add(subTab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Assets/Scripts/Def/InputDef.cs
Normal file
27
Assets/Scripts/Def/InputDef.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace NBF
|
||||
{
|
||||
public class InputDef
|
||||
{
|
||||
public class UI
|
||||
{
|
||||
public const string Back = "Back";
|
||||
public const string Enter = "Enter";
|
||||
public const string Tab = "Tab";
|
||||
public const string Prev = "Prev";
|
||||
public const string Next = "Next";
|
||||
public const string SubPrev = "SubPrev";
|
||||
public const string SubNext = "SubNext";
|
||||
public const string Left = "Left";
|
||||
public const string Right = "Right";
|
||||
public const string Up = "Up";
|
||||
public const string Down = "Down";
|
||||
}
|
||||
|
||||
public class Player
|
||||
{
|
||||
public const string Run = "Run";
|
||||
public const string Use1 = "Use1";
|
||||
public const string Use2 = "Use2";
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Def/InputDef.cs.meta
Normal file
3
Assets/Scripts/Def/InputDef.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c1d17072df749909ccc26de605346d1
|
||||
timeCreated: 1748104048
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using NBC;
|
||||
// using Rewired;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
@@ -13,95 +14,28 @@ namespace NBF
|
||||
public static bool IsOp1;
|
||||
public static bool IsOp2;
|
||||
|
||||
|
||||
public static event Action<bool> OnOp1Action;
|
||||
public static event Action<bool> OnOp2Action;
|
||||
public static event Action OnUseAction;
|
||||
public static event Action OnUse2Action;
|
||||
public static event Action<bool> OnSelectItemAction;
|
||||
public static event Action<bool> OnSelectBaitAction;
|
||||
public static event Action<bool> OnSelectFoodAction;
|
||||
|
||||
/// <summary>
|
||||
/// 快速选择数值
|
||||
/// 执行输入事件
|
||||
/// </summary>
|
||||
public static event Action<int> OnQuickIndexAction;
|
||||
public static event Action<string> OnUIPerformed;
|
||||
|
||||
/// <summary>
|
||||
/// 使用手电筒
|
||||
/// 执行输入事件完毕
|
||||
/// </summary>
|
||||
public static event Action<bool> OnUseTorchAction;
|
||||
public static event Action<string> OnUICanceled;
|
||||
|
||||
/// <summary>
|
||||
/// 使用抄网
|
||||
/// 执行输入事件
|
||||
/// </summary>
|
||||
public static event Action<bool> OnUseBrailAction;
|
||||
public static event Action<string> OnPlayerPerformed;
|
||||
|
||||
/// <summary>
|
||||
/// 使用望远镜
|
||||
/// 执行输入事件完毕
|
||||
/// </summary>
|
||||
public static event Action<bool> OnUseTelescopeAction;
|
||||
|
||||
/// <summary>
|
||||
/// 添加浮漂
|
||||
/// </summary>
|
||||
public static event Action<bool> OnAddBobAction;
|
||||
|
||||
/// <summary>
|
||||
/// 减少浮漂
|
||||
/// </summary>
|
||||
public static event Action<bool> OnSubBobAction;
|
||||
|
||||
/// <summary>
|
||||
/// 返回背包
|
||||
/// </summary>
|
||||
public static event Action<bool> OnToBagAction;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 帮助
|
||||
/// </summary>
|
||||
public static event Action<bool> OnHelpAction;
|
||||
|
||||
/// <summary>
|
||||
/// 聊天
|
||||
/// </summary>
|
||||
public static event Action<bool> OnChatAction;
|
||||
|
||||
/// <summary>
|
||||
/// 物品信息
|
||||
/// </summary>
|
||||
public static event Action<bool> OnInfoAction;
|
||||
|
||||
/// <summary>
|
||||
/// 技能
|
||||
/// </summary>
|
||||
public static event Action<bool> OnSkillAction;
|
||||
|
||||
/// <summary>
|
||||
/// 打开背包
|
||||
/// </summary>
|
||||
public static event Action<bool> OnOpenBagAction;
|
||||
|
||||
/// <summary>
|
||||
/// 打开鱼护
|
||||
/// </summary>
|
||||
public static event Action<bool> OnKeepnetAction;
|
||||
|
||||
/// <summary>
|
||||
/// 打开制造
|
||||
/// </summary>
|
||||
public static event Action<bool> OnMakeAction;
|
||||
|
||||
/// <summary>
|
||||
/// 打开地图
|
||||
/// </summary>
|
||||
public static event Action<bool> OnMapAction;
|
||||
|
||||
/// <summary>
|
||||
/// 奔跑
|
||||
/// </summary>
|
||||
public static event Action<bool> OnRunAction;
|
||||
public static event Action<string> OnPlayerCanceled;
|
||||
|
||||
/// <summary>
|
||||
/// 触发交互游戏对象
|
||||
@@ -110,6 +44,11 @@ namespace NBF
|
||||
|
||||
public static PlayerInputControl PlayerInputControl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// ui阻止游戏输入
|
||||
/// </summary>
|
||||
public static bool IsUIStopInput;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
@@ -118,19 +57,20 @@ namespace NBF
|
||||
|
||||
public static Vector2 GetMovementInput()
|
||||
{
|
||||
return PlayerInputControl.Normal.Move?.ReadValue<Vector2>() ?? Vector2.zero;
|
||||
if (IsUIStopInput) return Vector2.zero;
|
||||
return PlayerInputControl.Player.Move?.ReadValue<Vector2>() ?? Vector2.zero;
|
||||
}
|
||||
|
||||
public static Vector2 GetLookInput()
|
||||
{
|
||||
return PlayerInputControl.Normal.Look?.ReadValue<Vector2>() ?? Vector2.zero;
|
||||
if (IsUIStopInput) return Vector2.zero;
|
||||
return PlayerInputControl.Player.Look?.ReadValue<Vector2>() ?? Vector2.zero;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
PlayerInputControl = new PlayerInputControl();
|
||||
PlayerInputControl.Enable();
|
||||
PlayerInputControl.Normal.Enable();
|
||||
AddEvent();
|
||||
}
|
||||
|
||||
@@ -141,348 +81,85 @@ namespace NBF
|
||||
|
||||
private void AddEvent()
|
||||
{
|
||||
PlayerInputControl.Normal.Run.performed += OnRun;
|
||||
PlayerInputControl.Normal.Run.canceled += OnRun;
|
||||
PlayerInputControl.Normal.Op1.performed += OnOp1;
|
||||
PlayerInputControl.Normal.Op1.canceled += OnOp1;
|
||||
PlayerInputControl.Normal.Op2.performed += OnOp2;
|
||||
PlayerInputControl.Normal.Op2.canceled += OnOp2;
|
||||
PlayerInputControl.Normal.Use.performed += OnUse;
|
||||
PlayerInputControl.Normal.Use.canceled += OnUse;
|
||||
PlayerInputControl.Normal.Use2.performed += OnUse2;
|
||||
PlayerInputControl.Normal.Use2.canceled += OnUse2;
|
||||
|
||||
PlayerInputControl.Normal.SelectItem.performed += OnSelectItem;
|
||||
PlayerInputControl.Normal.SelectItem.canceled += OnSelectItem;
|
||||
|
||||
PlayerInputControl.Normal.SelectFood.performed += OnSelectFood;
|
||||
PlayerInputControl.Normal.SelectFood.canceled += OnSelectFood;
|
||||
|
||||
PlayerInputControl.Normal.SelectBait.performed += OnSelectBait;
|
||||
PlayerInputControl.Normal.SelectBait.canceled += OnSelectBait;
|
||||
|
||||
PlayerInputControl.Normal.UseTorch.performed += OnUseTorch;
|
||||
PlayerInputControl.Normal.UseTorch.canceled += OnUseTorch;
|
||||
|
||||
PlayerInputControl.Normal.UseTelescope.performed += OnUseTelescope;
|
||||
PlayerInputControl.Normal.UseTelescope.canceled += OnUseTelescope;
|
||||
|
||||
PlayerInputControl.Normal.UseBrail.performed += OnUseBrail;
|
||||
PlayerInputControl.Normal.UseBrail.canceled += OnUseBrail;
|
||||
|
||||
PlayerInputControl.Normal.AddBob.performed += OnAddBob;
|
||||
PlayerInputControl.Normal.AddBob.canceled += OnAddBob;
|
||||
|
||||
PlayerInputControl.Normal.SubBob.performed += OnSubBob;
|
||||
PlayerInputControl.Normal.SubBob.canceled += OnSubBob;
|
||||
|
||||
PlayerInputControl.Normal.ToBag.performed += OnToBag;
|
||||
PlayerInputControl.Normal.ToBag.canceled += OnToBag;
|
||||
|
||||
PlayerInputControl.Normal.Help.performed += OnHelp;
|
||||
PlayerInputControl.Normal.Help.canceled += OnHelp;
|
||||
|
||||
PlayerInputControl.Normal.Chat.performed += OnChat;
|
||||
PlayerInputControl.Normal.Chat.canceled += OnChat;
|
||||
|
||||
PlayerInputControl.Normal.Info.performed += OnInfo;
|
||||
PlayerInputControl.Normal.Info.canceled += OnInfo;
|
||||
|
||||
PlayerInputControl.Normal.Skill.performed += OnSkill;
|
||||
PlayerInputControl.Normal.Skill.canceled += OnSkill;
|
||||
|
||||
PlayerInputControl.Normal.OpenBag.performed += OnOpenBag;
|
||||
PlayerInputControl.Normal.OpenBag.canceled += OnOpenBag;
|
||||
|
||||
PlayerInputControl.Normal.Keepnet.performed += OnKeepnet;
|
||||
PlayerInputControl.Normal.Keepnet.canceled += OnKeepnet;
|
||||
|
||||
PlayerInputControl.Normal.Make.performed += OnMake;
|
||||
PlayerInputControl.Normal.Make.canceled += OnMake;
|
||||
|
||||
PlayerInputControl.Normal.Map.performed += OnMap;
|
||||
PlayerInputControl.Normal.Map.canceled += OnMap;
|
||||
|
||||
PlayerInputControl.Normal.Quick1.performed += OnQuick1;
|
||||
PlayerInputControl.Normal.Quick2.performed += OnQuick2;
|
||||
PlayerInputControl.Normal.Quick3.performed += OnQuick3;
|
||||
PlayerInputControl.Normal.Quick4.performed += OnQuick4;
|
||||
PlayerInputControl.Normal.Quick5.performed += OnQuick5;
|
||||
PlayerInputControl.Normal.Quick6.performed += OnQuick6;
|
||||
PlayerInputControl.Normal.Quick7.performed += OnQuick7;
|
||||
PlayerInputControl.Normal.Quick8.performed += OnQuick8;
|
||||
PlayerInputControl.Normal.Quick9.performed += OnQuick9;
|
||||
foreach (var actionMap in PlayerInputControl.asset.actionMaps)
|
||||
{
|
||||
actionMap.Enable();
|
||||
if (actionMap.name == "UI")
|
||||
{
|
||||
foreach (var action in actionMap.actions)
|
||||
{
|
||||
if (action.type == InputActionType.Button)
|
||||
{
|
||||
action.performed += OnUIButtonPerformed;
|
||||
action.canceled += OnUIButtonCanceled;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (actionMap.name == "Normal")
|
||||
{
|
||||
foreach (var action in actionMap.actions)
|
||||
{
|
||||
if (action.type == InputActionType.Button)
|
||||
{
|
||||
action.performed += OnPlayerButtonPerformed;
|
||||
action.canceled += OnPlayerButtonCanceled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveEvent()
|
||||
{
|
||||
PlayerInputControl.Normal.Run.performed -= OnRun;
|
||||
PlayerInputControl.Normal.Run.canceled -= OnRun;
|
||||
PlayerInputControl.Normal.Op1.performed -= OnOp1;
|
||||
PlayerInputControl.Normal.Op1.canceled -= OnOp1;
|
||||
PlayerInputControl.Normal.Op2.performed -= OnOp2;
|
||||
PlayerInputControl.Normal.Op2.canceled -= OnOp2;
|
||||
PlayerInputControl.Normal.Use.performed -= OnUse;
|
||||
PlayerInputControl.Normal.Use.canceled -= OnUse;
|
||||
PlayerInputControl.Normal.Use2.performed -= OnUse2;
|
||||
PlayerInputControl.Normal.Use2.canceled -= OnUse2;
|
||||
|
||||
PlayerInputControl.Normal.SelectItem.performed -= OnSelectItem;
|
||||
PlayerInputControl.Normal.SelectItem.canceled -= OnSelectItem;
|
||||
|
||||
PlayerInputControl.Normal.SelectFood.performed -= OnSelectFood;
|
||||
PlayerInputControl.Normal.SelectFood.canceled -= OnSelectFood;
|
||||
|
||||
PlayerInputControl.Normal.SelectBait.performed -= OnSelectBait;
|
||||
PlayerInputControl.Normal.SelectBait.canceled -= OnSelectBait;
|
||||
|
||||
PlayerInputControl.Normal.UseTorch.performed -= OnUseTorch;
|
||||
PlayerInputControl.Normal.UseTorch.canceled -= OnUseTorch;
|
||||
|
||||
PlayerInputControl.Normal.UseTelescope.performed -= OnUseTelescope;
|
||||
PlayerInputControl.Normal.UseTelescope.canceled -= OnUseTelescope;
|
||||
|
||||
PlayerInputControl.Normal.UseBrail.performed -= OnUseBrail;
|
||||
PlayerInputControl.Normal.UseBrail.canceled -= OnUseBrail;
|
||||
|
||||
PlayerInputControl.Normal.AddBob.performed -= OnAddBob;
|
||||
PlayerInputControl.Normal.AddBob.canceled -= OnAddBob;
|
||||
|
||||
PlayerInputControl.Normal.SubBob.performed -= OnSubBob;
|
||||
PlayerInputControl.Normal.SubBob.canceled -= OnSubBob;
|
||||
|
||||
PlayerInputControl.Normal.ToBag.performed -= OnToBag;
|
||||
PlayerInputControl.Normal.ToBag.canceled -= OnToBag;
|
||||
|
||||
PlayerInputControl.Normal.Help.performed -= OnHelp;
|
||||
PlayerInputControl.Normal.Help.canceled -= OnHelp;
|
||||
|
||||
PlayerInputControl.Normal.Chat.performed -= OnChat;
|
||||
PlayerInputControl.Normal.Chat.canceled -= OnChat;
|
||||
|
||||
PlayerInputControl.Normal.Info.performed -= OnInfo;
|
||||
PlayerInputControl.Normal.Info.canceled -= OnInfo;
|
||||
|
||||
PlayerInputControl.Normal.Skill.performed -= OnSkill;
|
||||
PlayerInputControl.Normal.Skill.canceled -= OnSkill;
|
||||
|
||||
PlayerInputControl.Normal.OpenBag.performed -= OnOpenBag;
|
||||
PlayerInputControl.Normal.OpenBag.canceled -= OnOpenBag;
|
||||
|
||||
PlayerInputControl.Normal.Keepnet.performed -= OnKeepnet;
|
||||
PlayerInputControl.Normal.Keepnet.canceled -= OnKeepnet;
|
||||
|
||||
PlayerInputControl.Normal.Make.performed -= OnMake;
|
||||
PlayerInputControl.Normal.Make.canceled -= OnMake;
|
||||
|
||||
PlayerInputControl.Normal.Map.performed -= OnMap;
|
||||
PlayerInputControl.Normal.Map.canceled -= OnMap;
|
||||
|
||||
PlayerInputControl.Normal.Quick1.performed -= OnQuick1;
|
||||
PlayerInputControl.Normal.Quick2.performed -= OnQuick2;
|
||||
PlayerInputControl.Normal.Quick3.performed -= OnQuick3;
|
||||
PlayerInputControl.Normal.Quick4.performed -= OnQuick4;
|
||||
PlayerInputControl.Normal.Quick5.performed -= OnQuick5;
|
||||
PlayerInputControl.Normal.Quick6.performed -= OnQuick6;
|
||||
PlayerInputControl.Normal.Quick7.performed -= OnQuick7;
|
||||
PlayerInputControl.Normal.Quick8.performed -= OnQuick8;
|
||||
PlayerInputControl.Normal.Quick9.performed -= OnQuick9;
|
||||
OnUIPerformed = null;
|
||||
OnUICanceled = null;
|
||||
OnPlayerPerformed = null;
|
||||
OnPlayerCanceled = null;
|
||||
}
|
||||
|
||||
private void OnUIButtonPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
OnUIPerformed?.Invoke(context.action.name);
|
||||
}
|
||||
|
||||
private void OnUIButtonCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
OnUICanceled?.Invoke(context.action.name);
|
||||
}
|
||||
|
||||
private void OnPlayerButtonPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
if (IsUIStopInput) return;
|
||||
var actionName = context.action.name;
|
||||
if (actionName == "Op1")
|
||||
{
|
||||
OnOp1Action?.Invoke(true);
|
||||
}
|
||||
else if (actionName == "Op2")
|
||||
{
|
||||
OnOp2Action?.Invoke(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPlayerButtonCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
if (IsUIStopInput) return;
|
||||
var actionName = context.action.name;
|
||||
if (actionName == "Op1")
|
||||
{
|
||||
OnOp1Action?.Invoke(false);
|
||||
}
|
||||
else if (actionName == "Op2")
|
||||
{
|
||||
OnOp2Action?.Invoke(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void OnInteractiveObject(InteractiveObject interactiveObject)
|
||||
{
|
||||
Debug.LogError($"OnInteractiveObject {interactiveObject != null}");
|
||||
OnInteractiveObjectAction?.Invoke(interactiveObject);
|
||||
}
|
||||
|
||||
private void OnRun(InputAction.CallbackContext context)
|
||||
{
|
||||
OnRunAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnOp1(InputAction.CallbackContext context)
|
||||
{
|
||||
IsOp1 = context.performed;
|
||||
OnOp1Action?.Invoke(IsOp1);
|
||||
}
|
||||
|
||||
private void OnOp2(InputAction.CallbackContext context)
|
||||
{
|
||||
IsOp2 = context.performed;
|
||||
OnOp2Action?.Invoke(IsOp2);
|
||||
}
|
||||
|
||||
private void OnUse(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnUseAction?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUse2(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnUse2Action?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSelectItem(InputAction.CallbackContext context)
|
||||
{
|
||||
OnSelectItemAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnSelectFood(InputAction.CallbackContext context)
|
||||
{
|
||||
OnSelectFoodAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnSelectBait(InputAction.CallbackContext context)
|
||||
{
|
||||
OnSelectBaitAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnUseTorch(InputAction.CallbackContext context)
|
||||
{
|
||||
OnUseTorchAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnUseTelescope(InputAction.CallbackContext context)
|
||||
{
|
||||
OnUseTelescopeAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnUseBrail(InputAction.CallbackContext context)
|
||||
{
|
||||
OnUseBrailAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnAddBob(InputAction.CallbackContext context)
|
||||
{
|
||||
OnSubBobAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnSubBob(InputAction.CallbackContext context)
|
||||
{
|
||||
OnSubBobAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnToBag(InputAction.CallbackContext context)
|
||||
{
|
||||
OnToBagAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnHelp(InputAction.CallbackContext context)
|
||||
{
|
||||
OnHelpAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnChat(InputAction.CallbackContext context)
|
||||
{
|
||||
OnChatAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnInfo(InputAction.CallbackContext context)
|
||||
{
|
||||
OnInfoAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnSkill(InputAction.CallbackContext context)
|
||||
{
|
||||
OnSkillAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnOpenBag(InputAction.CallbackContext context)
|
||||
{
|
||||
OnOpenBagAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnKeepnet(InputAction.CallbackContext context)
|
||||
{
|
||||
OnKeepnetAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnMake(InputAction.CallbackContext context)
|
||||
{
|
||||
OnMakeAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnMap(InputAction.CallbackContext context)
|
||||
{
|
||||
OnMapAction?.Invoke(context.performed);
|
||||
}
|
||||
|
||||
private void OnQuick1(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnQuickIndexAction?.Invoke(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnQuick2(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnQuickIndexAction?.Invoke(2);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnQuick3(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnQuickIndexAction?.Invoke(3);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnQuick4(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnQuickIndexAction?.Invoke(4);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnQuick5(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnQuickIndexAction?.Invoke(5);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnQuick6(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnQuickIndexAction?.Invoke(6);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnQuick7(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnQuickIndexAction?.Invoke(7);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnQuick8(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnQuickIndexAction?.Invoke(8);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnQuick9(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnQuickIndexAction?.Invoke(9);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,10 +56,12 @@ namespace NBF
|
||||
transform.rotation = _player.Data.rotation;
|
||||
|
||||
App.Inst.SetMouseCurrsor(false);
|
||||
InputManager.OnRunAction += OnRunAction;
|
||||
InputManager.OnQuickIndexAction += OnQuickIndexAction;
|
||||
InputManager.OnUseTorchAction += OnUseTorchAction;
|
||||
InputManager.OnUseTelescopeAction += OnUseTelescopeAction;
|
||||
InputManager.OnPlayerCanceled += OnPlayerCanceled;
|
||||
InputManager.OnPlayerPerformed += OnPlayerPerformed;
|
||||
// InputManager.OnRunAction += OnRunAction;
|
||||
// InputManager.OnQuickIndexAction += OnQuickIndexAction;
|
||||
// InputManager.OnUseTorchAction += OnUseTorchAction;
|
||||
// InputManager.OnUseTelescopeAction += OnUseTelescopeAction;
|
||||
|
||||
interactableLayer = LayerMask.GetMask("Interactive");
|
||||
}
|
||||
@@ -93,9 +95,8 @@ namespace NBF
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
InputManager.OnQuickIndexAction -= OnQuickIndexAction;
|
||||
InputManager.OnUseTorchAction -= OnUseTorchAction;
|
||||
InputManager.OnUseTelescopeAction -= OnUseTelescopeAction;
|
||||
InputManager.OnPlayerCanceled -= OnPlayerCanceled;
|
||||
InputManager.OnPlayerPerformed -= OnPlayerPerformed;
|
||||
}
|
||||
|
||||
#region 交互检测
|
||||
@@ -283,28 +284,29 @@ namespace NBF
|
||||
|
||||
#region 按键输入事件
|
||||
|
||||
private void OnRunAction(bool performed)
|
||||
private void OnPlayerPerformed(string action)
|
||||
{
|
||||
if (performed) Sprint();
|
||||
else StopSprinting();
|
||||
}
|
||||
|
||||
private void OnQuickIndexAction(int index)
|
||||
{
|
||||
nextShowSlotIndex = index;
|
||||
}
|
||||
|
||||
private void OnUseTorchAction(bool ret)
|
||||
{
|
||||
if (!ret)
|
||||
if (action == "Run")
|
||||
{
|
||||
_player.Data.openLight = !_player.Data.openLight;
|
||||
Sprint();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUseTelescopeAction(bool ret)
|
||||
private void OnPlayerCanceled(string action)
|
||||
{
|
||||
if (!ret)
|
||||
if (action == "Run")
|
||||
{
|
||||
StopSprinting();
|
||||
}
|
||||
else if (action.StartsWith("Quick"))
|
||||
{
|
||||
nextShowSlotIndex = int.Parse(action.Substring("Quick".Length));
|
||||
}
|
||||
else if (action == "UseTorch")
|
||||
{
|
||||
_player.Data.openLight = !_player.Data.openLight;
|
||||
}
|
||||
else if (action == "UseTelescope")
|
||||
{
|
||||
_player.Data.openTelescope = !_player.Data.openTelescope;
|
||||
_player.ToggleTelescope();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,9 +8,12 @@ namespace NBF
|
||||
{
|
||||
public static void BindAll()
|
||||
{
|
||||
UIObjectFactory.SetPackageItemExtension(BottomMenu.URL, typeof(BottomMenu));
|
||||
UIObjectFactory.SetPackageItemExtension(ClassifyList.URL, typeof(ClassifyList));
|
||||
UIObjectFactory.SetPackageItemExtension(CommonMenu.URL, typeof(CommonMenu));
|
||||
UIObjectFactory.SetPackageItemExtension(ListTitleItem.URL, typeof(ListTitleItem));
|
||||
UIObjectFactory.SetPackageItemExtension(BtnTitleInputControl.URL, typeof(BtnTitleInputControl));
|
||||
UIObjectFactory.SetPackageItemExtension(CommonSubMenu.URL, typeof(CommonSubMenu));
|
||||
UIObjectFactory.SetPackageItemExtension(BtnInputControl.URL, typeof(BtnInputControl));
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/UI/Common/Button.meta
Normal file
3
Assets/Scripts/UI/Common/Button.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e421fb97db2b48ccb37e75b8766265de
|
||||
timeCreated: 1748071593
|
||||
@@ -7,17 +7,17 @@ using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class ListTitleItem
|
||||
public partial class BtnInputControl
|
||||
{
|
||||
public const string URL = "ui://6hgkvlauoomea";
|
||||
public const string URL = "ui://6hgkvlaur03ut";
|
||||
|
||||
public GImage back;
|
||||
public Controller show;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
back = (GImage)GetChild("back");
|
||||
show = GetController("show");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfab5a485e648254dad616e988d7a17e
|
||||
15
Assets/Scripts/UI/Common/Button/BtnInputControl.cs
Normal file
15
Assets/Scripts/UI/Common/Button/BtnInputControl.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class BtnInputControl : GButton
|
||||
{
|
||||
private void OnInited()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Common/Button/BtnInputControl.cs.meta
Normal file
2
Assets/Scripts/UI/Common/Button/BtnInputControl.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bc3045114c90ef4888ae8cd51aa1e2e
|
||||
25
Assets/Scripts/UI/Common/Button/BtnTitleInputControl.Designer.cs
generated
Normal file
25
Assets/Scripts/UI/Common/Button/BtnTitleInputControl.Designer.cs
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class BtnTitleInputControl
|
||||
{
|
||||
public const string URL = "ui://6hgkvlaur03uj0";
|
||||
|
||||
public Controller show;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
show = GetController("show");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a4cdcb09978fcd47b043fa05e53e433
|
||||
19
Assets/Scripts/UI/Common/Button/BtnTitleInputControl.cs
Normal file
19
Assets/Scripts/UI/Common/Button/BtnTitleInputControl.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class BtnTitleInputControl : GButton
|
||||
{
|
||||
public Action OnAction;
|
||||
public string ActionName;
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15ebd24da667f9146bc2cfbfec56a512
|
||||
@@ -11,18 +11,65 @@ namespace NBF
|
||||
public partial class ClassifyList : GComponent
|
||||
{
|
||||
private readonly List<object> _listData = new List<object>();
|
||||
|
||||
|
||||
public event Action<object> OnClickItem;
|
||||
|
||||
|
||||
private int _columnsCount;
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
List.itemProvider = GetListItemResource;
|
||||
List.itemRenderer = OnRenderItem;
|
||||
List.onClickItem.Add(OnClickListItem);
|
||||
InputManager.OnUICanceled += OnUICanceled;
|
||||
}
|
||||
|
||||
public void SetListData(List<object> listData,ListSelectionMode selectionMode = ListSelectionMode.Single)
|
||||
public override void Dispose()
|
||||
{
|
||||
InputManager.OnUICanceled -= OnUICanceled;
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
private void OnUICanceled(string action)
|
||||
{
|
||||
if (action == InputDef.UI.Right)
|
||||
{
|
||||
SetListSelected(List.selectedIndex + 1);
|
||||
}
|
||||
else if (action == InputDef.UI.Left)
|
||||
{
|
||||
SetListSelected(List.selectedIndex - 1);
|
||||
}
|
||||
else if (action == InputDef.UI.Up)
|
||||
{
|
||||
SetListSelected(List.selectedIndex - _columnsCount);
|
||||
}
|
||||
else if (action == InputDef.UI.Down)
|
||||
{
|
||||
if (List.selectedIndex < 0)
|
||||
{
|
||||
SetListSelected(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetListSelected(List.selectedIndex + _columnsCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetListSelected(int selectedIndex)
|
||||
{
|
||||
if (selectedIndex >= 0 && selectedIndex < _listData.Count)
|
||||
{
|
||||
List.selectedIndex = selectedIndex;
|
||||
List.ScrollToView(List.selectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetListData(List<object> listData, ListSelectionMode selectionMode = ListSelectionMode.Single)
|
||||
{
|
||||
List.selectedIndex = -1;
|
||||
List.defaultItem = GetListDefaultItemResource(listData);
|
||||
List.itemRenderer = OnRenderItem;
|
||||
List.onClickItem.Add(OnClickListItem);
|
||||
List.SetVirtual();
|
||||
_listData.Clear();
|
||||
foreach (var obj in listData)
|
||||
{
|
||||
@@ -32,13 +79,14 @@ namespace NBF
|
||||
List.selectionMode = selectionMode;
|
||||
List.numItems = _listData.Count;
|
||||
List.ScrollToView(0);
|
||||
_columnsCount = 5;
|
||||
}
|
||||
|
||||
void OnClickListItem(EventContext context)
|
||||
{
|
||||
OnClickItem?.Invoke(context.data);
|
||||
}
|
||||
|
||||
|
||||
void OnRenderItem(int index, GObject obj)
|
||||
{
|
||||
if (obj is ListItemBase item)
|
||||
@@ -48,20 +96,15 @@ namespace NBF
|
||||
}
|
||||
|
||||
//根据索引的不同,返回不同的资源URL
|
||||
string GetListItemResource(int index)
|
||||
string GetListDefaultItemResource(List<object> listData)
|
||||
{
|
||||
var itemData = _listData[index];
|
||||
|
||||
if (itemData is ShopGearData shopItem)
|
||||
var itemData = listData.Find(t => t != null);
|
||||
|
||||
if (itemData is ShopGearData)
|
||||
{
|
||||
return ShopGearItem.URL;
|
||||
}
|
||||
|
||||
if (itemData is ListClassifyData item)
|
||||
{
|
||||
return ListTitleItem.URL;
|
||||
}
|
||||
|
||||
return List.defaultItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class CommonMenu : GLabel
|
||||
{
|
||||
public event Action OnClose;
|
||||
public event Action<int> OnTabChange;
|
||||
private void OnInited()
|
||||
{
|
||||
BtnClose.onClick.Add(OnClickClose);
|
||||
List.onClickItem.Add(OnClickItem);
|
||||
}
|
||||
|
||||
public void SetTabs(List<TabListData> tabList,int selectIndex = 0)
|
||||
{
|
||||
List.RemoveChildrenToPool();
|
||||
for (int i = 0; i < tabList.Count; i++)
|
||||
{
|
||||
var tabData = tabList[i];
|
||||
var tabItem = List.AddItemFromPool().asButton;
|
||||
tabItem.title = tabData.TabName;
|
||||
}
|
||||
Log.Info($"Set tab index={List.selectedIndex}");
|
||||
List.selectedIndex = selectIndex;
|
||||
OnClickItem();
|
||||
}
|
||||
|
||||
|
||||
private void OnClickItem()
|
||||
{
|
||||
OnTabChange?.Invoke(List.selectedIndex);
|
||||
}
|
||||
|
||||
private void OnClickClose()
|
||||
{
|
||||
OnClose?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Common/GMPanel.Designer.cs
generated
2
Assets/Scripts/UI/Common/GMPanel.Designer.cs
generated
@@ -17,7 +17,7 @@ namespace NBF
|
||||
public GButton BtnOk;
|
||||
[AutoFind(Name = "Dir")]
|
||||
public GComboBox Dir;
|
||||
public override string[] GetDependPackages(){ return new string[] {"Main"}; }
|
||||
public override string[] GetDependPackages(){ return new string[] {}; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8042079334b43394ca275c4a2189dbfb
|
||||
@@ -1,27 +0,0 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class ListTitleItem : ListItemBase
|
||||
{
|
||||
public ListClassifyData ClassifyData;
|
||||
private void OnInited()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnSetData(object showData)
|
||||
{
|
||||
width = parent.width - 40;
|
||||
ClassifyData = showData as ListClassifyData;
|
||||
if (ClassifyData == null)
|
||||
{
|
||||
ClassifyData = new ListClassifyData(string.Empty);
|
||||
}
|
||||
title = ClassifyData.Title;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1c42293e0f4ae546ba4419aa2ed199c
|
||||
@@ -1,30 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class TabListData
|
||||
{
|
||||
public string TabName;
|
||||
public bool Selected;
|
||||
public List<object> ListData;
|
||||
|
||||
public void AddTestData(int index)
|
||||
{
|
||||
ListData = new List<object>();
|
||||
TabName = $"标题-{index + 1}";
|
||||
var count1 = Random.Range(5, 10);
|
||||
var count2 = Random.Range(10, 30);
|
||||
for (int i = 0; i < count1; i++)
|
||||
{
|
||||
ListData.Add(new ListClassifyData($"Title-{i}"));
|
||||
for (int j = 0; j < count2; j++)
|
||||
{
|
||||
var item = new ShopGearData();
|
||||
item.title = $"Item {i}-" + j;
|
||||
ListData.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/UI/Common/Menu.meta
Normal file
3
Assets/Scripts/UI/Common/Menu.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d49e5e796ac4b4487b72a164e22ba73
|
||||
timeCreated: 1748093228
|
||||
27
Assets/Scripts/UI/Common/Menu/BottomMenu.Designer.cs
generated
Normal file
27
Assets/Scripts/UI/Common/Menu/BottomMenu.Designer.cs
generated
Normal file
@@ -0,0 +1,27 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class BottomMenu
|
||||
{
|
||||
public const string URL = "ui://6hgkvlau9mf1z";
|
||||
|
||||
public GList List;
|
||||
public GList LeftList;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
List = (GList)GetChild("List");
|
||||
LeftList = (GList)GetChild("LeftList");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 172ed53c6c409e04c8a993c9fae4c820
|
||||
79
Assets/Scripts/UI/Common/Menu/BottomMenu.cs
Normal file
79
Assets/Scripts/UI/Common/Menu/BottomMenu.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class BottomMenu : GComponent
|
||||
{
|
||||
public event Action OnBack;
|
||||
public event Action OnEnter;
|
||||
public event Action OnTab;
|
||||
public event Action OnUse;
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
List.onClickItem.Add(OnClickItem);
|
||||
}
|
||||
|
||||
private void OnClickItem(EventContext context)
|
||||
{
|
||||
var item = context.data as BtnTitleInputControl;
|
||||
if (item == null) return;
|
||||
item.OnAction?.Invoke();
|
||||
}
|
||||
|
||||
public void UnUse()
|
||||
{
|
||||
OnBack = null;
|
||||
OnEnter = null;
|
||||
OnTab = null;
|
||||
OnUse = null;
|
||||
|
||||
InputManager.OnUICanceled -= OnAction;
|
||||
}
|
||||
|
||||
public void Use()
|
||||
{
|
||||
List.RemoveChildrenToPool();
|
||||
LeftList.RemoveChildrenToPool();
|
||||
|
||||
InputManager.OnUICanceled += OnAction;
|
||||
|
||||
AddButtonItem(OnUse, "");
|
||||
AddButtonItem(OnTab, InputDef.UI.Tab);
|
||||
AddButtonItem(OnEnter, InputDef.UI.Enter);
|
||||
AddButtonItem(OnBack, InputDef.UI.Back);
|
||||
}
|
||||
|
||||
private void AddButtonItem(Action action, string actionName)
|
||||
{
|
||||
if (action != null)
|
||||
{
|
||||
if (List.AddItemFromPool() is BtnTitleInputControl item)
|
||||
{
|
||||
item.OnAction = action;
|
||||
item.ActionName = actionName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAction(string action)
|
||||
{
|
||||
var children = List.GetChildren();
|
||||
foreach (var child in children)
|
||||
{
|
||||
if (child is BtnTitleInputControl item)
|
||||
{
|
||||
if (action == item.ActionName)
|
||||
{
|
||||
item.OnAction?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Common/Menu/BottomMenu.cs.meta
Normal file
2
Assets/Scripts/UI/Common/Menu/BottomMenu.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94c5df4d4f05c2b40ad72c5c90008295
|
||||
@@ -11,23 +11,19 @@ namespace NBF
|
||||
{
|
||||
public const string URL = "ui://6hgkvlaufcfggr";
|
||||
|
||||
public GImage LongLine;
|
||||
public GList List;
|
||||
public GButton Head;
|
||||
public GTextField TextName;
|
||||
public GComponent Currency;
|
||||
public GButton BtnClose;
|
||||
public GButton BtnUserHead;
|
||||
public BtnInputControl BtnPrev;
|
||||
public BtnInputControl BtnNext;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
LongLine = (GImage)GetChild("LongLine");
|
||||
List = (GList)GetChild("List");
|
||||
Head = (GButton)GetChild("Head");
|
||||
TextName = (GTextField)GetChild("TextName");
|
||||
Currency = (GComponent)GetChild("Currency");
|
||||
BtnClose = (GButton)GetChild("BtnClose");
|
||||
BtnUserHead = (GButton)GetChild("BtnUserHead");
|
||||
BtnPrev = (BtnInputControl)GetChild("BtnPrev");
|
||||
BtnNext = (BtnInputControl)GetChild("BtnNext");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
98
Assets/Scripts/UI/Common/Menu/CommonMenu.cs
Normal file
98
Assets/Scripts/UI/Common/Menu/CommonMenu.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class CommonMenu : GLabel
|
||||
{
|
||||
public event Action<int> OnTabChange;
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
List.onClickItem.Add(OnClickItem);
|
||||
BtnPrev.onClick.Add(OnClickBtnPrev);
|
||||
BtnNext.onClick.Add(OnClickBtnNext);
|
||||
|
||||
InputManager.OnUICanceled += OnUICanceled;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
InputManager.OnUICanceled -= OnUICanceled;
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
private void OnUICanceled(string action)
|
||||
{
|
||||
if (action == InputDef.UI.Prev)
|
||||
{
|
||||
OnClickBtnPrev();
|
||||
}
|
||||
else if (action == InputDef.UI.Next)
|
||||
{
|
||||
OnClickBtnNext();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTabs(List<TabListData> tabList, int selectIndex = 0)
|
||||
{
|
||||
List.RemoveChildrenToPool();
|
||||
var width = 0f;
|
||||
for (int i = 0; i < tabList.Count; i++)
|
||||
{
|
||||
var tabData = tabList[i];
|
||||
var tabItem = List.AddItemFromPool().asButton;
|
||||
tabItem.title = tabData.Tab.Name;
|
||||
width += tabItem.width;
|
||||
if (i > 0)
|
||||
{
|
||||
width += List.columnGap;
|
||||
}
|
||||
}
|
||||
|
||||
Log.Info($"Set tab index={List.selectedIndex}");
|
||||
List.selectedIndex = selectIndex;
|
||||
List.width = width;
|
||||
OnClickItem();
|
||||
}
|
||||
|
||||
|
||||
private void OnClickItem()
|
||||
{
|
||||
OnTabChange?.Invoke(List.selectedIndex);
|
||||
}
|
||||
|
||||
private void OnClickBtnPrev()
|
||||
{
|
||||
if (List.selectedIndex > 0)
|
||||
{
|
||||
List.selectedIndex -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
List.selectedIndex = List.numItems - 1;
|
||||
}
|
||||
|
||||
OnClickItem();
|
||||
}
|
||||
|
||||
private void OnClickBtnNext()
|
||||
{
|
||||
if (List.selectedIndex < List.numItems - 1)
|
||||
{
|
||||
List.selectedIndex += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
List.selectedIndex = 0;
|
||||
}
|
||||
|
||||
OnClickItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Assets/Scripts/UI/Common/Menu/CommonSubMenu.Designer.cs
generated
Normal file
29
Assets/Scripts/UI/Common/Menu/CommonSubMenu.Designer.cs
generated
Normal file
@@ -0,0 +1,29 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class CommonSubMenu
|
||||
{
|
||||
public const string URL = "ui://6hgkvlaur03us";
|
||||
|
||||
public GList List;
|
||||
public BtnInputControl BtnPrev;
|
||||
public BtnInputControl BtnNext;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
List = (GList)GetChild("List");
|
||||
BtnPrev = (BtnInputControl)GetChild("BtnPrev");
|
||||
BtnNext = (BtnInputControl)GetChild("BtnNext");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b9116bdcaaf42e4ea12741ceab85742
|
||||
98
Assets/Scripts/UI/Common/Menu/CommonSubMenu.cs
Normal file
98
Assets/Scripts/UI/Common/Menu/CommonSubMenu.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class CommonSubMenu : GComponent
|
||||
{
|
||||
public event Action<int> OnTabChange;
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
List.onClickItem.Add(OnClickItem);
|
||||
BtnPrev.onClick.Add(OnClickBtnPrev);
|
||||
BtnNext.onClick.Add(OnClickBtnNext);
|
||||
|
||||
InputManager.OnUICanceled += OnUICanceled;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
InputManager.OnUICanceled -= OnUICanceled;
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
private void OnUICanceled(string action)
|
||||
{
|
||||
if (action == InputDef.UI.SubPrev)
|
||||
{
|
||||
OnClickBtnPrev();
|
||||
}
|
||||
else if (action == InputDef.UI.SubNext)
|
||||
{
|
||||
OnClickBtnNext();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTabs(List<TabSubItemData> subItems, int selectIndex = 0)
|
||||
{
|
||||
List.RemoveChildrenToPool();
|
||||
var width = 0f;
|
||||
for (int i = 0; i < subItems.Count; i++)
|
||||
{
|
||||
var tabData = subItems[i];
|
||||
var tabItem = List.AddItemFromPool().asButton;
|
||||
tabItem.title = tabData.Name;
|
||||
width += tabItem.width;
|
||||
if (i > 0)
|
||||
{
|
||||
width += List.columnGap;
|
||||
}
|
||||
}
|
||||
|
||||
Log.Info($"Set tab index={List.selectedIndex}");
|
||||
List.selectedIndex = selectIndex;
|
||||
List.width = width;
|
||||
OnClickItem();
|
||||
}
|
||||
|
||||
|
||||
private void OnClickItem()
|
||||
{
|
||||
OnTabChange?.Invoke(List.selectedIndex);
|
||||
}
|
||||
|
||||
private void OnClickBtnPrev()
|
||||
{
|
||||
if (List.selectedIndex > 0)
|
||||
{
|
||||
List.selectedIndex -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
List.selectedIndex = List.numItems - 1;
|
||||
}
|
||||
|
||||
OnClickItem();
|
||||
}
|
||||
|
||||
private void OnClickBtnNext()
|
||||
{
|
||||
if (List.selectedIndex < List.numItems - 1)
|
||||
{
|
||||
List.selectedIndex += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
List.selectedIndex = 0;
|
||||
}
|
||||
|
||||
OnClickItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Common/Menu/CommonSubMenu.cs.meta
Normal file
2
Assets/Scripts/UI/Common/Menu/CommonSubMenu.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93621bc99ea075a4089f13224578d4ef
|
||||
30
Assets/Scripts/UI/Common/MessageBox.Designer.cs
generated
Normal file
30
Assets/Scripts/UI/Common/MessageBox.Designer.cs
generated
Normal file
@@ -0,0 +1,30 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary> </summary>
|
||||
public partial class MessageBox
|
||||
{
|
||||
public GObject this[string aKey] => ContentPane.GetChild(aKey);
|
||||
[AutoFind(Name = "back")]
|
||||
public GImage back;
|
||||
[AutoFind(Name = "box")]
|
||||
public GImage box;
|
||||
[AutoFind(Name = "TextTitle")]
|
||||
public GTextField TextTitle;
|
||||
[AutoFind(Name = "TextContent")]
|
||||
public GTextField TextContent;
|
||||
[AutoFind(Name = "BtnConfirm")]
|
||||
public BtnTitleInputControl BtnConfirm;
|
||||
[AutoFind(Name = "BtnCancel")]
|
||||
public BtnTitleInputControl BtnCancel;
|
||||
public override string[] GetDependPackages(){ return new string[] {}; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Common/MessageBox.Designer.cs.meta
Normal file
2
Assets/Scripts/UI/Common/MessageBox.Designer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ce689c460bfe8245948899939807a59
|
||||
@@ -1,9 +1,33 @@
|
||||
namespace NBF
|
||||
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
|
||||
|
||||
using UnityEngine;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class MessageBox
|
||||
public partial class MessageBox : UIPanel
|
||||
{
|
||||
public static void Show(string text)
|
||||
public override string UIPackName => "Common";
|
||||
public override string UIResName => "MessageBox";
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
base.OnHide();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e4609ff88d94fa8ad77c3cb17641809
|
||||
timeCreated: 1742483434
|
||||
guid: 8e4609ff88d94fa8ad77c3cb17641809
|
||||
@@ -15,8 +15,9 @@ namespace NBF
|
||||
{
|
||||
base.OnShow();
|
||||
InputManager.OnInteractiveObjectAction += OnInteractiveObjectAction;
|
||||
InputManager.OnUseAction += OnUseAction;
|
||||
InputManager.OnUse2Action += OnUse2Action;
|
||||
InputManager.OnPlayerCanceled += OnPlayerCanceled;
|
||||
// InputManager.OnUseAction += OnUseAction;
|
||||
// InputManager.OnUse2Action += OnUse2Action;
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
@@ -38,28 +39,27 @@ namespace NBF
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUseAction()
|
||||
private void OnPlayerCanceled(string action)
|
||||
{
|
||||
if (Interactive.visible)
|
||||
{
|
||||
Interactive.Use1();
|
||||
if (action == "Use1")
|
||||
{
|
||||
Interactive.Use1();
|
||||
}
|
||||
else if (action == "Use2")
|
||||
{
|
||||
Interactive.Use2();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUse2Action()
|
||||
{
|
||||
if (Interactive.visible)
|
||||
{
|
||||
Interactive.Use2();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
base.OnHide();
|
||||
InputManager.OnInteractiveObjectAction -= OnInteractiveObjectAction;
|
||||
InputManager.OnUseAction -= OnUseAction;
|
||||
InputManager.OnUse2Action -= OnUse2Action;
|
||||
InputManager.OnUICanceled -= OnPlayerCanceled;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,14 @@ namespace NBF
|
||||
public GImage back;
|
||||
[AutoFind(Name = "Menu")]
|
||||
public CommonMenu Menu;
|
||||
[AutoFind(Name = "divisionLine")]
|
||||
public GImage divisionLine;
|
||||
[AutoFind(Name = "SubMenu")]
|
||||
public CommonSubMenu SubMenu;
|
||||
[AutoFind(Name = "List")]
|
||||
public ClassifyList List;
|
||||
[AutoFind(Name = "Currencys")]
|
||||
public GComponent Currencys;
|
||||
[AutoFind(Name = "BottomMenu")]
|
||||
public BottomMenu BottomMenu;
|
||||
public override string[] GetDependPackages(){ return new string[] {"Common"}; }
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ using UIPanel = NBC.UIPanel;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
|
||||
public class ShopGearData
|
||||
{
|
||||
public string title;
|
||||
@@ -18,14 +17,13 @@ namespace NBF
|
||||
public override string UIPackName => "Shop";
|
||||
public override string UIResName => "FishingShopPanel";
|
||||
|
||||
|
||||
private List<TabListData> _tabList = new List<TabListData>();
|
||||
|
||||
private TabListData _currentTab;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
this.AutoAddClick(OnClick);
|
||||
Menu.OnClose += Hide;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
@@ -35,7 +33,7 @@ namespace NBF
|
||||
}
|
||||
|
||||
Menu.OnTabChange += ChangeTab;
|
||||
|
||||
SubMenu.OnTabChange += ChangeSubTab;
|
||||
List.OnClickItem += OnClickItem;
|
||||
}
|
||||
|
||||
@@ -43,23 +41,35 @@ namespace NBF
|
||||
{
|
||||
base.OnShow();
|
||||
Menu.SetTabs(_tabList);
|
||||
UseBottomMenu();
|
||||
}
|
||||
|
||||
private void UseBottomMenu()
|
||||
{
|
||||
BottomMenu.OnBack += Hide;
|
||||
BottomMenu.Use();
|
||||
}
|
||||
|
||||
private void ChangeTab(int index)
|
||||
{
|
||||
Log.Info($"Change tab index={index}");
|
||||
var listData = _tabList[index];
|
||||
List.SetListData(listData.ListData);
|
||||
var tabListData = _tabList[index];
|
||||
_currentTab = tabListData;
|
||||
SubMenu.SetTabs(_currentTab.SubTab);
|
||||
}
|
||||
|
||||
private void ChangeSubTab(int index)
|
||||
{
|
||||
var subList = _currentTab.SubTab[index];
|
||||
List.SetListData(subList.Items);
|
||||
}
|
||||
|
||||
private void OnClickItem(object item)
|
||||
{
|
||||
if(item is not ShopGearItem shopGearItem) return;
|
||||
if (item is not ShopGearItem shopGearItem) return;
|
||||
Log.Info($"click item ={shopGearItem.GearData.title}");
|
||||
}
|
||||
|
||||
|
||||
private void OnClick(GComponent btn)
|
||||
{
|
||||
// if (btn == BtnClose)
|
||||
@@ -71,11 +81,14 @@ namespace NBF
|
||||
protected override void OnHide()
|
||||
{
|
||||
base.OnHide();
|
||||
BottomMenu.UnUse();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
Menu.OnTabChange -= ChangeTab;
|
||||
SubMenu.OnTabChange -= ChangeSubTab;
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Assets/Scripts/UI/Shops/ShopGearItem.Designer.cs
generated
8
Assets/Scripts/UI/Shops/ShopGearItem.Designer.cs
generated
@@ -11,15 +11,15 @@ namespace NBF
|
||||
{
|
||||
public const string URL = "ui://146ra2lqoome9";
|
||||
|
||||
public GGraph select;
|
||||
public GGraph over;
|
||||
public GImage back;
|
||||
public GImage ba;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
select = (GGraph)GetChild("select");
|
||||
over = (GGraph)GetChild("over");
|
||||
back = (GImage)GetChild("back");
|
||||
ba = (GImage)GetChild("ba");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user