Skip to content

Instantly share code, notes, and snippets.

@Narazaka
Last active September 5, 2015 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Narazaka/05e2735316cb04ebee47 to your computer and use it in GitHub Desktop.
Save Narazaka/05e2735316cb04ebee47 to your computer and use it in GitHub Desktop.
public enum SkillEffectType {
ChangeCharacterHP,
ChangeAllEnemyHP,
//...
}
public partial class SkillEffect {
private static Dictionary<SkillEffectType, Type> skill_types = new Dictionary<SkillEffectType, Type> {
{ SkillEffectType.ChangeCharacterHP, typeof(SkillEffect.ChangeCharacterHP) },
{ SkillEffectType.ChangeAllEnemyHP, typeof(SkillEffect.ChangeAllEnemyHP) },
};
public static SkillEffect build(SkillEffectType type, Dictionary<string, object> skilleffect) {
return (SkillEffect)Activator.CreateInstance(SkillEffect.skill_types[type], new object[] { skilleffect });
}
}
public enum SkillEffectType {
ChangeCharacterHP,
ChangeAllEnemyHP,
//...
}
public partial class SkillEffect {
public static SkillEffect build(SkillEffectType type, Dictionary<string, object> skilleffect) {
switch (type) {
case SkillEffectType.ChangeCharacterHP: return new SkillEffect.ChangeCharacterHP(skilleffect);
case SkillEffectType.ChangeAllEnemyHP: return new SkillEffect.ChangeAllEnemyHP(skilleffect);
//...
default: throw new InvalidOperationException("unknown skill type");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment