using GeometryTD.Definition; namespace GeometryTD.CustomUtility { public static class InventorySeedUtility { private static readonly TagType[] FirePool = { TagType.Fire }; private static readonly TagType[] IceFreezePool = { TagType.Ice, TagType.FreezeMask }; private static readonly TagType[] CritPiercePool = { TagType.Pierce, TagType.Crit }; private static readonly TagType[] IceShatterPool = { TagType.Ice, TagType.Shatter }; private static readonly TagType[] PierceOverpenetratePool = { TagType.Pierce, TagType.Overpenetrate }; private static readonly TagType[] IceAbsoluteZeroPool = { TagType.Ice, TagType.AbsoluteZero }; private static readonly TagType[] PierceExecutionPool = { TagType.Pierce, TagType.Execution }; public static BackpackInventoryData CreateSampleInventory() { BackpackInventoryData inventory = new BackpackInventoryData { Gold = 500 }; MuzzleCompItemData muzzle = new MuzzleCompItemData { InstanceId = 10001, ConfigId = 1, Name = "元素枪口", Rarity = InventoryRarityRuleService.NormalizeComponentRarity(RarityType.Green), Endurance = 90f, IsAssembledIntoTower = true, AttackDamage = new[] { 200, 300, 400, 500, 800 }, DamageRandomRate = 0.05f, AttackMethodType = AttackMethodType.NormalBullet, Constraint = string.Empty, Tags = ResolveSeedTags(FirePool, RarityType.Green, 10001, 1) }; BearingCompItemData bearing = new BearingCompItemData { InstanceId = 20001, ConfigId = 1, Name = "元素轴承", Rarity = InventoryRarityRuleService.NormalizeComponentRarity(RarityType.Green), Endurance = 1f, IsAssembledIntoTower = true, RotateSpeed = new[] { 100f, 120f, 130f, 140f, 150f }, AttackRange = new[] { 3f, 4f, 5f, 6f, 8f }, Constraint = string.Empty, Tags = ResolveSeedTags(FirePool, RarityType.Green, 20001, 1) }; BaseCompItemData baseComp = new BaseCompItemData { InstanceId = 30001, ConfigId = 1, Name = "元素底座", Rarity = InventoryRarityRuleService.NormalizeComponentRarity(RarityType.Green), Endurance = 88f, IsAssembledIntoTower = true, AttackSpeed = new[] { 1f, 2f, 3f, 3.5f, 0.7f }, AttackPropertyType = AttackPropertyType.Fire, Constraint = string.Empty, Tags = ResolveSeedTags(FirePool, RarityType.Green, 30001, 1) }; TowerItemData tower = new TowerItemData { InstanceId = 90001, Name = "测试防御塔-A", Rarity = InventoryRarityRuleService.ResolveTowerRarity( muzzle.Rarity, bearing.Rarity, baseComp.Rarity), IsParticipatingInCombat = true, MuzzleComponentInstanceId = muzzle.InstanceId, BearingComponentInstanceId = bearing.InstanceId, BaseComponentInstanceId = baseComp.InstanceId, Stats = new TowerStatsData { AttackDamage = new[] { 200, 220, 240, 260, 300 }, DamageRandomRate = 0f, RotateSpeed = new[] { 200f, 210f, 220f, 230f, 240f }, AttackRange = new[] { 4.5f, 4.5f, 4.5f, 4.5f, 4.5f }, AttackSpeed = new[] { 1.0f, 1.2f, 1.3f, 1.4f, 0.5f }, AttackMethodType = AttackMethodType.NormalBullet, AttackPropertyType = AttackPropertyType.Fire, TagRuntimes = TowerTagAggregationService.AggregateTowerTags( muzzle.Tags, bearing.Tags, baseComp.Tags) } }; tower.Stats.Tags = TowerTagAggregationService.FlattenUniqueTags(tower.Stats.TagRuntimes); inventory.MuzzleComponents.Add(muzzle); inventory.BaseComponents.Add(baseComp); inventory.BearingComponents.Add(bearing); inventory.Towers.Add(tower); inventory.MuzzleComponents.Add(new MuzzleCompItemData { InstanceId = 10002, ConfigId = 2, Name = "控制枪口", Rarity = InventoryRarityRuleService.NormalizeComponentRarity(RarityType.Blue), Endurance = 80, IsAssembledIntoTower = false, AttackDamage = new[] { 200, 300, 400, 500, 600 }, DamageRandomRate = 0.01f, AttackMethodType = AttackMethodType.NormalBullet, Constraint = string.Empty, Tags = ResolveSeedTags(IceFreezePool, RarityType.Blue, 10002, 2) }); inventory.MuzzleComponents.Add(new MuzzleCompItemData { InstanceId = 10003, ConfigId = 3, Name = "穿透枪口", Rarity = InventoryRarityRuleService.NormalizeComponentRarity(RarityType.Purple), Endurance = 1f, IsAssembledIntoTower = false, AttackDamage = new[] { 50, 55, 60, 80, 90 }, DamageRandomRate = 0.02f, AttackMethodType = AttackMethodType.NormalBullet, Constraint = string.Empty, Tags = ResolveSeedTags(CritPiercePool, RarityType.Purple, 10003, 3) }); inventory.BearingComponents.Add(new BearingCompItemData { InstanceId = 20002, ConfigId = 2, Name = "控制轴承", Rarity = InventoryRarityRuleService.NormalizeComponentRarity(RarityType.Blue), Endurance = 20, IsAssembledIntoTower = false, RotateSpeed = new[] { 200f, 250f, 300f, 320f, 350f }, AttackRange = new[] { 6f, 6.5f, 7f, 8f, 8f }, Constraint = string.Empty, Tags = ResolveSeedTags(IceShatterPool, RarityType.Blue, 20002, 2) }); inventory.BearingComponents.Add(new BearingCompItemData { InstanceId = 20003, ConfigId = 3, Name = "穿透轴承", Rarity = InventoryRarityRuleService.NormalizeComponentRarity(RarityType.Purple), Endurance = 96f, IsAssembledIntoTower = false, RotateSpeed = new[] { 60f, 70f, 80f, 90f, 100f }, AttackRange = new[] { 4f, 4.5f, 5f, 5.5f, 6f }, Constraint = string.Empty, Tags = ResolveSeedTags(PierceOverpenetratePool, RarityType.Purple, 20003, 3) }); inventory.BaseComponents.Add(new BaseCompItemData { InstanceId = 30002, ConfigId = 2, Name = "控制底座", Rarity = InventoryRarityRuleService.NormalizeComponentRarity(RarityType.Blue), Endurance = 50f, IsAssembledIntoTower = false, AttackSpeed = new[] { 4f, 4.2f, 4.4f, 4.6f, 4.8f }, AttackPropertyType = AttackPropertyType.Ice, Constraint = string.Empty, Tags = ResolveSeedTags(IceAbsoluteZeroPool, RarityType.Blue, 30002, 2) }); inventory.BaseComponents.Add(new BaseCompItemData { InstanceId = 30003, ConfigId = 3, Name = "穿透底座", Rarity = InventoryRarityRuleService.NormalizeComponentRarity(RarityType.Purple), Endurance = 30f, IsAssembledIntoTower = false, AttackSpeed = new[] { 1f, 1f, 1f, 1f, 1f }, AttackPropertyType = AttackPropertyType.Physics, Constraint = string.Empty, Tags = ResolveSeedTags(PierceExecutionPool, RarityType.Purple, 30003, 3) }); inventory.ParticipantTowerInstanceIds.Add(90001); return inventory; } private static TagType[] ResolveSeedTags(TagType[] possibleTags, RarityType rarity, long instanceId, int configId) { return ComponentTagGenerationService.ResolveComponentTags( possibleTags, rarity, InventoryTagSourceType.Seed, instanceId, configId); } } }