S7-01 + S7-02

This commit is contained in:
2026-03-12 10:46:11 +08:00
parent d34af661b9
commit 185ea43323
20 changed files with 468 additions and 112 deletions
@@ -13,6 +13,8 @@ namespace GeometryTD.UI
{
private const int GoodsCount = 4;
private long _nextTempInstanceId = 1000000;
private int _activeRunSeed;
private int _activeSequenceIndex = -1;
private readonly List<GoodsItemRawData> _currentGoods = new List<GoodsItemRawData>(GoodsCount);
private readonly List<DRShopPrice> _shopPriceRows = new List<DRShopPrice>();
@@ -21,13 +23,15 @@ namespace GeometryTD.UI
private IDataTable<DRBearingComp> _bearingCompTable;
private IDataTable<DRBaseComp> _baseCompTable;
public bool PrepareForOpen()
public bool PrepareForOpen(int runSeed = 0, int sequenceIndex = -1)
{
if (!EnsureTables())
{
return false;
}
_activeRunSeed = runSeed;
_activeSequenceIndex = sequenceIndex;
_currentGoods.Clear();
for (int i = 0; i < GoodsCount; i++)
{
@@ -132,7 +136,7 @@ namespace GeometryTD.UI
private bool TryBuildRandomGoodsItem(int goodsIndex, out GoodsItemRawData goodsItem)
{
goodsItem = null;
TowerCompItemData sourceItem = BuildRandomComponentItem();
TowerCompItemData sourceItem = BuildRandomComponentItem(goodsIndex);
if (sourceItem == null)
{
return false;
@@ -153,7 +157,7 @@ namespace GeometryTD.UI
return true;
}
private TowerCompItemData BuildRandomComponentItem()
private TowerCompItemData BuildRandomComponentItem(int goodsIndex)
{
int slotRoll = UnityEngine.Random.Range(0, 3);
DRShopPrice priceRow = _shopPriceRows[UnityEngine.Random.Range(0, _shopPriceRows.Count)];
@@ -163,15 +167,15 @@ namespace GeometryTD.UI
switch (slotRoll)
{
case 0:
return BuildRandomMuzzleItem(rarity);
return BuildRandomMuzzleItem(rarity, goodsIndex);
case 1:
return BuildRandomBearingItem(rarity);
return BuildRandomBearingItem(rarity, goodsIndex);
default:
return BuildRandomBaseItem(rarity);
return BuildRandomBaseItem(rarity, goodsIndex);
}
}
private MuzzleCompItemData BuildRandomMuzzleItem(RarityType rarity)
private MuzzleCompItemData BuildRandomMuzzleItem(RarityType rarity, int goodsIndex)
{
DRMuzzleComp[] rows = _muzzleCompTable.GetAllDataRows();
DRMuzzleComp config = rows[UnityEngine.Random.Range(0, rows.Length)];
@@ -188,16 +192,14 @@ namespace GeometryTD.UI
Tags = ComponentTagGenerationService.ResolveComponentTags(
config.PossibleTag,
normalizedRarity,
InventoryTagSourceType.Shop,
instanceId,
config.Id),
InventoryTagRandomContext.CreateShop(_activeRunSeed, _activeSequenceIndex, goodsIndex, config.Id)),
AttackDamage = config.AttackDamage != null ? (int[])config.AttackDamage.Clone() : Array.Empty<int>(),
DamageRandomRate = config.DamageRandomRate,
AttackMethodType = config.AttackMethodType
};
}
private BearingCompItemData BuildRandomBearingItem(RarityType rarity)
private BearingCompItemData BuildRandomBearingItem(RarityType rarity, int goodsIndex)
{
DRBearingComp[] rows = _bearingCompTable.GetAllDataRows();
DRBearingComp config = rows[UnityEngine.Random.Range(0, rows.Length)];
@@ -214,15 +216,13 @@ namespace GeometryTD.UI
Tags = ComponentTagGenerationService.ResolveComponentTags(
config.PossibleTag,
normalizedRarity,
InventoryTagSourceType.Shop,
instanceId,
config.Id),
InventoryTagRandomContext.CreateShop(_activeRunSeed, _activeSequenceIndex, goodsIndex, config.Id)),
RotateSpeed = config.RotateSpeed != null ? (float[])config.RotateSpeed.Clone() : Array.Empty<float>(),
AttackRange = config.AttackRange != null ? (float[])config.AttackRange.Clone() : Array.Empty<float>()
};
}
private BaseCompItemData BuildRandomBaseItem(RarityType rarity)
private BaseCompItemData BuildRandomBaseItem(RarityType rarity, int goodsIndex)
{
DRBaseComp[] rows = _baseCompTable.GetAllDataRows();
DRBaseComp config = rows[UnityEngine.Random.Range(0, rows.Length)];
@@ -239,9 +239,7 @@ namespace GeometryTD.UI
Tags = ComponentTagGenerationService.ResolveComponentTags(
config.PossibleTag,
normalizedRarity,
InventoryTagSourceType.Shop,
instanceId,
config.Id),
InventoryTagRandomContext.CreateShop(_activeRunSeed, _activeSequenceIndex, goodsIndex, config.Id)),
AttackSpeed = config.AttackSpeed != null ? (float[])config.AttackSpeed.Clone() : Array.Empty<float>(),
AttackPropertyType = config.AttackPropertyType
};