public override SkillNodeState Use(Entity skillUser) { SkillNodeState currentNodeState = SkillNodeState.FailToRun; for (int i = 0; i < ChildSkillNodes.Count; i++) { SkillNodeState childTreeState = ChildSkillNodes[NextUse].Use(skillUser); if (childTreeState == SkillNodeState.FailToRun) //如果本次执行的子技能节点无法释放 { NextUse = (NextUse + 1) % ChildSkillNodes.Count; //下一次进入时执行下一个子技能节点 } if (childTreeState == SkillNodeState.Running) //如果本次执行的子技能节点正在释放中 { currentNodeState = SkillNodeState.Running; //当前节点的子节点还在执行 break; //跳出循环 } if (childTreeState == SkillNodeState.Finish) //如果本次执行的子技能节点全部释放完毕,也就是说这个节点下没有可以执行的技能了 { NextUse = (NextUse + 1) % ChildSkillNodes.Count; //下一次进入时执行下一个子技能节点 currentNodeState = SkillNodeState.Running; //当前节点是正在运行的 break; //跳出循环 } } return(currentNodeState); }
public override SkillNodeState Use() { SkillNodeState currentNodeState = SkillNodeState.FailToRun; for (int i = 0; i < ChildSkillNodes.Count; i++) { switch (ChildSkillNodes[NextUse].Use()) { case SkillNodeState.Running: return(SkillNodeState.Running); case SkillNodeState.Finish: //此子技能释放完毕 currentNodeState = SkillNodeState.Running; //此节点的子节点正在释放 NextUse = (NextUse + 1) % ChildSkillNodes.Count; if (NextUse == 0) //如果刚才释放的是最后一个子节点技能,代表完成 { currentNodeState = SkillNodeState.Finish; } break; case SkillNodeState.FailToRun: //当子技能无法被释放时 NextUse = (NextUse + 1) % ChildSkillNodes.Count; break; default: NextUse = (NextUse + 1) % ChildSkillNodes.Count; break; } } return(currentNodeState); }
public override SkillNodeState Use(Entity skillUser) { SkillNodeState currentNodeState = SkillNodeState.FailToRun; for (int i = 0; i < ChildSkillNodes.Count; i++) { if (ChildSkillNodes[NextUse].Use(skillUser) == SkillNodeState.Finish) //此子技能可以释放 { currentNodeState = SkillNodeState.Running; //此节点的子节点正在释放 NextUse = (NextUse + 1) % ChildSkillNodes.Count; if (NextUse == 0) //如果刚才释放的是最后一个子节点技能,代表完成 { currentNodeState = SkillNodeState.Finish; } break; } NextUse = (NextUse + 1) % ChildSkillNodes.Count; } return(currentNodeState); }