完成交互逻辑

This commit is contained in:
2025-05-20 00:22:31 +08:00
parent 84d13e8981
commit b0abc1c30a
63 changed files with 42664 additions and 42166 deletions

View File

@@ -8,6 +8,8 @@ namespace NBF
{
public static void BindAll()
{
UIObjectFactory.SetPackageItemExtension(FishingStateInfo.URL, typeof(FishingStateInfo));
UIObjectFactory.SetPackageItemExtension(InteractiveTag.URL, typeof(InteractiveTag));
UIObjectFactory.SetPackageItemExtension(FishingPower.URL, typeof(FishingPower));
UIObjectFactory.SetPackageItemExtension(WeatherInfo.URL, typeof(WeatherInfo));
}

View File

@@ -13,12 +13,18 @@ namespace NBF
public GObject this[string aKey] => ContentPane.GetChild(aKey);
[AutoFind(Name = "throwCtrl")]
public Controller throwCtrl;
[AutoFind(Name = "fishingState")]
public Controller fishingState;
[AutoFind(Name = "ThrowProgress")]
public GProgressBar ThrowProgress;
[AutoFind(Name = "TextFPS")]
public GTextField TextFPS;
[AutoFind(Name = "TextTime")]
public WeatherInfo TextTime;
[AutoFind(Name = "FishingState")]
public FishingStateInfo FishingState;
[AutoFind(Name = "Interactive")]
public InteractiveTag Interactive;
public override string[] GetDependPackages(){ return new string[] {}; }

View File

@@ -11,14 +11,12 @@ namespace NBF
public override string UIPackName => "Fishing";
public override string UIResName => "FishingPanel";
protected override void OnInit()
{
base.OnInit();
}
protected override void OnShow()
{
base.OnShow();
InputManager.OnInteractiveObjectAction += OnInteractiveObjectAction;
InputManager.OnUseAction += OnUseAction;
InputManager.OnUse2Action += OnUse2Action;
}
protected override void OnUpdate()
@@ -27,14 +25,41 @@ namespace NBF
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 OnUseAction()
{
if (Interactive.visible)
{
Interactive.Use1();
}
}
private void OnUse2Action()
{
if (Interactive.visible)
{
Interactive.Use2();
}
}
protected override void OnHide()
{
base.OnHide();
}
protected override void OnDestroy()
{
base.OnDestroy();
InputManager.OnInteractiveObjectAction -= OnInteractiveObjectAction;
InputManager.OnUseAction -= OnUseAction;
InputManager.OnUse2Action -= OnUse2Action;
}
}
}

View 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 InteractiveTag
{
public const string URL = "ui://682kb9n0fcfg1p";
public GList List;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
List = (GList)GetChild("List");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0d866f9f28bbd2d46a69e9b1bd2e9fa8

View File

@@ -0,0 +1,58 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using FairyGUI;
namespace NBF
{
public partial class InteractiveTag : GLabel
{
private InteractiveObject _interactiveObject;
private InteractiveData _interactiveData;
private void OnInited()
{
}
public void SetData(InteractiveObject interactiveObject)
{
_interactiveObject = interactiveObject;
List.RemoveChildrenToPool();
var interactiveType = GameDef.InteractiveDataList.Find(t => t.Type == interactiveObject.Type);
if (interactiveType != null)
{
_interactiveData = interactiveType;
if (!string.IsNullOrEmpty(interactiveType.Use1))
{
var item1 = List.AddItemFromPool().asLabel;
item1.title = "E - " + interactiveType.Use1Title;
}
if (!string.IsNullOrEmpty(interactiveType.Use2))
{
var item2 = List.AddItemFromPool().asLabel;
item2.title = "Y - " + interactiveType.Use2Title;
}
var iconUrl = UIPackage.GetItemURL("Common", interactiveType.Icon);
icon = iconUrl;
title = interactiveType.Name;
}
}
public void Use1()
{
if (string.IsNullOrEmpty(_interactiveData.Use1)) return;
}
public void Use2()
{
if (string.IsNullOrEmpty(_interactiveData.Use2)) return;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 04d94697f36267345bce12ab05cbb3d2

View 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 FishingStateInfo
{
public const string URL = "ui://682kb9n0fcfg1o";
public FishingPower Power;
public GTextField TextTitle;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
Power = (FishingPower)GetChild("Power");
TextTitle = (GTextField)GetChild("TextTitle");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: dde0fb0491131de41919399c219e6cd8

View File

@@ -0,0 +1,15 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class FishingStateInfo : GLabel
{
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0c0786297b4fc9843a13ad5b5260936d