Example #1
0
 //重写执行
 protected override sealed int OnExcute(NodeData wData)
 {
     int runningState = NodeState.FINISHED;
     //获取环境数据
     NodeActionContext context = GetContext<NodeActionContext>(wData);
     //准备进入
     if (context.status == ACTION_READY)
     {
         OnEnter(wData);
         context.needExit = true;
         context.status = ACTION_RUNNING;
     }
     //运行执行
     if (context.status == ACTION_RUNNING)
     {
         runningState = OnRunning(wData);
         if (NodeState.IsFinished(runningState))
         {
             context.status = ACTION_FINISHED;
         }
     }
     //完成退出
     if (context.status == ACTION_FINISHED)
     {
         if (context.needExit)
         {
             OnExit(wData, runningState);
         }
         context.status = ACTION_READY;
         context.needExit = false;
     }
     return runningState;
 }
Example #2
0
        protected sealed override void OnTransition(NodeData wData)
        {
            NodeActionContext context = GetContext <NodeActionContext>(wData);

            context.status = ACTION_READY;
            OnExit(wData, NodeState.TRANSITION);
        }
        protected override int OnRunning(NodeData wData)
        {
            EntityWorkData    workData = wData as EntityWorkData;
            NodeActionContext context  = GetContext <NodeActionContext>(wData);
            PushSkillData     userData = context.GetUserData <PushSkillData>();

            SkillCom skillCom = workData.MEntity.GetCom <SkillCom>();

            if (userData.skillId == "-1" || skillCom.CheckSkillIsFinish(userData.skillId))
            {
                Debug.LogError("完成》》》》》" + userData.skillId);
                Debug.LogError("完成》》》》》" + skillCom.CheckSkillIsFinish(userData.skillId));
                return(NodeState.FINISHED);
            }
            else
            {
                return(NodeState.EXECUTING);
            }
        }
        protected override void OnExit(NodeData wData, int runningStatus)
        {
            EntityWorkData    workData = wData as EntityWorkData;
            NodeActionContext context  = GetContext <NodeActionContext>(wData);
            PushSkillData     userData = context.GetUserData <PushSkillData>();

            userData.skillId = "-1";

            //打断移动
            SkillCom skillCom = workData.MEntity.GetCom <SkillCom>();

            skillCom.StopSkill();
            AnimCom animCom = workData.MEntity.GetCom <AnimCom>();

            if (animCom != null)
            {
                animCom.SetReqAnim(AnimSystem.IdleState);
            }
        }
        protected override void OnEnter(NodeData wData)
        {
            EntityWorkData workData = wData as EntityWorkData;
            string         skillId  = workData.GetParam().GetString();

            //获取环境数据
            NodeActionContext context  = GetContext <NodeActionContext>(wData);
            PushSkillData     userData = context.GetUserData <PushSkillData>();

            userData.skillId = skillId;

            //打断移动
            TransformCom transformCom = workData.MEntity.GetCom <TransformCom>();

            if (transformCom != null)
            {
                transformCom.ReqMove = Vector3.zero;
                transformCom.ReqDir  = DirType.None;
            }
            PlayerMoveCom moveCom = workData.MEntity.GetCom <PlayerMoveCom>();

            if (moveCom != null)
            {
                moveCom.HasNoReqMove = true;
                moveCom.Rig.velocity = Vector2.zero;
            }

            //释放技能
            SkillCom skillCom = workData.MEntity.GetCom <SkillCom>();

            if (skillCom.ReleaseSkill(skillId))
            {
                userData.skillId = skillId;
                LCECS.ECSLocate.Log.Log("释放技能成功>>>>>", skillId);
            }
            else
            {
                userData.skillId = "-1";
                LCECS.ECSLocate.Log.LogError("释放技能失败>>>>>", skillId);
            }
        }