Exemple #1
0
        public List <GuideNode> GetLinkNodes(GuideNode node)
        {
            List <GuideNode> listNodes = new List <GuideNode>();

            listNodes.Add(node);
            SetForeNode(listNodes);
            SetNextEndNode(listNodes);
            return(listNodes);
        }
Exemple #2
0
 /// <summary>
 /// 是否所有经历的节点都是仅条件节点
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 private bool IsForeOnlyCondition(GuideNode node)
 {
     if (!node.isOnlyCondition)
     {
         return(false);
     }
     node = GetNode(node.ForeID);
     if (node == null)
     {
         return(true);
     }
     return(IsForeOnlyCondition(node));
 }
Exemple #3
0
 public void SetLinkOnceUndone(GuideNode node, bool isSave = true, bool isSend = true)
 {
     if (node.NextID == 0 && node.ForeID == 0)
     {
         node.SetOnceUndone();
         if (isSave)
         {
             if (listCompleteFirstStepID.Contains(node.StepID))
             {
                 listCompleteFirstStepID.Remove(node.StepID);
             }
             EB.Debug.Log("<color=#00ff00ff>激活StepID = {0}</color>", node.StepID);
         }
     }
     else
     {
         List <GuideNode> buffUndones = GetLinkNodes(node);
         for (int i = 0; i < buffUndones.Count; i++)
         {
             buffUndones[i].SetOnceUndone(); //标记一次不能完成
         }
         if (isSave)
         {
             if (listCompleteFirstStepID.Contains(node.StepID))
             {
                 listCompleteFirstStepID.Remove(buffUndones[0].StepID);
             }
             EB.Debug.Log("<color=#00ff00ff>重新激活StepID = {0}- {1}</color>", buffUndones[0].StepID, buffUndones[buffUndones.Count - 1].StepID);
         }
     }
     if (isSave && isSend) //如果要保存上传
     {
         StringBuilder sb      = new StringBuilder();
         bool          isfirst = true;
         foreach (var value in listCompleteIntStepID.Values)
         {
             if (isfirst)
             {
                 sb.Append(value);
                 isfirst = false;
                 continue;
             }
             sb.Append("%");
             sb.Append(value);
         }
         string data = sb.ToString();
         mGuideNodeApi.SaveGuideNode(data, (Response res) => { return(true); }); //默认完成
     }
 }
Exemple #4
0
        public void SetGuideNodes(List <Hotfix_LT.Data.GuideNodeTemplate> listNodeTpl)
        {
            dicNode.Clear();
            for (int i = 0; i < listNodeTpl.Count; i++)
            {
                Hotfix_LT.Data.GuideNodeTemplate tplNode = listNodeTpl[i];
                if (dicNode.ContainsKey(tplNode.step_id))
                {
                    continue;
                }

                GuideNode node = new GuideNode();
                node.UmengID = tplNode.umeng_id;
                node.GroupID = tplNode.group_id;
                node.StepID  = tplNode.step_id;
                node.NextID  = tplNode.next_id;
                node.ForeID  = tplNode.fore_id;
                if (tplNode.step_type != null)
                {
                    node.StepType  = tplNode.step_type;
                    node.FocusView = tplNode.focus_view;
                }
                node.RollBackID         = tplNode.roll_back_id;
                node.SkipToID           = tplNode.skip_to_id;
                node.ConditionEventCmd  = tplNode.condition_cmd;
                node.ConditionParameter = tplNode.c_parameter;
                switch (tplNode.c_receipt_type)
                {
                case "=":
                    node.ConditionReceiptType = 0;
                    break;

                case ">":
                    node.ConditionReceiptType = 1;
                    break;

                case "<":
                    node.ConditionReceiptType = 2;
                    break;
                }
                node.ConditionNeedParameter = tplNode.c_need_parameter;
                node.ExecuteEventCmd        = tplNode.execute_cmd;
                node.ExecuteParameter       = tplNode.e_parameter;
                node.ExecuteFailType        = tplNode.e_fail_type;
                node.Process();
                dicNode.Add(node.StepID, node);
            }
            isReceiveGuideNodes = true;
        }
Exemple #5
0
 /// <summary>
 /// 是否关联线已完成
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public bool IsLinkCompleted(GuideNode node)
 {
     if (node.IsCompleted)
     {
         return(true);
     }
     else
     {
         if (node.firstNodeStepID != node.StepID && dicNode.ContainsKey(node.firstNodeStepID))
         {
             return(dicNode[node.firstNodeStepID].IsCompleted);
         }
         return(false);
     }
 }
Exemple #6
0
        public void SetForeNode(List <GuideNode> list)
        {
            int findStepID = list[0].ForeID;

            if (findStepID != 0)
            {
                GuideNode node = GetNode(findStepID);
                if (node == null)
                {
                    EB.Debug.LogError("miss node ForeID={0}", findStepID);
                    return;
                }
                list.Insert(0, node);
                SetForeNode(list);
            }
        }
