完成交互逻辑
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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[] {}; }
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Assets/Scripts/UI/Fishing/InteractiveTag.Designer.cs
generated
Normal file
25
Assets/Scripts/UI/Fishing/InteractiveTag.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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d866f9f28bbd2d46a69e9b1bd2e9fa8
|
||||
58
Assets/Scripts/UI/Fishing/InteractiveTag.cs
Normal file
58
Assets/Scripts/UI/Fishing/InteractiveTag.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Fishing/InteractiveTag.cs.meta
Normal file
2
Assets/Scripts/UI/Fishing/InteractiveTag.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04d94697f36267345bce12ab05cbb3d2
|
||||
27
Assets/Scripts/UI/FishingStateInfo.Designer.cs
generated
Normal file
27
Assets/Scripts/UI/FishingStateInfo.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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/FishingStateInfo.Designer.cs.meta
Normal file
2
Assets/Scripts/UI/FishingStateInfo.Designer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dde0fb0491131de41919399c219e6cd8
|
||||
15
Assets/Scripts/UI/FishingStateInfo.cs
Normal file
15
Assets/Scripts/UI/FishingStateInfo.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class FishingStateInfo : GLabel
|
||||
{
|
||||
private void OnInited()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/FishingStateInfo.cs.meta
Normal file
2
Assets/Scripts/UI/FishingStateInfo.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c0786297b4fc9843a13ad5b5260936d
|
||||
Reference in New Issue
Block a user