P0-02 补齐数据表:组件、敌人、波次、节点、事件、商店商品
- 组件:
- 底座:Assets\GameMain\DataTables\BaseComp.txt
- 轴承:Assets\GameMain\DataTables\BearingComp.txt
- 枪口:Assets\GameMain\DataTables\MuzzleComp.txt
- 敌人:Assets\GameMain\DataTables\Enemy.txt
- 波次:
- 关卡:Assets\GameMain\DataTables\Level.txt
- 关卡阶段(波次):Assets\GameMain\DataTables\LevelPhase.txt
- 波次条目(波次出怪规则):Assets\GameMain\DataTables\LevelSpawnEntry.txt
- 事件:Assets\GameMain\DataTables\Event.txt
- 商店:Assets\GameMain\DataTables\ShopPrice.txt
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.UI
|
||||
{
|
||||
public class EventForm : UGuiForm
|
||||
{
|
||||
[SerializeField] private TMP_Text m_TitleText;
|
||||
[SerializeField] private TMP_Text m_DescriptionText;
|
||||
[SerializeField] private EventOptionItem[] m_OptionItems;
|
||||
|
||||
private EventFormContext m_Context;
|
||||
public void RefreshUI(EventFormContext context)
|
||||
{
|
||||
m_Context = context;
|
||||
|
||||
if (m_TitleText != null)
|
||||
{
|
||||
m_TitleText.text = context?.Title ?? string.Empty;
|
||||
}
|
||||
|
||||
if (m_DescriptionText != null)
|
||||
{
|
||||
m_DescriptionText.text = context?.Description ?? string.Empty;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_OptionItems.Length; i++)
|
||||
{
|
||||
EventOptionItemContext optionContext = null;
|
||||
if (context?.OptionItems != null && i < context.OptionItems.Length)
|
||||
{
|
||||
optionContext = context.OptionItems[i];
|
||||
}
|
||||
|
||||
if (m_OptionItems[i] != null)
|
||||
{
|
||||
m_OptionItems[i].OnInit(optionContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnOpen(object userData)
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
if (userData is EventFormContext context)
|
||||
{
|
||||
RefreshUI(context);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Warning("EventForm requires EventFormContext as userData.");
|
||||
}
|
||||
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
{
|
||||
m_Context = null;
|
||||
|
||||
if (m_TitleText != null)
|
||||
{
|
||||
m_TitleText.text = string.Empty;
|
||||
}
|
||||
|
||||
if (m_DescriptionText != null)
|
||||
{
|
||||
m_DescriptionText.text = string.Empty;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_OptionItems.Length; i++)
|
||||
{
|
||||
if (m_OptionItems[i] != null)
|
||||
{
|
||||
m_OptionItems[i].OnReset();
|
||||
}
|
||||
}
|
||||
|
||||
base.OnClose(isShutdown, userData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81064d72b60548b6b54d07d94d20b519
|
||||
timeCreated: 1772104206
|
||||
@@ -0,0 +1,50 @@
|
||||
using GeometryTD.CustomEvent;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GeometryTD.UI
|
||||
{
|
||||
public class EventOptionItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text _optionText;
|
||||
|
||||
private int _optionIndex;
|
||||
|
||||
public void OnInit(EventOptionItemContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
OnReset();
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
_optionIndex = context.OptionIndex;
|
||||
if (_optionText != null)
|
||||
{
|
||||
_optionText.text = context.OptionText ?? string.Empty;
|
||||
}
|
||||
|
||||
gameObject.SetActive(!string.IsNullOrEmpty(context.OptionText));
|
||||
}
|
||||
|
||||
public void OnReset()
|
||||
{
|
||||
_optionIndex = -1;
|
||||
if (_optionText != null)
|
||||
{
|
||||
_optionText.text = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClick()
|
||||
{
|
||||
if (_optionIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Event.Fire(this, EventOptionItemSelectedEventArgs.Create(_optionIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86cf465d14c649a58473c19ae946d220
|
||||
timeCreated: 1772104205
|
||||
Reference in New Issue
Block a user