Example #1
0
        public void OnStepFinish(GuideStep step, bool forceFinishAllSteps = false)
        {
            if (step.stepID > m_LastFinishStepID)
            {
                m_LastFinishStepID = step.stepID;
                GuideMgr.S.FinishStep(step);
            }

            //GuideMgr.S.FinishStep(step);

            TDGuideStep lastStep = TDGuideStepTable.GetGuideLastStep(m_GuideId);

            if (lastStep == null || lastStep.id == m_LastFinishStepID || forceFinishAllSteps)
            {
                ClearSelf();

                GuideMgr.S.FinishGuide(this);

                Log.i("#Guide Finish:" + m_GuideId);
            }
            else
            {
                TrackNextStep();
            }
        }
Example #2
0
        protected override List <ITrigger> GetTriggerArray()
        {
            TDGuideStep data = TDGuideStepTable.GetData(m_GuideStepID);

            if (data == null)
            {
                return(null);
            }

            return(LoadTrigger(data.trigger, data.commonParam));
        }
Example #3
0
        public void FinishStep(GuideStep step)
        {
            int oldKeyStep = DataRecord.S.GetInt(GetLastKeyStepKey(step.guide.guideID));

            if (oldKeyStep >= step.stepID)
            {
                return;
            }

            //TODO:需要找到最近的关键帧并保存
            var data = TDGuideStepTable.GetData(step.stepID);

            if (data != null)
            {
                if (data.keyFrame)
                {
                    DataRecord.S.SetInt(GetLastKeyStepKey(step.guide.guideID), step.stepID);
                    DataRecord.S.Save();
                }
                else
                {
                    //纪录最近的keyframe
                    var allStep = TDGuideStepTable.GetDataAsGuideID(step.guide.guideID);
                    for (int i = allStep.Count - 1; i >= 0; --i)
                    {
                        if (!allStep[i].keyFrame)
                        {
                            continue;
                        }

                        if (allStep[i].id <= oldKeyStep)
                        {
                            break;
                        }

                        if (allStep[i].id <= data.id)
                        {
                            DataRecord.S.SetInt(GetLastKeyStepKey(step.guide.guideID), allStep[i].id);
                            DataRecord.S.Save();
                            break;
                        }
                    }
                }
            }
        }
Example #4
0
        public int GetGuideLastStep(int guideID)
        {
            int stepId = DataRecord.S.GetInt(GetLastKeyStepKey(guideID));

            if (stepId > 0)
            {
                return(stepId);
            }

            var data = TDGuideStepTable.GetGuideFirstStep(guideID);

            if (data == null)
            {
                return(-1);
            }

            return(data.id - 1);
        }
Example #5
0
        protected override void OnAllTriggerEvent(bool ready)
        {
            if (ready)
            {
                if (!m_IsActive)
                {
                    var data = TDGuideStepTable.GetData(m_GuideStepID);

                    if (data.requireStepId > 0)
                    {
                        if (m_Guide.IsStepFinish(data.requireStepId))
                        {
                            ActiveSelf();
                        }
                    }
                    else
                    {
                        ActiveSelf();
                    }
                }
            }
            else
            {
                if (!m_IsActive)
                {
                    return;
                }

                m_IsActive = false;
                //Log.e ("Force Finish Step:" + m_GuideStepID);
                if (m_Commands != null)
                {
                    for (int i = 0; i < m_Commands.Count; ++i)
                    {
                        m_Commands[i].Finish(true);
                    }
                }
            }
        }
Example #6
0
        public bool ActiveSelf()
        {
            if (m_IsActive)
            {
                return(true);
            }

            m_IsActive = true;

            if (m_GuideSteps == null)
            {
                m_LastFinishStepID = GuideMgr.S.GetGuideLastStep(m_GuideId);

                var dataList = TDGuideStepTable.GetDataAsGuideID(m_GuideId);
                for (int i = 0; i < dataList.Count; ++i)
                {
                    if (dataList[i].id <= m_LastFinishStepID)
                    {
                        continue;
                    }
                    GuideStep step = new GuideStep(dataList [i].id);
                    AddStep(step);
                }
            }

            if (m_GuideSteps == null)
            {
                return(false);
            }

            Log.i("#Guide Start:" + m_GuideId);

            TrackNextStep();

            return(true);
        }
Example #7
0
        //command format:[c1:p1,p2,p3;c2:p1,p2,p3]
        private List <AbstractGuideCommand> LoadCommands()
        {
            TDGuideStep data = TDGuideStepTable.GetData(m_GuideStepID);

            if (data == null)
            {
                return(null);
            }

            string[] msg = data.command.Split(';');
            if (msg == null || msg.Length == 0)
            {
                return(null);
            }

            object[] commonParams = null;

            if (data.commonParam != null)
            {
                string[] comParamString = data.commonParam.Split(';');
                if (comParamString.Length > 0)
                {
                    commonParams = new object[comParamString.Length];
                    for (int i = 0; i < comParamString.Length; ++i)
                    {
                        if (comParamString[i].Contains(":"))
                        {
                            string[]      dynaParams   = comParamString [i].Split(':');
                            IRuntimeParam runtimeParam = RuntimeParamFactory.S.Create(dynaParams[0]);
                            if (runtimeParam == null)
                            {
                                Log.e("Create RuntimeParam Failed:" + dynaParams[0]);
                            }
                            else
                            {
                                if (dynaParams.Length > 1)
                                {
                                    object[] resultArray = GuideConfigParamProcess.ProcessParam(dynaParams[1], commonParams);
                                    runtimeParam.SetParam(resultArray);
                                }
                            }
                            commonParams[i] = runtimeParam;
                        }
                        else
                        {
                            commonParams[i] = comParamString[i];
                        }
                    }
                }
            }

            List <AbstractGuideCommand> result = null;

            for (int i = 0; i < msg.Length; ++i)
            {
                if (string.IsNullOrEmpty(msg[i]))
                {
                    continue;
                }
                string[] com = msg[i].Split(':');
                if (com == null || com.Length == 0)
                {
                    continue;
                }

                AbstractGuideCommand command = GuideCommandFactory.S.Create(com[0]);
                if (command == null)
                {
                    Log.e("Create Command Failed:" + com [0]);
                    continue;
                }

                if (com.Length > 1)
                {
                    object[] resultArray = GuideConfigParamProcess.ProcessParam(com[1], commonParams);
                    //处理参数
                    command.SetParam(resultArray);
                }

                if (result == null)
                {
                    result = new List <AbstractGuideCommand> ();
                }

                result.Add(command);
            }

            return(result);
        }