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:
SepComet
2026-02-26 21:36:29 +08:00
parent bb0a4edfb7
commit 11e4c1c1f2
115 changed files with 3218 additions and 135 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 34c97e1af6767d049b17b5c4ff75cb5a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
using GeometryTD.UI;
namespace GeometryTD.UI
{
public class EventFormContext : UIContext
{
public int EventId;
public string Title;
public string Description;
public EventOptionItemContext[] OptionItems;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 95f3e80a51954c66b14e41365622d63f
timeCreated: 1772104202
@@ -0,0 +1,8 @@
namespace GeometryTD.UI
{
public class EventOptionItemContext
{
public int OptionIndex;
public string OptionText;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f56befc364564ac8b499f81ca48a165b
timeCreated: 1772104201
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 043cb0d817552b549aeff457ac685a0b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,124 @@
using GeometryTD.Definition;
using GeometryTD.CustomEvent;
using GameFramework.Event;
using UnityGameFramework.Runtime;
namespace GeometryTD.UI
{
public class EventFormController : UIFormControllerCommonBase<EventFormContext, EventForm>
{
private EventFormUseCase m_UseCase;
protected override UIFormType UIFormTypeId => UIFormType.EventForm;
protected override void RefreshUI(EventForm form, EventFormContext context)
{
form.RefreshUI(context);
}
protected override void SubscribeCustomEvents()
{
GameEntry.Event.Subscribe(EventOptionItemSelectedEventArgs.EventId, OnEventOptionItemSelected);
}
protected override void UnsubscribeCustomEvents()
{
GameEntry.Event.Unsubscribe(EventOptionItemSelectedEventArgs.EventId, OnEventOptionItemSelected);
}
public override int? OpenUI(object userData = null)
{
if (userData is EventFormContext eventFormContext)
{
return OpenUIInternal(eventFormContext);
}
if (userData is EventFormRawData rawDataFromUserData)
{
return OpenUI(rawDataFromUserData);
}
if (userData != null)
{
Log.Warning("EventFormController.OpenUI() userData type is invalid.");
return null;
}
if (m_UseCase == null)
{
Log.Error("EventFormController.OpenUI() useCase is null.");
return null;
}
EventFormRawData rawData = m_UseCase.CreateInitialModel();
return OpenUI(rawData);
}
public int? OpenUI(EventFormRawData rawData)
{
EventFormContext context = BuildContext(rawData);
return OpenUIInternal(context);
}
public override void BindUseCase(IUIUseCase useCase)
{
if (!(useCase is EventFormUseCase eventFormUseCase))
{
Log.Error("EventFormController.BindUseCase() useCase is invalid.");
return;
}
m_UseCase = eventFormUseCase;
}
private static EventFormContext BuildContext(EventFormRawData rawData)
{
if (rawData?.EventItem == null)
{
return null;
}
EventOptionItemContext[] options = new EventOptionItemContext[4];
for (int i = 0; i < options.Length; i++)
{
string optionText = string.Empty;
if (rawData.EventItem.Options != null && i < rawData.EventItem.Options.Length &&
rawData.EventItem.Options[i] != null)
{
optionText = rawData.EventItem.Options[i].OptionText;
}
options[i] = new EventOptionItemContext
{
OptionIndex = i,
OptionText = optionText
};
}
return new EventFormContext
{
EventId = rawData.EventItem.Id,
Title = rawData.EventItem.Title,
Description = rawData.EventItem.Description,
OptionItems = options
};
}
private void OnEventOptionItemSelected(object sender, GameEventArgs e)
{
if (!(e is EventOptionItemSelectedEventArgs args))
{
return;
}
if (m_UseCase == null)
{
Log.Warning("EventFormController.OnOptionSelected() useCase is null.");
return;
}
m_UseCase.SelectOption(args.SelectedItemId);
CloseUI();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 916da3490ed14b01ae064cbb37880bba
timeCreated: 1772104204
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a0e002d6d3ee84d46859c7933b285513
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
using GeometryTD.Definition;
namespace GeometryTD.UI
{
public class EventFormRawData
{
public EventItem EventItem;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 463e60ff83314069b83158ccf64cddef
timeCreated: 1772104200
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 90fb2ec88edcd2942abcf17a4e206f3e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,46 @@
using GeometryTD.Definition;
using GeometryTD.UI;
using UnityGameFramework.Runtime;
namespace GeometryTD.UI
{
public class EventFormUseCase : IUIUseCase
{
private EventItem m_CurrentEvent;
public void SetCurrentEvent(EventItem eventItem)
{
m_CurrentEvent = eventItem;
}
public EventFormRawData CreateInitialModel()
{
if (m_CurrentEvent == null)
{
return null;
}
return new EventFormRawData
{
EventItem = m_CurrentEvent
};
}
public EventOption SelectOption(int optionIndex)
{
if (m_CurrentEvent == null || m_CurrentEvent.Options == null)
{
return null;
}
if (optionIndex < 0 || optionIndex >= m_CurrentEvent.Options.Length)
{
Log.Warning("EventFormUseCase.SelectOption() option index is invalid: {0}", optionIndex);
return null;
}
// TODO: 执行 Requirements 校验、CostEffects/RewardEffects 结算与后续节点推进。
return m_CurrentEvent.Options[optionIndex];
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 80d6d6100109462ea498781e9e70201d
timeCreated: 1772104203
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1f5bf29ff4f1c404cb5b42fb54a8e0b4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -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