Exemple #7
0
        public void SetNextEndNode(List <GuideNode> list)
        {
            int findStepID = list[list.Count - 1].NextID;

            if (findStepID != 0)
            {
                GuideNode node = GetNode(findStepID);
                if (node == null)
                {
                    EB.Debug.LogError("miss node NextID={0}", findStepID);
                    return;
                }
                list.Add(node);
                SetNextEndNode(list);
            }
        }
Exemple #8
0
        private void GetGuideComplete(string strGuideNode)
        {
            int guideNodeID = 0;

            int.TryParse(strGuideNode, out guideNodeID);
            string result = NodeMessageManager.Fail;

            if (guideNodeID != 0)
            {
                GuideNode node = GuideNodeManager.GetInstance().GetNode(guideNodeID);

                if (node == null)
                {
                    EB.Debug.LogError("GetGuideComplete guidNode == null guideNodeStepID={0}", guideNodeID);
                }
                else
                {
                    if (GuideNodeManager.GetInstance().IsLinkCompleted(node))
                    {
                        result = NodeMessageManager.Sucess;
                    }
                }
            }
            else
            {
                string[] split = strGuideNode.Split(',');
                for (int i = 0; i < split.Length; i++)
                {
                    guideNodeID = int.Parse(split[i]);
                    GuideNode node = GuideNodeManager.GetInstance().GetNode(guideNodeID);

                    if (node == null)
                    {
                        EB.Debug.LogError("GetGuideComplete guidNode == null guideNodeStepID={0}", guideNodeID);
                    }
                    else
                    {
                        if (GuideNodeManager.GetInstance().IsLinkCompleted(node))
                        {
                            result = NodeMessageManager.Sucess;
                            break;
                        }
                    }
                }
            }
            DispatchConditionReceipt(NodeMessageManager.GetGuideComplete, result);
        }
Exemple #9
0
        ///关闭新手引导
        public void Close()
        {
            if (_currentGuideNodeArray != null)
            {
                EB.Debug.Log("GuideNodeManager Close _currentGuideNodeArray!");
                MengBanController.Instance.UnFobiddenAll();
                MengBanController.Instance.Hide();
                GuideToolController.Instance.Hide();
                IsGuide           = false;
                IsVirtualBtnGuide = false;
                isFuncOpenGuide   = false;
                FuncOpenGuideId   = string.Empty;
                GateString        = string.Empty;
                partnerStatID     = 0;
                VirtualBtnStr     = null;
                currentGuideId    = -1;
                if (_currentGuideNodeArray != null && !_currentGuideNodeArray.isExecuteReceipt)
                {
                    NotifyExecuteJump(_currentGuideNodeArray.ExecuteCmd); //执行跳过
                }
                _currentGuideNodeArray = null;
            }

            if (_cPrepare != null)
            {
                EB.Coroutines.Stop(_cPrepare);
                _cPrepare = null;
            }
            if (_cProcessCurrentArray != null)
            {
                EB.Coroutines.Stop(_cProcessCurrentArray);
                _cProcessCurrentArray = null;
            }
            ILRTimerManager.instance.RemoveTimerSafely(ref _Update_Seq);

            isReceiveCompletedData      = false;
            _commonCondition            = null;
            _commonExecute              = null;
            GuideNodeManager.GateString = string.Empty;
        }
Exemple #10
0
 /// <summary>
 /// 保存起始节点及设置首节点
 /// </summary>
 void SetStartNodes()
 {
     listStartNode.Clear();
     foreach (var v in dicNode)
     {
         if (v.Value.ForeID == 0)
         {
             listStartNode.Add(v.Value);
             v.Value.firstNodeStepID = v.Value.StepID;
         }
         else
         {
             GuideNode fn = GetFirstNode(v.Value);
             if (fn == null)
             {
                 v.Value.firstNodeStepID = v.Value.StepID;
             }
             else
             {
                 v.Value.firstNodeStepID = fn.StepID;
             }
         }
     }
 }
Exemple #11
0
        public GuideNode GetFirstNode(GuideNode node)
        {
            GuideNode buff = GetNode(node.ForeID);

            return(buff != null?GetFirstNode(buff) : node);
        }
