补全防御塔组装与介绍描述功能

- RepoForm.CombineArea:防御塔组装,直接继承所有组件的属性
- ItemDescUtility:根据属性构建不同的 ItemDescForm 的文本
This commit is contained in:
SepComet
2026-03-04 18:17:10 +08:00
parent e12d2e73b2
commit 1e5803f4c5
29 changed files with 832 additions and 168 deletions
@@ -5,25 +5,25 @@ using UnityEngine;
namespace GeometryTD.Entity.EntityData
{
[Serializable]
public class DefenseTowerData : EntityDataBase
public class TowerData : EntityDataBase
{
[SerializeField] private DefenseTowerStatsData _stats = new DefenseTowerStatsData();
[SerializeField] private TowerStatsData _stats = new TowerStatsData();
[SerializeField] private int _towerLevel = 0;
public DefenseTowerData(int entityId, int typeId, Vector3 position, Quaternion rotation,
DefenseTowerStatsData stats, int towerLevel = 0)
public TowerData(int entityId, int typeId, Vector3 position, Quaternion rotation,
TowerStatsData stats, int towerLevel = 0)
: base(entityId, typeId)
{
Position = position;
Rotation = rotation;
_stats = stats ?? new DefenseTowerStatsData();
_stats = stats ?? new TowerStatsData();
_towerLevel = Mathf.Max(0, towerLevel);
}
public DefenseTowerStatsData Stats
public TowerStatsData Stats
{
get => _stats;
set => _stats = value ?? new DefenseTowerStatsData();
set => _stats = value ?? new TowerStatsData();
}
public int TowerLevel
@@ -46,9 +46,9 @@ namespace GeometryTD
entityComponent.ShowEntity(typeof(EnemyEntity), "Enemy", Constant.AssetPriority.EnemyAsset, data);
}
public static void ShowDefenseTower(this EntityComponent entityComponent, DefenseTowerData data)
public static void ShowDefenseTower(this EntityComponent entityComponent, TowerData data)
{
entityComponent.ShowEntity(typeof(DefenseTowerEntity), "Tower", Constant.AssetPriority.EnemyAsset, data);
entityComponent.ShowEntity(typeof(TowerEntity), "Tower", Constant.AssetPriority.EnemyAsset, data);
}
public static void ShowBullet(this EntityComponent entityComponent, BulletData data)
@@ -5,16 +5,16 @@ using UnityGameFramework.Runtime;
namespace GeometryTD.Entity
{
public class DefenseTowerEntity : EntityBase
public class TowerEntity : EntityBase
{
private DefenseTowerController _towerController;
private TowerController _towerController;
public void SetAttackRangeVisible(bool visible)
{
_towerController?.SetAttackRangeVisible(visible);
}
public bool TryApplyStats(DefenseTowerStatsData stats, int towerLevel)
public bool TryApplyStats(TowerStatsData stats, int towerLevel)
{
if (_towerController == null || stats == null)
{
@@ -29,7 +29,7 @@ namespace GeometryTD.Entity
{
base.OnInit(userData);
_towerController = GetComponent<DefenseTowerController>();
_towerController = GetComponent<TowerController>();
if (_towerController == null)
{
Log.Error("DefenseTowerController is missing on tower entity '{0}'.", name);
@@ -45,7 +45,7 @@ namespace GeometryTD.Entity
return;
}
if (userData is not DefenseTowerData towerData)
if (userData is not TowerData towerData)
{
Log.Warning("DefenseTowerData is invalid for tower entity '{0}'.", Id);
_towerController.OnReset();