/// <summary> /// 技能的合法性验证, 通过TrigSkill返回触发的技能 /// </summary> /// <param name="skillId"></param> /// <param name="caster">施法者</param> /// <param name="target">目标</param> /// <param name="trig">技能触发</param> /// <param name="complate">技能完成回掉</param> public void Verify(int skillId, Entity caster, Entity target, TrigSkill trig, SkillComplate complate) { //查阅技能 if (!m_Skills.ContainsKey(skillId)) { throw new KeyNotFoundException(string.Format("{0} 不在技能表")); } SkillTable skilldata = m_Skills[skillId]; //根据技能表组装技能属性 Attribute attribue = new Attribute(); attribue.CostMp = skilldata.Cost; //使用技能属性初始化技能[这里后续使用对象池获取对象,暂时直接new] Skill skill = new Skill(); skill.Init(caster, target, attribue, complate); //检查释放条件 //蓝耗检查 if (skilldata.Cost > 0) { if (!skill.IsValid(new MpVerify())) { trig(null); return; } } //to-do其他检查 trig(skill); }
IEnumerator Start() { Attribute attribute = new Attribute(); attribute.CostMp = 5; attribute.m_DelayTime = 2; SkillSystem.Skill windy = new SkillSystem.Skill(); Entity sakura = new Entity(); sakura.Name = "小樱"; sakura.Mp = 10; Entity enemy = new Entity(); windy.Init(sakura, enemy, attribute); //检验流程 bool isvalid = windy.IsValid(new MpVerify()); if (!isvalid) { windy.Interrupt(new InterruptValid()); } Debug.Log("准备 吟唱"); TaskSystem.TimeCondition cond = new TaskSystem.TimeCondition(attribute.m_DelayTime); TaskSystem.Task task = new TaskSystem.Task("吟唱动画", cond); yield return(StartCoroutine(windy.Sing(task))); Debug.Log("吟唱 结束"); }