85 lines
2.4 KiB
C#
85 lines
2.4 KiB
C#
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;
|
|
}
|
|
}
|
|
|
|
}
|
|
} |