コード例 #1
0
        ///处理当前Guide
        IEnumerator ProcessCurrent()
        {
            while (true)
            {
                if (_currentGuideNodeArray /*[arrayIndex]*/ != null) //有当前步骤
                {
                    _currentGuideNodeArray /*[arrayIndex]*/.DispatchCondition();
                    _startTime /*[arrayIndex]*/ = Time.realtimeSinceStartup;
                    while (!_currentGuideNodeArray /*[arrayIndex]*/.isConditionReceipt)
                    {
                        if (Time.realtimeSinceStartup - _startTime /*[arrayIndex]*/ > TimeOut)//超时处理
                        {
                            break;
                        }
                        yield return(null);
                    }

                    if (_currentGuideNodeArray /*[arrayIndex]*/.isConditionSucess)
                    {
                        if (!_currentGuideNodeArray /*[arrayIndex]*/.isOnlyCondition) //非仅条件节点
                        {
                            IsRunGuide = true;
                            _currentGuideNodeArray /*[arrayIndex]*/.DispatchExecute();
                            _startTime /*[arrayIndex]*/ = Time.realtimeSinceStartup;
                            while (!_currentGuideNodeArray /*[arrayIndex]*/.isExecuteReceipt)
                            {
                                yield return(null);
                            }

                            if (_currentGuideNodeArray /*[arrayIndex]*/.isExecuteSucess)
                            {
                                GuideNode buff = GetNode(_currentGuideNodeArray /*[arrayIndex]*/.NextID);
                                if (buff == null)
                                {
                                    SetLinkCompleted(_currentGuideNodeArray /*[arrayIndex]*/);
                                }

                                if (buff != null && _currentGuideNodeArray /*[arrayIndex]*/.isNoWait && buff.isNoWait) //当前和上一个节点都是不需要等待就立即执行
                                {
                                    _currentGuideNodeArray /*[arrayIndex]*/ = buff;
                                    continue;
                                }
                                else
                                {
                                    _currentGuideNodeArray /*[arrayIndex]*/ = buff;
                                }
                            }
                            else
                            {
                                switch (_currentGuideNodeArray /*[arrayIndex]*/.ExecuteFailType)
                                {
                                case 1:
                                    int stepID = _currentGuideNodeArray /*[arrayIndex]*/.StepID;
                                    _currentGuideNodeArray /*[arrayIndex]*/ = GetNode(_currentGuideNodeArray /*[arrayIndex]*/.RollBackID);

                                    if (_currentGuideNodeArray /*[arrayIndex]*/ == null)
                                    {
                                        EB.Debug.LogError(" GuideNode {0}no RollBackID", stepID);
                                    }
                                    break;

                                case 0:
                                default:
                                    if (_currentGuideNodeArray /*[arrayIndex]*/.SkipToID == 0)
                                    {
                                        SetLinkCompleted(_currentGuideNodeArray /*[arrayIndex]*/);
                                        //发送同步完成的信息
                                        _currentGuideNodeArray /*[arrayIndex]*/ = null;
                                    }
                                    else
                                    {
                                        GuideNode buff = GetNode(_currentGuideNodeArray /*[arrayIndex]*/.SkipToID);
                                        if (buff == null)     //假如因为填写异常 报错提示并完成
                                        {
                                            EB.Debug.LogError("GuideNode SkipToID {0}no found,so Completed. ", _currentGuideNodeArray /*[arrayIndex]*/.SkipToID);
                                            SetLinkCompleted(_currentGuideNodeArray /*[arrayIndex]*/);
                                        }
                                        _currentGuideNodeArray /*[arrayIndex]*/ = buff;
                                    }
                                    break;
                                }
                            }
                            IsRunGuide = false;
                        }
                        else //处理仅条件节点 相当于同帧并行判断
                        {
                            GuideNode buff = GetNode(_currentGuideNodeArray /*[arrayIndex]*/.NextID);
                            while (buff != null && buff.isOnlyCondition) //遍历仅条件节点 不含执行的
                            {
                                buff.DispatchCondition();
                                _startTime /*[arrayIndex]*/ = Time.realtimeSinceStartup;
                                while (!buff.isConditionReceipt)
                                {
                                    if (Time.realtimeSinceStartup - _startTime /*[arrayIndex]*/ > TimeOut)//超时处理
                                    {
                                        break;
                                    }
                                    yield return(null);
                                }

                                if (buff.isConditionSucess) //如果条件成功那么就继续判断后续的仅条件节点
                                {
                                    buff = GetNode(buff.NextID);
                                }
                                else //如果不成功 仅条件节点就需要回滚 因为其是多条件组合
                                {
                                    buff = GetNode(buff.RollBackID);
                                    break;
                                }
                            }
                            _currentGuideNodeArray /*[arrayIndex]*/ = buff; //空或 含执行节点 交由下一逻辑帧处理
                        }
                    }
                    else  //条件不满足
                    {
                        if (_currentGuideNodeArray /*[arrayIndex]*/.ForeID == 0) //首节点条件不满足直接pass
                        {
                            _currentGuideNodeArray /*[arrayIndex]*/ = null;
                        }
                        else
                        {
                            GuideNode buff = GetNode(_currentGuideNodeArray /*[arrayIndex]*/.RollBackID);
                            if (buff == null)
                            {
                                //连续任务中间节点不满足且无回滚节点 直接标注为完成(除非不写条件就靠执行判断)
                                SetLinkCompleted(_currentGuideNodeArray /*[arrayIndex]*/);
                            }
                            _currentGuideNodeArray /*[arrayIndex]*/ = buff; //跳至需要回滚的节点 或==null 下一逻辑帧处理下一初始节点
                        }
                    }
                }

                yield return(null);
            }
        }
