Last active
September 5, 2015 06:03
-
-
Save Narazaka/05e2735316cb04ebee47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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