You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.7 KiB
68 lines
1.7 KiB
using System.Collections.Generic; |
|
|
|
namespace ET |
|
{ |
|
[FriendClass(typeof(Skill))] |
|
public static class SkillComponentSystem |
|
{ |
|
|
|
|
|
public static Skill GetSkill(this SkillComponent self, int configId) |
|
{ |
|
foreach (var v in self.Children.Values) |
|
{ |
|
var skill = (Skill) v; |
|
if (skill.ConfigId == configId) |
|
{ |
|
return skill; |
|
} |
|
} |
|
|
|
return null; |
|
} |
|
|
|
public static bool TestReplaceSkill(this SkillComponent self, int oldConfigId, int newConfigId) |
|
{ |
|
if (oldConfigId <= 0 || newConfigId <= 0) |
|
{ |
|
return false; |
|
} |
|
|
|
var oldSkill = self.GetSkill(oldConfigId); |
|
if (oldSkill != null) |
|
{ |
|
oldSkill.Dispose(); |
|
} |
|
var skill = self.AddChild<Skill>(); |
|
skill.ConfigId = newConfigId; |
|
skill.Level = 1; |
|
|
|
return true; |
|
} |
|
|
|
public static List<Skill> GetSkillList(this SkillComponent self) |
|
{ |
|
List<Skill> skillList = new List<Skill>(); |
|
foreach (var v in self.Children.Values) |
|
{ |
|
skillList.Add((Skill)v); |
|
} |
|
|
|
return skillList; |
|
} |
|
|
|
public static void CdOneTime(this SkillComponent self, SkillFatherCDTypeEnum cdTypeEnum) |
|
{ |
|
foreach (var v in self.Children.Values) |
|
{ |
|
var skill = (Skill) v; |
|
if (skill.Config.CDType == (int)cdTypeEnum) |
|
{ |
|
skill.CdOneTime(); |
|
} |
|
|
|
} |
|
} |
|
|
|
} |
|
} |