コード例 #2
0
        ///监控器Update
        private void Update(int seq)
        {
            if (_currentGuideNodeArray != null) //当前有引导要处理
            {
                if (_cProcessCurrentArray == null)
                {
                    _cProcessCurrentArray = EB.Coroutines.Run(ProcessCurrent());
                }
                return;
            }
            else if (_cProcessCurrentArray != null)//当前没引导
            {
                EB.Coroutines.Stop(_cProcessCurrentArray); _cProcessCurrentArray = null;
            }

            #region 当前没有步骤
            bool isGroupCompleted = true;
            // 遍历初始节点
            for (int i = 0; i < listStartNode.Count; i++)
            {
                var node = listStartNode[i];
                //前置ID不为0
                if (node.ForeID != 0)
                {
                    continue;
                }

                //此节点已完成
                if (node.IsCompleted)
                {
                    continue;
                }

                //判断执行该条件前的前置完成条件
                if (node.StepType != null)
                {
                    if (node.FocusView.Equals(CommonConditionParse.FocusViewName) &&
                        listCompleteIntStepID.TryGetValue(node.StepType[0], out var step0ID) &&
                        node.StepType[1] <= step0ID)
                    {
                        //特殊条件提前判断
                        switch (node.ConditionCmd)
                        {
                        case NodeMessageManager.GetGuideType:
                        {
                            if (GuideNodeManager.IsGuide)
                            {
                                isGroupCompleted = false;
                                continue;
                            }
                        }; break;

                        case NodeMessageManager.GetChallengeDiedAction:
                        {
                            isGroupCompleted = false;
                            continue;
                        };

                        default: { }; break;
                        }
                    }
                    else
                    {
                        isGroupCompleted = false;
                        continue;
                    }
                }

                isGroupCompleted = false;

                node.DispatchCondition();
                //条件满足
                if (node.isConditionSucess)
                {
                    if (!node.isOnlyCondition)
                    {
                        node.DispatchExecute();
                        if (node.isExecuteSucess)
                        {
                            GuideNode buff = GetNode(node.NextID);
                            if (buff == null)
                            {
                                SetLinkCompleted(node);//标记完成
                            }
                            _currentGuideNodeArray = buff;
                            break;
                        }
                        else
                        {
                            switch (node.ExecuteFailType)
                            {
                            case 1:
                                GuideNode buff = GetNode(node.RollBackID);
                                if (buff == null)
                                {
                                    EB.Debug.LogError(" GuideNode {0}no RollBackID", node.StepID);
                                }
                                _currentGuideNodeArray = buff;
                                continue;

                            case 0:
                            default:
                                if (node.SkipToID == 0)
                                {
                                    //这个相关联节点都成功 并发送告知服务器
                                    SetLinkCompleted(node);
                                    _currentGuideNodeArray = null;
                                }
                                else
                                {
                                    _currentGuideNodeArray = GetNode(node.SkipToID);
                                    if (_currentGuideNodeArray == null)     //假如因为填写异常 报错提示并完成
                                    {
                                        EB.Debug.LogError("GuideNode SkipToID {0}no found,so Completed. ", node.SkipToID);
                                        SetLinkCompleted(node);
                                    }
                                }
                                continue;
                            }
                        }
                    }
                    else //处理仅条件节点 相当于同帧并行判断
                    {
                        GuideNode buff = GetNode(node.NextID);
                        while (buff != null && buff.isOnlyCondition) //遍历仅条件节点 不含执行的
                        {
                            buff.DispatchCondition();
                            if (buff.isConditionSucess)
                            {
                                buff = GetNode(buff.NextID);
                            }
                            else //如果不成功 仅条件节点就需要回滚 因为其是多条件组合
                            {
                                buff = GetNode(buff.RollBackID);
                                break;
                            }
                        }

                        //空或 含执行节点 交由下一逻辑帧处理
                        _currentGuideNodeArray = buff;
                        if (_currentGuideNodeArray != null)
                        {
                            break;
                        }
                    }
                }
            }
            #endregion

            //全部引导结束,关闭携程,Update
            if (isGroupCompleted)
            {
                ILRTimerManager.instance.RemoveTimerSafely(ref _Update_Seq);
                EB.Coroutines.Stop(_cProcessCurrentArray); _cProcessCurrentArray = null;
            }
        }