G1-01 + G1-02
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Definition;
|
||||
|
||||
namespace GeometryTD.Factory
|
||||
{
|
||||
public static class ComponentItemFactory
|
||||
{
|
||||
public static MuzzleCompItemData CreateMuzzle(
|
||||
DRMuzzleComp config,
|
||||
long instanceId,
|
||||
RarityType rarity,
|
||||
InventoryTagRandomContext randomContext)
|
||||
{
|
||||
RarityType normalizedRarity = InventoryRarityRuleService.NormalizeComponentRarity(rarity);
|
||||
return new MuzzleCompItemData
|
||||
{
|
||||
InstanceId = instanceId,
|
||||
ConfigId = config.Id,
|
||||
Name = config.Name,
|
||||
Rarity = normalizedRarity,
|
||||
Endurance = 100f,
|
||||
Constraint = config.Constraint,
|
||||
Tags = ComponentTagGenerationService.ResolveComponentTags(
|
||||
config.PossibleTag,
|
||||
normalizedRarity,
|
||||
randomContext),
|
||||
AttackDamage = config.AttackDamage != null ? (int[])config.AttackDamage.Clone() : Array.Empty<int>(),
|
||||
DamageRandomRate = config.DamageRandomRate,
|
||||
AttackMethodType = config.AttackMethodType
|
||||
};
|
||||
}
|
||||
|
||||
public static BearingCompItemData CreateBearing(
|
||||
DRBearingComp config,
|
||||
long instanceId,
|
||||
RarityType rarity,
|
||||
InventoryTagRandomContext randomContext)
|
||||
{
|
||||
RarityType normalizedRarity = InventoryRarityRuleService.NormalizeComponentRarity(rarity);
|
||||
return new BearingCompItemData
|
||||
{
|
||||
InstanceId = instanceId,
|
||||
ConfigId = config.Id,
|
||||
Name = config.Name,
|
||||
Rarity = normalizedRarity,
|
||||
Endurance = 100f,
|
||||
Constraint = config.Constraint,
|
||||
Tags = ComponentTagGenerationService.ResolveComponentTags(
|
||||
config.PossibleTag,
|
||||
normalizedRarity,
|
||||
randomContext),
|
||||
RotateSpeed = config.RotateSpeed != null ? (float[])config.RotateSpeed.Clone() : Array.Empty<float>(),
|
||||
AttackRange = config.AttackRange != null ? (float[])config.AttackRange.Clone() : Array.Empty<float>()
|
||||
};
|
||||
}
|
||||
|
||||
public static BaseCompItemData CreateBase(
|
||||
DRBaseComp config,
|
||||
long instanceId,
|
||||
RarityType rarity,
|
||||
InventoryTagRandomContext randomContext)
|
||||
{
|
||||
RarityType normalizedRarity = InventoryRarityRuleService.NormalizeComponentRarity(rarity);
|
||||
return new BaseCompItemData
|
||||
{
|
||||
InstanceId = instanceId,
|
||||
ConfigId = config.Id,
|
||||
Name = config.Name,
|
||||
Rarity = normalizedRarity,
|
||||
Endurance = 100f,
|
||||
Constraint = config.Constraint,
|
||||
Tags = ComponentTagGenerationService.ResolveComponentTags(
|
||||
config.PossibleTag,
|
||||
normalizedRarity,
|
||||
randomContext),
|
||||
AttackSpeed = config.AttackSpeed != null ? (float[])config.AttackSpeed.Clone() : Array.Empty<float>(),
|
||||
AttackPropertyType = config.AttackPropertyType
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf4dd23294965e945bdda9496e0278e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,77 @@
|
||||
using GeometryTD.CustomUtility;
|
||||
using GeometryTD.Definition;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.Factory
|
||||
{
|
||||
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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fae04d7a401d4c7fbe2de385c3f23580
|
||||
timeCreated: 1772102401
|
||||
@@ -0,0 +1,75 @@
|
||||
using GeometryTD.CustomUtility;
|
||||
using GeometryTD.Definition;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.Factory
|
||||
{
|
||||
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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3b92d366cac404394c9e6aa1aa4062b
|
||||
timeCreated: 1772102400
|
||||
@@ -0,0 +1,25 @@
|
||||
using GeometryTD.CustomComponent;
|
||||
using GeometryTD.Definition;
|
||||
|
||||
namespace GeometryTD.Factory
|
||||
{
|
||||
internal static class PhaseEndConditionFactory
|
||||
{
|
||||
private static readonly IPhaseEndCondition None = new NonePhaseEndCondition();
|
||||
private static readonly IPhaseEndCondition TimeElapsed = new TimeElapsedPhaseEndCondition();
|
||||
private static readonly IPhaseEndCondition EnemiesCleared = new EnemiesClearedPhaseEndCondition();
|
||||
private static readonly IPhaseEndCondition BossDead = new BossDeadPhaseEndCondition();
|
||||
|
||||
public static IPhaseEndCondition Create(PhaseEndType endType)
|
||||
{
|
||||
return endType switch
|
||||
{
|
||||
PhaseEndType.TimeElapsed => TimeElapsed,
|
||||
PhaseEndType.EnemiesCleared => EnemiesCleared,
|
||||
PhaseEndType.BossDead => BossDead,
|
||||
PhaseEndType.None => None,
|
||||
_ => None
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35a7aac328337414dbae929053176177
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,59 @@
|
||||
using System.Collections.Generic;
|
||||
using GeometryTD.Definition;
|
||||
using GeometryTD.Procedure;
|
||||
|
||||
namespace GeometryTD.Factory
|
||||
{
|
||||
public static class RunStateFactory
|
||||
{
|
||||
public static RunState CreateFixedRun(
|
||||
LevelThemeType themeType,
|
||||
BackpackInventoryData initialInventorySnapshot,
|
||||
string runId = null,
|
||||
int runSeed = 0)
|
||||
{
|
||||
IReadOnlyList<RunNodeSeed> fixedNodeSeeds = FixedRunNodeSequenceBuilder.Build(themeType);
|
||||
return Create(themeType, initialInventorySnapshot, fixedNodeSeeds, runId, runSeed);
|
||||
}
|
||||
|
||||
public static RunState Create(
|
||||
LevelThemeType themeType,
|
||||
BackpackInventoryData initialInventorySnapshot,
|
||||
IEnumerable<RunNodeSeed> nodeSeeds,
|
||||
string runId = null,
|
||||
int runSeed = 0)
|
||||
{
|
||||
List<RunNodeState> nodes = new List<RunNodeState>();
|
||||
if (nodeSeeds != null)
|
||||
{
|
||||
int sequenceIndex = 0;
|
||||
foreach (RunNodeSeed seed in nodeSeeds)
|
||||
{
|
||||
if (seed == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
nodes.Add(new RunNodeState
|
||||
{
|
||||
NodeId = seed.NodeId > 0 ? seed.NodeId : sequenceIndex + 1,
|
||||
NodeType = seed.NodeType,
|
||||
ThemeType = seed.ThemeType == LevelThemeType.None ? themeType : seed.ThemeType,
|
||||
LinkedLevelId = seed.LinkedLevelId,
|
||||
SequenceIndex = seed.SequenceIndex >= 0 ? seed.SequenceIndex : sequenceIndex,
|
||||
Status = sequenceIndex == 0 ? RunNodeStatus.Available : RunNodeStatus.Locked
|
||||
});
|
||||
sequenceIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
return new RunState(runId, runSeed, themeType, nodes, initialInventorySnapshot);
|
||||
}
|
||||
|
||||
public static int CreateRunSeed()
|
||||
{
|
||||
int seed = System.Guid.NewGuid().GetHashCode();
|
||||
return seed == 0 ? 1 : seed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b14d5010eb149678d2f4b269d6b8401
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user