添加节点测试 UI 和商店节点(占位)

- TestMenuForm:节点测试 UI
- ShopNodeComponent:商店节点组件,只有 OnInit() 和 StartShop() 两个空方法
This commit is contained in:
SepComet
2026-02-28 16:28:37 +08:00
parent bee7ae381e
commit 9504c1ca18
22 changed files with 1186 additions and 7 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bf3ce5b1e0a94d94cbbd70bbc1ba3519
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -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: