TH1/Unity/Assets/Scripts/TH1_Logic/HeroTask/HeroTaskFactory.cs
2026-06-05 19:59:32 +08:00

66 lines
2.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Reflection;
using Logic.Skill;
namespace TH1_Logic.HeroTask
{
public class HeroTaskFactory
{
private static Dictionary<HeroTaskContentType, Type> _contentDict;
public static HeroTaskContentBase GetHeroTaskContentBase(HeroTaskContentType contentType)
{
if (_contentDict == null)
{
_contentDict = new Dictionary<HeroTaskContentType, Type>();
Assembly assembly = typeof(HeroTaskContentBase).Assembly; // 获取基类所在程序集
foreach (Type classType in assembly.GetTypes())
{
if (classType.IsSubclassOf(typeof(HeroTaskContentBase)) && !classType.IsAbstract)
{
var obj = Activator.CreateInstance(classType);
var contentBase = obj as HeroTaskContentBase;
if (contentBase == null) continue;
_contentDict[contentBase.GetContentType()] = classType;
}
}
}
if (_contentDict.TryGetValue(contentType, out var contentClass))
{
return Activator.CreateInstance(contentClass) as HeroTaskContentBase;
}
return null;
}
public static string GetHeroTaskContentName(HeroTaskContentType contentType)
{
if (contentType == HeroTaskContentType.AccumulateDamageTaken)
return "累计承受伤害";
if (contentType == HeroTaskContentType.AccumulateDamageDealt)
return "累计造成伤害";
if (contentType == HeroTaskContentType.AccumulateDamageTakenAndDealt)
return "累计承受伤害和造成伤害";
if (contentType == HeroTaskContentType.AccumulateKills)
return "累计杀人";
if (contentType == HeroTaskContentType.AccumulateHealing)
return "累计产生(自身或他人)治疗";
if (contentType == HeroTaskContentType.AccumulateRelicsOpened)
return "累计开启遗迹";
if (contentType == HeroTaskContentType.AccumulateAreasExplored)
return "累计探索新地块";
if (contentType == HeroTaskContentType.AccumulateCitiesCaptured)
return "累计占领新城市";
if (contentType == HeroTaskContentType.AddSkillStacks)
return "单位X 给任何单位增加N次技能A的层数X的该计数+N";
if (contentType == HeroTaskContentType.SkillActivation)
return "单位X 的技能A 生效时(接口,技能自定义),则该计数变化(技能自定义)";
return "";
}
}
}