S4 收尾
This commit is contained in:
@@ -5,6 +5,8 @@ namespace GeometryTD.Definition
|
||||
None = 0,
|
||||
Status = 1,
|
||||
NumericModifier = 2,
|
||||
AttackShape = 3
|
||||
AttackShape = 3,
|
||||
// Enhances another applied status on the same hit, but does not create its own enemy-held state.
|
||||
StatusModifier = 4
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f2ab8a7e488575498ac933a125360d1
|
||||
guid: 1c2505f2ce4cfd7499cdd3bc8c0e22eb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eae63f0557814c14a9a2b9e6c8726404
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+3
-4
@@ -7,13 +7,12 @@ namespace GeometryTD.Definition
|
||||
{
|
||||
public static class EnemyStatusTagRegistry
|
||||
{
|
||||
// Only tags that create or tick enemy-held status state belong here.
|
||||
private static readonly Dictionary<TagType, IEnemyStatusTagEffect> EffectsByTag =
|
||||
new Dictionary<TagType, IEnemyStatusTagEffect>
|
||||
{
|
||||
[TagType.Fire] = new FireTagEffect(),
|
||||
[TagType.Inferno] = new InfernoTagEffect(),
|
||||
[TagType.Ice] = new IceTagEffect(),
|
||||
[TagType.AbsoluteZero] = new AbsoluteZeroTagEffect()
|
||||
[TagType.Ice] = new IceTagEffect()
|
||||
};
|
||||
|
||||
public static IReadOnlyDictionary<TagType, IEnemyStatusTagEffect> Effects => EffectsByTag;
|
||||
@@ -23,4 +22,4 @@ namespace GeometryTD.Definition
|
||||
return EffectsByTag.TryGetValue(tagType, out effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df89bbfead1892c469024466c479bef1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-1
@@ -17,7 +17,7 @@ namespace GeometryTD.Definition
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!TagConfigRegistry.TryGetDefinition(runtime.TagType, out TagDefinitionData definition) ||
|
||||
if (!TagDefinitionRegistry.TryGetDefinition(runtime.TagType, out TagDefinition definition) ||
|
||||
definition == null ||
|
||||
definition.Category != TagCategory.AttackShape ||
|
||||
definition.TriggerPhase != triggerPhase ||
|
||||
+1
-1
@@ -30,7 +30,7 @@ namespace GeometryTD.Definition
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!TagConfigRegistry.TryGetDefinition(runtime.TagType, out TagDefinitionData definition) ||
|
||||
if (!TagDefinitionRegistry.TryGetDefinition(runtime.TagType, out TagDefinition definition) ||
|
||||
definition == null ||
|
||||
definition.Category != TagCategory.NumericModifier ||
|
||||
definition.TriggerPhase != TagTriggerPhase.OnBeforeHit ||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efece7a307e9a2c44b7247921e8b3194
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 343c21d630e34fc47a132c7d94f72bec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+3
-3
@@ -11,7 +11,7 @@ namespace GeometryTD.Definition
|
||||
public override void Apply(AttackPayload attackPayload, EnemyTagStatusRuntime runtime,
|
||||
TagRuntimeData runtimeData)
|
||||
{
|
||||
Debug.Assert(TagConfigRegistry.TryGetDefinition(TagType, out TagDefinitionData definition));
|
||||
Debug.Assert(TagDefinitionRegistry.TryGetDefinition(TagType, out TagDefinition definition));
|
||||
|
||||
FireTagConfig config = definition.Config as FireTagConfig;
|
||||
Debug.Assert(config != null);
|
||||
@@ -72,7 +72,7 @@ namespace GeometryTD.Definition
|
||||
private static float GetInfernoBonusDuration(int infernoStack)
|
||||
{
|
||||
if (infernoStack <= 0 ||
|
||||
!TagConfigRegistry.TryGetDefinition(TagType.Inferno, out TagDefinitionData definition))
|
||||
!TagDefinitionRegistry.TryGetDefinition(TagType.Inferno, out TagDefinition definition))
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ namespace GeometryTD.Definition
|
||||
private static float GetInfernoBonusDamagePerSecond(int infernoStack)
|
||||
{
|
||||
if (infernoStack <= 0 ||
|
||||
!TagConfigRegistry.TryGetDefinition(TagType.Inferno, out TagDefinitionData definition))
|
||||
!TagDefinitionRegistry.TryGetDefinition(TagType.Inferno, out TagDefinition definition))
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
+3
-3
@@ -14,7 +14,7 @@ namespace GeometryTD.Definition
|
||||
_ = attackPayload;
|
||||
Debug.Assert(runtimeData != null);
|
||||
Debug.Assert(runtimeData.TotalStack > 0);
|
||||
Debug.Assert(TagConfigRegistry.TryGetDefinition(TagType, out TagDefinitionData definition));
|
||||
Debug.Assert(TagDefinitionRegistry.TryGetDefinition(TagType, out TagDefinition definition));
|
||||
|
||||
IceTagConfig config = definition.Config as IceTagConfig;
|
||||
Debug.Assert(config != null);
|
||||
@@ -53,7 +53,7 @@ namespace GeometryTD.Definition
|
||||
private static float GetAbsoluteZeroBonusDuration(int absoluteZeroStack)
|
||||
{
|
||||
if (absoluteZeroStack <= 0 ||
|
||||
!TagConfigRegistry.TryGetDefinition(TagType.AbsoluteZero, out TagDefinitionData definition))
|
||||
!TagDefinitionRegistry.TryGetDefinition(TagType.AbsoluteZero, out TagDefinition definition))
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace GeometryTD.Definition
|
||||
private static float GetAbsoluteZeroBonusSlowRatio(int absoluteZeroStack)
|
||||
{
|
||||
if (absoluteZeroStack <= 0 ||
|
||||
!TagConfigRegistry.TryGetDefinition(TagType.AbsoluteZero, out TagDefinitionData definition))
|
||||
!TagDefinitionRegistry.TryGetDefinition(TagType.AbsoluteZero, out TagDefinition definition))
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
+1
-1
@@ -45,7 +45,7 @@ namespace GeometryTD.Definition
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!TagConfigRegistry.TryGetDefinition(tag.TagType, out TagDefinitionData definition) ||
|
||||
if (!TagDefinitionRegistry.TryGetDefinition(tag.TagType, out TagDefinition definition) ||
|
||||
definition == null ||
|
||||
definition.Category != TagCategory.Status ||
|
||||
definition.TriggerPhase != TagTriggerPhase.OnAfterHit ||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1909b51822cc4368bc604674fd119123
|
||||
timeCreated: 1773105715
|
||||
@@ -1,9 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public sealed class AbsoluteZeroTagEffect : EnemyStatusTagEffectBase
|
||||
{
|
||||
public override TagType TagType => TagType.AbsoluteZero;
|
||||
}
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: deecaa9a38c04725b5abeb5488cbe53f
|
||||
timeCreated: 1773106137
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public sealed class InfernoTagEffect : EnemyStatusTagEffectBase
|
||||
{
|
||||
public override TagType TagType => TagType.Inferno;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2aa813ec42ea4dddb717ff28da764f15
|
||||
timeCreated: 1773106082
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44a85dd6308e175428074070c55e1020
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+18
-18
@@ -5,7 +5,7 @@ using Random = System.Random;
|
||||
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public static class InventoryTagRuleService
|
||||
public static class ComponentTagGenerationService
|
||||
{
|
||||
public static TagType[] ResolveComponentTags(
|
||||
IReadOnlyList<TagType> possibleTags,
|
||||
@@ -13,10 +13,10 @@ namespace GeometryTD.Definition
|
||||
InventoryTagSourceType sourceType,
|
||||
long itemInstanceId,
|
||||
int configId,
|
||||
IReadOnlyDictionary<TagType, TagGenerationRuleData> rulesByTag = null,
|
||||
IReadOnlyDictionary<RarityType, RarityTagBudgetRuleData> rarityTagBudgetRulesByRarity = null)
|
||||
IReadOnlyDictionary<TagType, TagGenerationRule> rulesByTag = null,
|
||||
IReadOnlyDictionary<RarityType, RarityTagBudgetRule> rarityTagBudgetRulesByRarity = null)
|
||||
{
|
||||
IReadOnlyDictionary<TagType, TagGenerationRuleData> ruleLookup = rulesByTag ?? TagGenerationRuleRegistry.Rules;
|
||||
IReadOnlyDictionary<TagType, TagGenerationRule> ruleLookup = rulesByTag ?? TagGenerationRuleRegistry.Rules;
|
||||
TagType[] eligibleTags = GetEligibleTags(possibleTags, rarity, ruleLookup);
|
||||
if (eligibleTags.Length <= 0)
|
||||
{
|
||||
@@ -46,7 +46,7 @@ namespace GeometryTD.Definition
|
||||
public static TagType[] GetEligibleTags(
|
||||
IReadOnlyList<TagType> possibleTags,
|
||||
RarityType rarity,
|
||||
IReadOnlyDictionary<TagType, TagGenerationRuleData> rulesByTag = null)
|
||||
IReadOnlyDictionary<TagType, TagGenerationRule> rulesByTag = null)
|
||||
{
|
||||
if (possibleTags == null || possibleTags.Count <= 0)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ namespace GeometryTD.Definition
|
||||
}
|
||||
|
||||
RarityType normalizedRarity = InventoryRarityRuleService.NormalizeComponentRarity(rarity);
|
||||
IReadOnlyDictionary<TagType, TagGenerationRuleData> ruleLookup = rulesByTag ?? TagGenerationRuleRegistry.Rules;
|
||||
IReadOnlyDictionary<TagType, TagGenerationRule> ruleLookup = rulesByTag ?? TagGenerationRuleRegistry.Rules;
|
||||
HashSet<TagType> uniqueTags = new HashSet<TagType>();
|
||||
|
||||
for (int i = 0; i < possibleTags.Count; i++)
|
||||
@@ -65,7 +65,7 @@ namespace GeometryTD.Definition
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!TryGetRule(tagType, ruleLookup, out TagGenerationRuleData rule))
|
||||
if (!TryGetRule(tagType, ruleLookup, out TagGenerationRule rule))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -92,11 +92,11 @@ namespace GeometryTD.Definition
|
||||
public static int ResolveRarityTagBudget(
|
||||
RarityType rarity,
|
||||
Random random,
|
||||
IReadOnlyDictionary<RarityType, RarityTagBudgetRuleData> rarityTagBudgetRulesByRarity = null)
|
||||
IReadOnlyDictionary<RarityType, RarityTagBudgetRule> rarityTagBudgetRulesByRarity = null)
|
||||
{
|
||||
RarityType normalizedRarity = InventoryRarityRuleService.NormalizeComponentRarity(rarity);
|
||||
IReadOnlyDictionary<RarityType, RarityTagBudgetRuleData> ruleLookup = rarityTagBudgetRulesByRarity ?? RarityTagBudgetRuleRegistry.Rules;
|
||||
RarityTagBudgetRuleData rule = GetRarityTagBudgetRule(normalizedRarity, ruleLookup);
|
||||
IReadOnlyDictionary<RarityType, RarityTagBudgetRule> ruleLookup = rarityTagBudgetRulesByRarity ?? RarityTagBudgetRuleRegistry.Rules;
|
||||
RarityTagBudgetRule rule = GetRarityTagBudgetRule(normalizedRarity, ruleLookup);
|
||||
|
||||
Debug.Assert(rule.MinCount >= 0);
|
||||
Debug.Assert(rule.MaxCount >= rule.MinCount);
|
||||
@@ -112,15 +112,15 @@ namespace GeometryTD.Definition
|
||||
|
||||
private static bool IsSupportedLaunchTag(TagType tagType)
|
||||
{
|
||||
return TagConfigRegistry.TryGetDefinition(tagType, out TagDefinitionData definition) &&
|
||||
return TagDefinitionRegistry.TryGetDefinition(tagType, out TagDefinition definition) &&
|
||||
definition.Config != null &&
|
||||
definition.Config.IsImplemented;
|
||||
}
|
||||
|
||||
private static bool TryGetRule(
|
||||
TagType tagType,
|
||||
IReadOnlyDictionary<TagType, TagGenerationRuleData> ruleLookup,
|
||||
out TagGenerationRuleData rule)
|
||||
IReadOnlyDictionary<TagType, TagGenerationRule> ruleLookup,
|
||||
out TagGenerationRule rule)
|
||||
{
|
||||
if (ruleLookup != null && ruleLookup.TryGetValue(tagType, out rule))
|
||||
{
|
||||
@@ -131,9 +131,9 @@ namespace GeometryTD.Definition
|
||||
return false;
|
||||
}
|
||||
|
||||
private static RarityTagBudgetRuleData GetRarityTagBudgetRule(
|
||||
private static RarityTagBudgetRule GetRarityTagBudgetRule(
|
||||
RarityType rarity,
|
||||
IReadOnlyDictionary<RarityType, RarityTagBudgetRuleData> ruleLookup)
|
||||
IReadOnlyDictionary<RarityType, RarityTagBudgetRule> ruleLookup)
|
||||
{
|
||||
Debug.Assert(ruleLookup != null);
|
||||
Debug.Assert(ruleLookup.TryGetValue(rarity, out _));
|
||||
@@ -142,13 +142,13 @@ namespace GeometryTD.Definition
|
||||
|
||||
private static int RollWeightedIndex(
|
||||
IReadOnlyList<TagType> pool,
|
||||
IReadOnlyDictionary<TagType, TagGenerationRuleData> ruleLookup,
|
||||
IReadOnlyDictionary<TagType, TagGenerationRule> ruleLookup,
|
||||
Random random)
|
||||
{
|
||||
int totalWeight = 0;
|
||||
for (int i = 0; i < pool.Count; i++)
|
||||
{
|
||||
TagGenerationRuleData rule = ruleLookup[pool[i]];
|
||||
TagGenerationRule rule = ruleLookup[pool[i]];
|
||||
Debug.Assert(rule.Weight > 0);
|
||||
totalWeight += rule.Weight;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ namespace GeometryTD.Definition
|
||||
int cumulative = 0;
|
||||
for (int i = 0; i < pool.Count; i++)
|
||||
{
|
||||
TagGenerationRuleData rule = ruleLookup[pool[i]];
|
||||
TagGenerationRule rule = ruleLookup[pool[i]];
|
||||
cumulative += rule.Weight;
|
||||
if (roll <= cumulative)
|
||||
{
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public sealed class RarityTagBudgetRuleData
|
||||
public sealed class RarityTagBudgetRule
|
||||
{
|
||||
public RarityType Rarity { get; set; }
|
||||
public int MinCount { get; set; }
|
||||
+8
-8
@@ -6,14 +6,14 @@ namespace GeometryTD.Definition
|
||||
{
|
||||
public static class RarityTagBudgetRuleRegistry
|
||||
{
|
||||
private static readonly Dictionary<RarityType, RarityTagBudgetRuleData> RulesByRarity = CreateDefaultRules();
|
||||
private static readonly Dictionary<RarityType, RarityTagBudgetRule> RulesByRarity = CreateDefaultRules();
|
||||
|
||||
public static IReadOnlyDictionary<RarityType, RarityTagBudgetRuleData> Rules => RulesByRarity;
|
||||
public static IReadOnlyDictionary<RarityType, RarityTagBudgetRule> Rules => RulesByRarity;
|
||||
|
||||
public static void ResetToDefaults()
|
||||
{
|
||||
RulesByRarity.Clear();
|
||||
foreach (KeyValuePair<RarityType, RarityTagBudgetRuleData> pair in CreateDefaultRules())
|
||||
foreach (KeyValuePair<RarityType, RarityTagBudgetRule> pair in CreateDefaultRules())
|
||||
{
|
||||
RulesByRarity.Add(pair.Key, pair.Value);
|
||||
}
|
||||
@@ -28,14 +28,14 @@ namespace GeometryTD.Definition
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetRule(RarityType rarity, out RarityTagBudgetRuleData rule)
|
||||
public static bool TryGetRule(RarityType rarity, out RarityTagBudgetRule rule)
|
||||
{
|
||||
return RulesByRarity.TryGetValue(rarity, out rule);
|
||||
}
|
||||
|
||||
private static Dictionary<RarityType, RarityTagBudgetRuleData> CreateDefaultRules()
|
||||
private static Dictionary<RarityType, RarityTagBudgetRule> CreateDefaultRules()
|
||||
{
|
||||
return new Dictionary<RarityType, RarityTagBudgetRuleData>
|
||||
return new Dictionary<RarityType, RarityTagBudgetRule>
|
||||
{
|
||||
[RarityType.White] = CreateRule(RarityType.White, 0, 1),
|
||||
[RarityType.Green] = CreateRule(RarityType.Green, 1, 1),
|
||||
@@ -45,13 +45,13 @@ namespace GeometryTD.Definition
|
||||
};
|
||||
}
|
||||
|
||||
private static RarityTagBudgetRuleData CreateRule(RarityType rarity, int minCount, int maxCount)
|
||||
private static RarityTagBudgetRule CreateRule(RarityType rarity, int minCount, int maxCount)
|
||||
{
|
||||
Debug.Assert(rarity >= RarityType.White && rarity <= RarityType.Red);
|
||||
Debug.Assert(minCount >= 0);
|
||||
Debug.Assert(maxCount >= minCount);
|
||||
|
||||
return new RarityTagBudgetRuleData
|
||||
return new RarityTagBudgetRule
|
||||
{
|
||||
Rarity = rarity,
|
||||
MinCount = minCount,
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public sealed class TagGenerationRuleData
|
||||
public sealed class TagGenerationRule
|
||||
{
|
||||
public TagType TagType { get; set; }
|
||||
public RarityType MinRarity { get; set; }
|
||||
+8
-8
@@ -6,14 +6,14 @@ namespace GeometryTD.Definition
|
||||
{
|
||||
public static class TagGenerationRuleRegistry
|
||||
{
|
||||
private static readonly Dictionary<TagType, TagGenerationRuleData> RulesByTag = CreateDefaultRules();
|
||||
private static readonly Dictionary<TagType, TagGenerationRule> RulesByTag = CreateDefaultRules();
|
||||
|
||||
public static IReadOnlyDictionary<TagType, TagGenerationRuleData> Rules => RulesByTag;
|
||||
public static IReadOnlyDictionary<TagType, TagGenerationRule> Rules => RulesByTag;
|
||||
|
||||
public static void ResetToDefaults()
|
||||
{
|
||||
RulesByTag.Clear();
|
||||
foreach (KeyValuePair<TagType, TagGenerationRuleData> pair in CreateDefaultRules())
|
||||
foreach (KeyValuePair<TagType, TagGenerationRule> pair in CreateDefaultRules())
|
||||
{
|
||||
RulesByTag.Add(pair.Key, pair.Value);
|
||||
}
|
||||
@@ -28,14 +28,14 @@ namespace GeometryTD.Definition
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetRule(TagType tagType, out TagGenerationRuleData rule)
|
||||
public static bool TryGetRule(TagType tagType, out TagGenerationRule rule)
|
||||
{
|
||||
return RulesByTag.TryGetValue(tagType, out rule);
|
||||
}
|
||||
|
||||
private static Dictionary<TagType, TagGenerationRuleData> CreateDefaultRules()
|
||||
private static Dictionary<TagType, TagGenerationRule> CreateDefaultRules()
|
||||
{
|
||||
return new Dictionary<TagType, TagGenerationRuleData>
|
||||
return new Dictionary<TagType, TagGenerationRule>
|
||||
{
|
||||
[TagType.Fire] = CreateRule(TagType.Fire, RarityType.White, 20),
|
||||
[TagType.BurnSpread] = CreateRule(TagType.BurnSpread, RarityType.White, 20),
|
||||
@@ -52,9 +52,9 @@ namespace GeometryTD.Definition
|
||||
};
|
||||
}
|
||||
|
||||
private static TagGenerationRuleData CreateRule(TagType tagType, RarityType minRarity, int weight)
|
||||
private static TagGenerationRule CreateRule(TagType tagType, RarityType minRarity, int weight)
|
||||
{
|
||||
return new TagGenerationRuleData
|
||||
return new TagGenerationRule
|
||||
{
|
||||
TagType = tagType,
|
||||
MinRarity = minRarity,
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6251ee2cac123b43899d056ed4ad544
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6219bd01b665fd4cae6580656c1f127
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-1
@@ -3,7 +3,7 @@ using System;
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class TagDefinitionData
|
||||
public sealed class TagDefinition
|
||||
{
|
||||
public TagType TagType { get; set; }
|
||||
public TagCategory Category { get; set; }
|
||||
+35
-12
@@ -5,16 +5,16 @@ using UnityEngine;
|
||||
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public static class TagConfigRegistry
|
||||
public static class TagDefinitionRegistry
|
||||
{
|
||||
private static readonly Dictionary<TagType, TagDefinitionData> DefinitionsByTag = CreateDefaultDefinitions();
|
||||
private static readonly Dictionary<TagType, TagDefinition> DefinitionsByTag = CreateDefaultDefinitions();
|
||||
|
||||
public static IReadOnlyDictionary<TagType, TagDefinitionData> Definitions => DefinitionsByTag;
|
||||
public static IReadOnlyDictionary<TagType, TagDefinition> Definitions => DefinitionsByTag;
|
||||
|
||||
public static void ResetToDefaults()
|
||||
{
|
||||
DefinitionsByTag.Clear();
|
||||
foreach (KeyValuePair<TagType, TagDefinitionData> pair in CreateDefaultDefinitions())
|
||||
foreach (KeyValuePair<TagType, TagDefinition> pair in CreateDefaultDefinitions())
|
||||
{
|
||||
DefinitionsByTag.Add(pair.Key, pair.Value);
|
||||
}
|
||||
@@ -29,23 +29,36 @@ namespace GeometryTD.Definition
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetDefinition(TagType tagType, out TagDefinitionData definition)
|
||||
public static bool TryGetDefinition(TagType tagType, out TagDefinition definition)
|
||||
{
|
||||
return DefinitionsByTag.TryGetValue(tagType, out definition);
|
||||
}
|
||||
|
||||
private static Dictionary<TagType, TagDefinitionData> CreateDefaultDefinitions()
|
||||
public static void ApplyTagRows(IEnumerable<DRTag> rows)
|
||||
{
|
||||
return new Dictionary<TagType, TagDefinitionData>
|
||||
if (rows == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (DRTag row in rows)
|
||||
{
|
||||
ApplyTagRow(row);
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<TagType, TagDefinition> CreateDefaultDefinitions()
|
||||
{
|
||||
return new Dictionary<TagType, TagDefinition>
|
||||
{
|
||||
[TagType.Fire] = CreateDefinition(TagType.Fire, TagCategory.Status, TagTriggerPhase.OnAfterHit, new FireTagConfig(true)),
|
||||
[TagType.BurnSpread] = CreateDefinition(TagType.BurnSpread, TagCategory.AttackShape, TagTriggerPhase.OnKill, new BurnSpreadTagConfig(false)),
|
||||
[TagType.IgniteBurst] = CreateDefinition(TagType.IgniteBurst, TagCategory.AttackShape, TagTriggerPhase.OnKill, new IgniteBurstTagConfig(false)),
|
||||
[TagType.Inferno] = CreateDefinition(TagType.Inferno, TagCategory.Status, TagTriggerPhase.OnAfterHit, new InfernoTagConfig(true)),
|
||||
[TagType.Inferno] = CreateDefinition(TagType.Inferno, TagCategory.StatusModifier, TagTriggerPhase.OnAfterHit, new InfernoTagConfig(true)),
|
||||
[TagType.Ice] = CreateDefinition(TagType.Ice, TagCategory.Status, TagTriggerPhase.OnAfterHit, new IceTagConfig(true)),
|
||||
[TagType.FreezeMask] = CreateDefinition(TagType.FreezeMask, TagCategory.AttackShape, TagTriggerPhase.OnAfterHit, new FreezeMaskTagConfig(false)),
|
||||
[TagType.Shatter] = CreateDefinition(TagType.Shatter, TagCategory.NumericModifier, TagTriggerPhase.OnBeforeHit, new ShatterTagConfig(true)),
|
||||
[TagType.AbsoluteZero] = CreateDefinition(TagType.AbsoluteZero, TagCategory.Status, TagTriggerPhase.OnAfterHit, new AbsoluteZeroTagConfig(true)),
|
||||
[TagType.AbsoluteZero] = CreateDefinition(TagType.AbsoluteZero, TagCategory.StatusModifier, TagTriggerPhase.OnAfterHit, new AbsoluteZeroTagConfig(true)),
|
||||
[TagType.Pierce] = CreateDefinition(TagType.Pierce, TagCategory.AttackShape, TagTriggerPhase.OnHit, new PierceTagConfig(false)),
|
||||
[TagType.Crit] = CreateDefinition(TagType.Crit, TagCategory.NumericModifier, TagTriggerPhase.OnBeforeHit, new CritTagConfig(true)),
|
||||
[TagType.Overpenetrate] = CreateDefinition(TagType.Overpenetrate, TagCategory.AttackShape, TagTriggerPhase.OnHit, new OverpenetrateTagConfig(false)),
|
||||
@@ -53,13 +66,13 @@ namespace GeometryTD.Definition
|
||||
};
|
||||
}
|
||||
|
||||
private static TagDefinitionData CreateDefinition(
|
||||
private static TagDefinition CreateDefinition(
|
||||
TagType tagType,
|
||||
TagCategory category,
|
||||
TagTriggerPhase triggerPhase,
|
||||
TagConfigBase config)
|
||||
{
|
||||
return new TagDefinitionData
|
||||
return new TagDefinition
|
||||
{
|
||||
TagType = tagType,
|
||||
Category = category,
|
||||
@@ -72,7 +85,7 @@ namespace GeometryTD.Definition
|
||||
private static void ApplyRow(DRTagConfig row)
|
||||
{
|
||||
Debug.Assert(row != null);
|
||||
Debug.Assert(DefinitionsByTag.TryGetValue(row.TagType, out TagDefinitionData definition));
|
||||
Debug.Assert(DefinitionsByTag.TryGetValue(row.TagType, out TagDefinition definition));
|
||||
|
||||
definition.TriggerPhase = row.TriggerPhase;
|
||||
definition.Description = row.Description ?? string.Empty;
|
||||
@@ -109,6 +122,16 @@ namespace GeometryTD.Definition
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyTagRow(DRTag row)
|
||||
{
|
||||
Debug.Assert(row != null);
|
||||
Debug.Assert(row.Id > 0);
|
||||
Debug.Assert(DefinitionsByTag.TryGetValue(row.TagType, out TagDefinition definition));
|
||||
Debug.Assert(definition.Config != null);
|
||||
|
||||
definition.Config.IsImplemented = row.IsImplemented;
|
||||
}
|
||||
|
||||
private static void ApplyFireConfig(FireTagConfig config, JObject param)
|
||||
{
|
||||
config.BurnDurationSeconds = ReadFloat(param, nameof(FireTagConfig.BurnDurationSeconds), config.BurnDurationSeconds);
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f3ef8704ccb98147a21c03330278743
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Definition;
|
||||
|
||||
namespace GeometryTD.CustomUtility
|
||||
{
|
||||
public static class TagDisplayUtility
|
||||
{
|
||||
public static string ResolveTagName(TagType tagType)
|
||||
{
|
||||
if (tagType == TagType.None)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (GameEntry.DataTable != null)
|
||||
{
|
||||
var tagTable = GameEntry.DataTable.GetDataTable<DRTag>();
|
||||
if (tagTable != null)
|
||||
{
|
||||
DRTag tagRow = tagTable.GetDataRow((int)tagType);
|
||||
if (tagRow != null && !string.IsNullOrWhiteSpace(tagRow.Name))
|
||||
{
|
||||
return tagRow.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tagType.ToString();
|
||||
}
|
||||
|
||||
public static string[] BuildTagTexts(IReadOnlyList<TagType> tags)
|
||||
{
|
||||
if (tags == null || tags.Count <= 0)
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
|
||||
List<string> results = new List<string>(tags.Count);
|
||||
for (int i = 0; i < tags.Count; i++)
|
||||
{
|
||||
string tagName = ResolveTagName(tags[i]);
|
||||
if (!string.IsNullOrWhiteSpace(tagName))
|
||||
{
|
||||
results.Add(tagName);
|
||||
}
|
||||
}
|
||||
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
public static string[] BuildTagTexts(IReadOnlyList<TagRuntimeData> tagRuntimes)
|
||||
{
|
||||
if (tagRuntimes == null || tagRuntimes.Count <= 0)
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
|
||||
List<string> results = new List<string>(tagRuntimes.Count);
|
||||
for (int i = 0; i < tagRuntimes.Count; i++)
|
||||
{
|
||||
TagRuntimeData tagRuntime = tagRuntimes[i];
|
||||
if (tagRuntime == null || tagRuntime.TagType == TagType.None || tagRuntime.TotalStack <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string tagName = ResolveTagName(tagRuntime.TagType);
|
||||
if (string.IsNullOrWhiteSpace(tagName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
results.Add(tagRuntime.TotalStack > 1 ? $"{tagName} x{tagRuntime.TotalStack}" : tagName);
|
||||
}
|
||||
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
public static string[] BuildTowerTagTexts(TowerStatsData towerStats)
|
||||
{
|
||||
if (towerStats == null)
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
|
||||
if (towerStats.TagRuntimes != null && towerStats.TagRuntimes.Length > 0)
|
||||
{
|
||||
return BuildTagTexts(towerStats.TagRuntimes);
|
||||
}
|
||||
|
||||
return BuildTagTexts(towerStats.Tags);
|
||||
}
|
||||
|
||||
public static string BuildTagDescriptionText(IReadOnlyList<TagType> tags)
|
||||
{
|
||||
if (tags == null || tags.Count <= 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
List<string> results = new List<string>(tags.Count);
|
||||
for (int i = 0; i < tags.Count; i++)
|
||||
{
|
||||
TagType tagType = tags[i];
|
||||
if (tagType == TagType.None)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string tagName = ResolveTagName(tagType);
|
||||
string tagDescription = ResolveTagDescription(tagType);
|
||||
if (string.IsNullOrWhiteSpace(tagDescription))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
results.Add(string.IsNullOrWhiteSpace(tagName) ? tagDescription : $"{tagName}: {tagDescription}");
|
||||
}
|
||||
|
||||
return string.Join("\n", results);
|
||||
}
|
||||
|
||||
public static string BuildTagDescriptionText(IReadOnlyList<TagRuntimeData> tagRuntimes)
|
||||
{
|
||||
if (tagRuntimes == null || tagRuntimes.Count <= 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
List<string> results = new List<string>(tagRuntimes.Count);
|
||||
for (int i = 0; i < tagRuntimes.Count; i++)
|
||||
{
|
||||
TagRuntimeData runtime = tagRuntimes[i];
|
||||
if (runtime == null || runtime.TagType == TagType.None || runtime.TotalStack <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string tagName = ResolveTagName(runtime.TagType);
|
||||
if (runtime.TotalStack > 1 && !string.IsNullOrWhiteSpace(tagName))
|
||||
{
|
||||
tagName = $"{tagName} x{runtime.TotalStack}";
|
||||
}
|
||||
|
||||
string tagDescription = ResolveTagDescription(runtime.TagType);
|
||||
if (string.IsNullOrWhiteSpace(tagDescription))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
results.Add(string.IsNullOrWhiteSpace(tagName) ? tagDescription : $"{tagName}: {tagDescription}");
|
||||
}
|
||||
|
||||
return string.Join("\n", results);
|
||||
}
|
||||
|
||||
public static string ResolveTagDescription(TagType tagType)
|
||||
{
|
||||
if (tagType == TagType.None)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (TagDefinitionRegistry.TryGetDefinition(tagType, out TagDefinition definition) &&
|
||||
!string.IsNullOrWhiteSpace(definition.Description))
|
||||
{
|
||||
return definition.Description;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93b93ce08ff34afea2cdf0cfe8f417f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c90264b23a9c45c0b21bc627a6109282
|
||||
timeCreated: 1773105821
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fb08c76711246c2afa02d60769d76ef
|
||||
timeCreated: 1773106291
|
||||
Reference in New Issue
Block a user