public static void InitSkills(this SkillComponent self) { DUnit role = self.GetParent <DUnit>(); UnitTypeComponent typeComponent = role.GetComponent <UnitTypeComponent>(); JsonData parameter = null; if (typeComponent.UnitType == UnitType.UnitRole) { parameter = JsonMapper.ToObject(role.GetComponent <URoleConfigComponent>().RoleConfig.Skills); } else if (typeComponent.UnitType == UnitType.UnitTower) { parameter = JsonMapper.ToObject(role.GetComponent <UTowerConfigComponent>().TowerConfig.Skills); } else if (typeComponent.UnitType == UnitType.UnitTrap) { parameter = JsonMapper.ToObject(role.GetComponent <UTrapConfigComponent>().TrapConfig.Skills); } else { parameter = JsonMapper.ToObject(role.GetComponent <UShellConfigComponent>().ShellConfig.Skills); } JsonData skills = parameter["skills"]; if (skills != null) { for (int i = 0; i < skills.Count; i++) { int skillid = (int)skills[i]; self.AddSkill(skillid); } } }
public static void OnSkillEnd(this SkillComponent self, Skill skill) { if (self.Skills.List.Contains(skill)) { self.Skills.List.Remove(skill); self.EndSkills.List.Add(skill); } }
public static void SetSkillState(this Skill self, SkillState state) { self.SkillState = state; if (state == SkillState.SkillEnd) { SkillComponent component = self.GetParent <SkillComponent>(); component.OnSkillEnd(self); } }
public static void AddSkill(this SkillComponent self, int configid) { Skill skill = SkillFactory.Create(self, configid); self.Skills.List.Add(skill); }