添加节点测试 UI 和商店节点(占位)
- TestMenuForm:节点测试 UI - ShopNodeComponent:商店节点组件,只有 OnInit() 和 StartShop() 两个空方法
This commit is contained in:
@@ -23,6 +23,8 @@ public partial class GameEntry : MonoBehaviour
|
||||
public static EventNodeComponent EventNode { get; private set; }
|
||||
|
||||
public static CombatNodeComponent CombatNode { get; private set; }
|
||||
|
||||
public static ShopNodeComponent ShopNode { get; private set; }
|
||||
|
||||
private static void InitCustomComponents()
|
||||
{
|
||||
@@ -31,5 +33,6 @@ public partial class GameEntry : MonoBehaviour
|
||||
UIRouter = UnityGameFramework.Runtime.GameEntry.GetComponent<UIRouterComponent>();
|
||||
EventNode = UnityGameFramework.Runtime.GameEntry.GetComponent<EventNodeComponent>();
|
||||
CombatNode = UnityGameFramework.Runtime.GameEntry.GetComponent<CombatNodeComponent>();
|
||||
ShopNode = UnityGameFramework.Runtime.GameEntry.GetComponent<ShopNodeComponent>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using GameFramework.DataTable;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Definition;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using GeometryTD.UI;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.CustomComponent
|
||||
{
|
||||
public class ShopNodeComponent : GameFrameworkComponent
|
||||
{
|
||||
public void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void StartShop()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 550e28d04b3e8b6439caac076581089c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -26,6 +26,11 @@
|
||||
/// 关于。
|
||||
/// </summary>
|
||||
AboutForm = 102,
|
||||
|
||||
/// <summary>
|
||||
/// 测试菜单。
|
||||
/// </summary>
|
||||
TestMenuForm = 150,
|
||||
|
||||
/// <summary>
|
||||
/// 事件节点界面。
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace GeometryTD.CustomEvent
|
||||
{
|
||||
public enum TestMenuNodeType : byte
|
||||
{
|
||||
Combat = 1,
|
||||
Event = 2,
|
||||
Shop = 3
|
||||
}
|
||||
|
||||
public class TestMenuNodeClickEventArgs : GameEventArgs
|
||||
{
|
||||
public static int EventId => typeof(TestMenuNodeClickEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public TestMenuNodeType NodeType { get; private set; }
|
||||
|
||||
public static TestMenuNodeClickEventArgs Create(TestMenuNodeType nodeType)
|
||||
{
|
||||
TestMenuNodeClickEventArgs args = ReferencePool.Acquire<TestMenuNodeClickEventArgs>();
|
||||
args.NodeType = nodeType;
|
||||
return args;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
NodeType = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 411999db6fd14f9485be9606a83c97ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -25,13 +25,9 @@ namespace GeometryTD.Procedure
|
||||
GameStart = false;
|
||||
GameEntry.EventNode.OnInit();
|
||||
GameEntry.CombatNode.OnInit(LevelThemeType.Plain);
|
||||
GameEntry.CombatNode.StartCombat();
|
||||
GameEntry.ShopNode.OnInit();
|
||||
|
||||
//GameEntry.EventNode.StartEvent();
|
||||
|
||||
// _repoFormUseCase = new RepoFormUseCase();
|
||||
// GameEntry.UIRouter.BindUIUseCase(UIFormType.RepoForm, _repoFormUseCase);
|
||||
// GameEntry.UIRouter.OpenUI(UIFormType.RepoForm);
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.TestMenuForm);
|
||||
}
|
||||
|
||||
protected override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds,
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 259253e364fe32a4195e182f78b8cc54
|
||||
guid: bf3ce5b1e0a94d94cbbd70bbc1ba3519
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace GeometryTD.UI
|
||||
{
|
||||
public class TestMenuFormContext : UIContext
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63c47e5da7f79214b9430a2654d385bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c54ad6fe1b9cbc468edcec51d2fe534
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
using GeometryTD.CustomEvent;
|
||||
using GeometryTD.Definition;
|
||||
using GameFramework.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.UI
|
||||
{
|
||||
public class TestMenuFormController : UIFormControllerCommonBase<TestMenuFormContext, TestMenuForm>
|
||||
{
|
||||
protected override UIFormType UIFormTypeId => UIFormType.TestMenuForm;
|
||||
|
||||
protected override void RefreshUI(TestMenuForm form, TestMenuFormContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
|
||||
protected override void SubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Subscribe(TestMenuNodeClickEventArgs.EventId, OnNodeClick);
|
||||
}
|
||||
|
||||
protected override void UnsubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(TestMenuNodeClickEventArgs.EventId, OnNodeClick);
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
{
|
||||
if (userData is TestMenuFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("TestMenuFormController.OpenUI() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return OpenUIInternal(BuildDefaultContext());
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
if (useCase != null)
|
||||
{
|
||||
Log.Warning("TestMenuFormController does not use a use case.");
|
||||
}
|
||||
}
|
||||
|
||||
private static TestMenuFormContext BuildDefaultContext()
|
||||
{
|
||||
return new TestMenuFormContext();
|
||||
}
|
||||
|
||||
private void OnNodeClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is TestMenuForm form))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(e is TestMenuNodeClickEventArgs args))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (args.NodeType)
|
||||
{
|
||||
case TestMenuNodeType.Combat:
|
||||
GameEntry.CombatNode.StartCombat();
|
||||
return;
|
||||
case TestMenuNodeType.Event:
|
||||
GameEntry.EventNode.StartEvent();
|
||||
return;
|
||||
case TestMenuNodeType.Shop:
|
||||
GameEntry.ShopNode.StartShop();
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84f4abe0ec5c55745b300177fe85fbc8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0052e673c97ae1349bb85014431b2a55
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fe1249a94e09e3478b142e671d272a1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6217fcd5b07f8f341a77124e269e94c4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using GeometryTD.CustomEvent;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.UI
|
||||
{
|
||||
public class TestMenuForm : UGuiForm
|
||||
{
|
||||
private TestMenuFormContext _context;
|
||||
|
||||
public void RefreshUI(TestMenuFormContext context)
|
||||
{
|
||||
_context = context;
|
||||
if (_context == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCombatButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, TestMenuNodeClickEventArgs.Create(TestMenuNodeType.Combat));
|
||||
}
|
||||
|
||||
public void OnEventButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, TestMenuNodeClickEventArgs.Create(TestMenuNodeType.Event));
|
||||
}
|
||||
|
||||
public void OnShopButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, TestMenuNodeClickEventArgs.Create(TestMenuNodeType.Shop));
|
||||
}
|
||||
|
||||
protected override void OnOpen(object userData)
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
if (userData is TestMenuFormContext context)
|
||||
{
|
||||
RefreshUI(context);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Warning("TestMenuForm requires TestMenuFormContext as userData.");
|
||||
}
|
||||
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
{
|
||||
_context = null;
|
||||
|
||||
base.OnClose(isShutdown, userData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1cfd203143c34c4e853705bdc409e04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user