仓库组件 + 防御塔升级
- `PlayerInventoryComponent`:玩家库存组件,收集金币/组件/防御塔等道具 - 补全防御塔的升级逻辑,最高 5 级
This commit is contained in:
@@ -98,10 +98,12 @@ namespace GeometryTD.UI
|
||||
switch (userData.ClickObjectType)
|
||||
{
|
||||
case CombatSelectClickObjectType.Foundation:
|
||||
_useCase.SetUpgradeVisible(true);
|
||||
_useCase.ShowForFoundation(userData.ContentPosition);
|
||||
break;
|
||||
case CombatSelectClickObjectType.Tower:
|
||||
_useCase.SetUpgradePrice(userData.UpgradeCost);
|
||||
_useCase.SetUpgradeVisible(!userData.IsTowerAtMaxLevel);
|
||||
_useCase.SetDestroyGain(userData.DestroyGain);
|
||||
_useCase.ShowForTower(userData.ContentPosition);
|
||||
break;
|
||||
@@ -133,6 +135,7 @@ namespace GeometryTD.UI
|
||||
return null;
|
||||
}
|
||||
|
||||
_useCase.SetUpgradeVisible(true);
|
||||
_useCase.ShowForFoundation(contentPosition);
|
||||
return OpenUI(_useCase.TryRefresh());
|
||||
}
|
||||
@@ -146,6 +149,7 @@ namespace GeometryTD.UI
|
||||
}
|
||||
|
||||
_useCase.SetUpgradePrice(upgradeCost);
|
||||
_useCase.SetUpgradeVisible(true);
|
||||
_useCase.SetDestroyGain(destroyGain);
|
||||
_useCase.ShowForTower(contentPosition);
|
||||
return OpenUI(_useCase.TryRefresh());
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace GeometryTD.UI
|
||||
public Vector3 WorldPosition;
|
||||
public Vector3Int CellPosition;
|
||||
public int TowerEntityId;
|
||||
public bool IsTowerAtMaxLevel;
|
||||
public int UpgradeCost;
|
||||
public int DestroyGain;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace GeometryTD.UI
|
||||
{
|
||||
public class CombatFinishFormUseCase : IUIUseCase
|
||||
{
|
||||
private readonly RepoFormUseCase _repoFormUseCase = new RepoFormUseCase();
|
||||
private CombatScheduler _combatScheduler;
|
||||
private int _defeatedEnemyCount;
|
||||
private int _gainedGold;
|
||||
@@ -57,8 +56,7 @@ namespace GeometryTD.UI
|
||||
BackpackInventoryData rewardInventory = _rewardInventory;
|
||||
if (rewardInventory == null)
|
||||
{
|
||||
RepoFormRawData repoRawData = _repoFormUseCase.CreateInitialModel();
|
||||
rewardInventory = repoRawData != null ? repoRawData.Inventory : null;
|
||||
rewardInventory = RepoFormUseCase.SampleInventory();
|
||||
}
|
||||
|
||||
return new CombatFinishFormRawData
|
||||
|
||||
@@ -134,6 +134,11 @@ namespace GeometryTD.UI
|
||||
_upgradeOption.Price = Mathf.Max(0, cost);
|
||||
}
|
||||
|
||||
public void SetUpgradeVisible(bool visible)
|
||||
{
|
||||
_upgradeOption.IsVisible = visible;
|
||||
}
|
||||
|
||||
public void SetDestroyGain(int gain)
|
||||
{
|
||||
_destroyOption.Price = Mathf.Max(0, gain);
|
||||
|
||||
@@ -7,14 +7,16 @@ namespace GeometryTD.UI
|
||||
{
|
||||
public RepoFormRawData CreateInitialModel()
|
||||
{
|
||||
BackpackInventoryData sample = BuildSampleInventory();
|
||||
BackpackInventoryData sample = GameEntry.PlayerInventory != null
|
||||
? GameEntry.PlayerInventory.GetInventorySnapshot()
|
||||
: SampleInventory();
|
||||
return new RepoFormRawData
|
||||
{
|
||||
Inventory = sample
|
||||
};
|
||||
}
|
||||
|
||||
private static BackpackInventoryData BuildSampleInventory()
|
||||
public static BackpackInventoryData SampleInventory()
|
||||
{
|
||||
BackpackInventoryData inventory = new BackpackInventoryData
|
||||
{
|
||||
@@ -75,11 +77,11 @@ namespace GeometryTD.UI
|
||||
BaseComponentInstanceId = baseComp.InstanceId,
|
||||
Stats = new DefenseTowerStatsData
|
||||
{
|
||||
AttackDamage = 30,
|
||||
DamageRandomRate = 0.05f,
|
||||
RotateSpeed = 12f,
|
||||
AttackRange = 2f,
|
||||
AttackSpeed = 1.5f,
|
||||
AttackDamage = new[] { 200, 220, 240, 260, 300 },
|
||||
DamageRandomRate = new[] { 0f, 0f, 0f, 0f, 0f },
|
||||
RotateSpeed = new[] { 200f, 210f, 220f, 230f, 240f },
|
||||
AttackRange = new[] { 4.5f, 4.7f, 4.9f, 5.1f, 5.3f },
|
||||
AttackSpeed = new[] { 1.5f, 1.2f, 1.1f, 1.0f, 0.8f },
|
||||
AttackMethodType = AttackMethodType.NormalBullet,
|
||||
AttackPropertyType = AttackPropertyType.Fire,
|
||||
Tags = new[] { TagType.Fire, TagType.BurnSpread }
|
||||
@@ -98,11 +100,11 @@ namespace GeometryTD.UI
|
||||
BaseComponentInstanceId = 0,
|
||||
Stats = new DefenseTowerStatsData
|
||||
{
|
||||
AttackDamage = 50,
|
||||
DamageRandomRate = 0.03f,
|
||||
RotateSpeed = 20f,
|
||||
AttackRange = 4f,
|
||||
AttackSpeed = 1f,
|
||||
AttackDamage = new[] { 200, 220, 240, 260, 300 },
|
||||
DamageRandomRate = new[] { 0f, 0f, 0f, 0f, 0f },
|
||||
RotateSpeed = new[] { 200f, 210f, 220f, 230f, 240f },
|
||||
AttackRange = new[] { 4.5f, 4.7f, 4.9f, 5.1f, 5.3f },
|
||||
AttackSpeed = new[] { 1.5f, 1.2f, 1.1f, 1.0f, 0.8f },
|
||||
AttackMethodType = AttackMethodType.NormalBullet,
|
||||
AttackPropertyType = AttackPropertyType.Physics,
|
||||
Tags = new[] { TagType.Pierce }
|
||||
|
||||
Reference in New Issue
Block a user