Exemple #12
0
        /// <summary>
        /// 设置相关联的节点都完成
        /// </summary>
        /// <param name="node"></param>
        /// <param name="isSave"></param>
        public void SetLinkCompleted(GuideNode node, bool isSave = true, bool isSend = true)
        {
            if (node.NextID == 0 && node.ForeID == 0)
            {
                node.SetCompleted();
                if (isSave && node.IsCompleted)//增加一次性不保存的特性判断 必须IsCompleted==true
                {
                    if (!listCompleteFirstStepID.Contains(node.StepID))
                    {
                        listCompleteFirstStepID.Add(node.StepID);
                    }
                }
            }
            else
            {
                List <GuideNode> buffCompletes = GetLinkNodes(node);
                for (int i = 0; i < buffCompletes.Count; i++)
                {
                    buffCompletes[i].SetCompleted(); //标记完成
                }
                if (isSave && node.IsCompleted)      //增加一次性不保存的特性判断 必须IsCompleted==true
                {
                    if (!listCompleteFirstStepID.Contains(node.StepID))
                    {
                        listCompleteFirstStepID.Add(buffCompletes[0].StepID);
                    }
                }
            }

            #region 如果要保存上传
            if (isSave && isSend)
            {
                for (var i = 0; i < listCompleteFirstStepID.Count; i++)
                {
                    int stepId    = listCompleteFirstStepID[i];
                    var guideNode = dicNode[stepId];

                    if (listCompleteIntStepID.TryGetValue(guideNode.GroupID, out var theStepID))
                    {
                        if (theStepID < stepId)
                        {
                            listCompleteIntStepID[guideNode.GroupID] = stepId;
                        }
                    }
                    else
                    {
                        listCompleteIntStepID[guideNode.GroupID] = stepId;
                    }
                }
                StringBuilder sb = new StringBuilder();
                foreach (var value in listCompleteIntStepID.Values)
                {
                    sb.Append("%");
                    sb.Append(value);
                }
                string data = sb.ToString();
                if (data.Length > 0)
                {
                    data = data.Remove(0, 1);
                }
                mGuideNodeApi.SaveGuideNode(data, (Response res) => { return(true); }); //默认完成
            }
            #endregion
        }
Exemple #13
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);
            }
        }
Exemple #14
0
        ///新手引导开启准备阶段
        private IEnumerator PrepareOpen()
        {
            while (!isReceiveGuideNodes) //等待收到所有引导节点的数据
            {
                yield return(null);
            }

            while (!isReceiveCompletedData) //等待收到完成数据
            {
                yield return(null);
            }

            if (_cProcessCurrentArray != null)
            {
                EB.Coroutines.Stop(_cProcessCurrentArray);
            }

            bool isError = false;

            listCompleteFirstStepID.Clear();
            listCompleteIntStepID.Clear();
            List <int> temp = new List <int>();

            string[] saveCompletes = _serverSaveStr.Split('%');
            for (int i = 0; i < saveCompletes.Length; i++)
            {
                if (!string.IsNullOrEmpty(saveCompletes[i]))
                {
                    if (dicNode.ContainsKey(int.Parse(saveCompletes[i])))
                    {
                        listCompleteIntStepID.Add(dicNode[int.Parse(saveCompletes[i])].GroupID, int.Parse(saveCompletes[i]));
                    }
                    temp.Add(int.Parse(saveCompletes[i]));
                }
            }
            SetStartNodes();
            // 配置完成的节点
            //bool isLoadGuideAudio = false;
            for (int i = 0; i < temp.Count; i++)
            {
                if (dicNode.ContainsKey(temp[i]))
                {
                    int groupID = dicNode[temp[i]].GroupID;
                    for (int j = 0; j < listStartNode.Count; j++)
                    {
                        if (listStartNode[j].GroupID == groupID)
                        {
                            if (listStartNode[j].StepID <= temp[i] && dicNode.ContainsKey(listStartNode[j].StepID))
                            {
                                GuideNode node = dicNode[listStartNode[j].StepID];
                                if (node == null)
                                {
                                    continue;
                                }
                                SetLinkCompleted(node, false);
                                listCompleteFirstStepID.Add(int.Parse(saveCompletes[i]));
                            }
                            //else if (listStartNode[j].GroupID == 0 && listStartNode[j].StepID > temp[i])//判断是否要加载引导音效
                            //{
                            //    isLoadGuideAudio = true;
                            //}
                        }
                    }
                }
            }
            //if (isLoadGuideAudio || temp.Count == 0)
            //{
            //    FusionAudio.LoadGuideAudioClip();
            //}
            //else
            //{
            //    FusionAudio.ReleaseGuideAudioClips();
            //}

            //没有错误,开启新手引导
            if (!isError)
            {
                if (_commonCondition != null)
                {
                    _commonCondition.Dispose();
                }

                if (_commonExecute != null)
                {
                    _commonExecute.Dispose();
                }

                _commonCondition       = new CommonConditionParse();
                _commonExecute         = new CommonExecuteParse();
                _startTime             = 0;
                _beforeMemoryTime      = 0;
                _currentGuideNodeArray = null;
                if (_Update_Seq == 0)
                {
                    _Update_Seq = ILRTimerManager.instance.AddTimer(1, 0, Update);
                }
            }
        }
Exemple #15
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;
            }
        }