G1-01 + G1-02

This commit is contained in:
SepComet
2026-03-12 13:20:02 +08:00
parent 1c45205e92
commit 99ed963faa
24 changed files with 424 additions and 32 deletions
@@ -1,76 +0,0 @@
using GeometryTD.CustomUtility;
using Newtonsoft.Json.Linq;
using UnityGameFramework.Runtime;
namespace GeometryTD.Definition
{
public static class EventEffectFactory
{
public static EventEffectBase Create(string rawType, JObject param, float? probability = null)
{
if (string.IsNullOrWhiteSpace(rawType))
{
return null;
}
EventEffectType type = EnumUtility<EventEffectType>.Get(rawType);
switch (type)
{
case EventEffectType.AddGold:
{
int count = GetInt(param, "Count");
return new AddGoldEffect(new AddGoldParam(count), probability);
}
case EventEffectType.RemoveRandomComps:
{
int count = GetInt(param, "Count");
RarityType rarity = EnumUtility<RarityType>.Get(GetString(param, "Rarity"));
return new RemoveRandomCompsEffect(new RemoveRandomCompsParam(count, rarity), probability);
}
case EventEffectType.AddRandomComps:
{
int count = GetInt(param, "Count");
RarityType rarity = EnumUtility<RarityType>.Get(GetString(param, "Rarity"));
return new AddRandomCompsEffect(new AddRandomCompsParam(count, rarity), probability);
}
case EventEffectType.DamageRandomTowersEndurance:
{
int count = GetInt(param, "Count");
int amount = GetInt(param, "Amount");
return new DamageRandomTowerEnduranceEffect(new DamageRandomTowerEnduranceParam(count, amount), probability);
}
default:
Log.Warning("Unsupported EventEffectType '{0}'.", rawType);
return null;
}
}
private static int GetInt(JObject param, params string[] keys)
{
if (param == null)
{
return 0;
}
foreach (string key in keys)
{
if (param.TryGetValue(key, out JToken token) && token.Type != JTokenType.Null)
{
return token.Value<int>();
}
}
return 0;
}
private static string GetString(JObject param, string key)
{
if (param == null || !param.TryGetValue(key, out JToken token) || token.Type == JTokenType.Null)
{
return string.Empty;
}
return token.Value<string>();
}
}
}
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: fae04d7a401d4c7fbe2de385c3f23580
timeCreated: 1772102401
@@ -1,74 +0,0 @@
using GeometryTD.CustomUtility;
using Newtonsoft.Json.Linq;
using UnityGameFramework.Runtime;
namespace GeometryTD.Definition
{
public static class EventRequirementFactory
{
public static EventRequirementBase Create(string rawType, JObject param)
{
if (string.IsNullOrWhiteSpace(rawType))
{
return null;
}
EventRequirementType type = EnumUtility<EventRequirementType>.Get(rawType);
switch (type)
{
case EventRequirementType.GoldAtLeast:
{
int count = GetInt(param, "Count", "Gold");
return new GoldAtLeastRequirement(new GoldAtLeastParam(count));
}
case EventRequirementType.CompCountAtLeast:
{
int count = GetInt(param, "Count");
RarityType rarity = EnumUtility<RarityType>.Get(GetString(param, "Rarity"));
return new CompCountAtLeastRequirement(new CompCountAtLeastParam(count, rarity));
}
case EventRequirementType.TowerCountAtLeast:
{
int count = GetInt(param, "Count");
return new TowerCountAtLeastRequirement(new TowerCountAtLeastParam(count));
}
case EventRequirementType.HasRelic:
{
int relicId = GetInt(param, "RelicId", "Id");
return new HasRelicRequirement(new HasRelicParam(relicId));
}
default:
Log.Warning("Unsupported EventRequirementType '{0}'.", rawType);
return null;
}
}
private static int GetInt(JObject param, params string[] keys)
{
if (param == null)
{
return 0;
}
foreach (string key in keys)
{
if (param.TryGetValue(key, out JToken token) && token.Type != JTokenType.Null)
{
return token.Value<int>();
}
}
return 0;
}
private static string GetString(JObject param, string key)
{
if (param == null || !param.TryGetValue(key, out JToken token) || token.Type == JTokenType.Null)
{
return string.Empty;
}
return token.Value<string>();
}
}
}
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: e3b92d366cac404394c9e6aa1aa4062b
timeCreated: 1772102400