66 lines
2.8 KiB
C#
66 lines
2.8 KiB
C#
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 "";
|
||
}
|
||
}
|
||
}
|