Ejemplo n.º 1
0
 /// <summary>
 /// 创建步骤助手
 /// </summary>
 private StepHelper CreateHelper(StepContent content, StepHelperTask task)
 {
     if (!string.IsNullOrEmpty(content.Helper) && content.Helper != "<None>")
     {
         Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(content.Helper);
         if (type != null)
         {
             StepHelper helper = Activator.CreateInstance(type) as StepHelper;
             helper.Parameters = content.Parameters;
             for (int i = 0; i < helper.Parameters.Count; i++)
             {
                 if (helper.Parameters[i].Type == StepParameter.ParameterType.GameObject)
                 {
                     if (_targets.ContainsKey(helper.Parameters[i].GameObjectGUID))
                     {
                         helper.Parameters[i].GameObjectValue = _targets[helper.Parameters[i].GameObjectGUID].gameObject;
                     }
                 }
             }
             helper.Content = content;
             helper.Target  = content.Target.GetComponent <StepTarget>();
             helper.Task    = task;
             helper.OnInit();
             return(helper);
         }
         else
         {
             Log.Error(string.Format("步骤控制器:步骤 {0}.{1} 的助手 {2} 丢失!", _currentStepIndex + 1, _currentContent.Name, _currentContent.Helper));
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
        private void BeginCurrentStep()
        {
            _executing      = false;
            _currentContent = _stepContents[_currentStep];
            _currentTarget  = _currentContent.Target.GetComponent <StepTarget>();

            //UGUI按钮点击型步骤,注册监听
            if (_currentContent.Trigger == StepTrigger.ButtonClick)
            {
                _isButtonClick = false;
                _currentButton = _currentContent.Target.GetComponent <Button>();
                if (_currentButton)
                {
                    _currentButton.onClick.AddListener(ButtonClickCallback);
                }
                else
                {
                    GlobalTools.LogError(string.Format("【步骤:{0}】的目标丢失Button组件!", _currentStep + 1));
                }
            }
            //状态改变触发类型的步骤,自动重置状态
            else if (_currentContent.Trigger == StepTrigger.StateChange)
            {
                _currentTarget.State = StepTargetState.Normal;
            }

            //创建步骤助手
            if (_currentContent.Helper != "<None>")
            {
                Type type = GlobalTools.GetTypeInRunTimeAssemblies(_currentContent.Helper);
                if (type != null)
                {
                    _currentHelper        = Activator.CreateInstance(type) as StepHelper;
                    _currentHelper.Target = _currentTarget;
                    _currentHelper.Task   = StepHelperTask.Execute;
                    _currentHelper.OnInit();
                }
                else
                {
                    GlobalTools.LogError(string.Format("【步骤:{0}】的助手 {1} 丢失!", _currentStep + 1, _currentContent.Helper));
                }
            }

            Main.m_Controller.TheControlMode = _currentContent.InitialMode;
            Main.m_Controller.SetLookPoint(_currentTarget.transform.position + _currentContent.ViewOffset, true);
            Main.m_Controller.SetLookAngle(_currentContent.BestView, true);

            if (_stepContentEnables.ContainsKey(_currentContent.GUID))
            {
                BeginStepEvent?.Invoke(_currentContent, _stepContentEnables[_currentContent.GUID]);
                if (!_stepContentEnables[_currentContent.GUID])
                {
                    StartCoroutine(SkipCurrentStepCoroutine());
                }
            }
            else
            {
                BeginStepEvent?.Invoke(_currentContent, false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 恢复到指定步骤
        /// </summary>
        /// <param name="stepID">步骤ID</param>
        /// <returns>恢复成功/失败</returns>
        public bool RestoreStep(string stepID)
        {
            if (_running && !_executing)
            {
                if (!_stepContentIndexs.ContainsKey(stepID))
                {
                    return(false);
                }

                int index = _stepContentIndexs[stepID];
                if (index < 0 || index >= _currentStep)
                {
                    return(false);
                }

                while (_currentStep >= index)
                {
                    _currentContent = _stepContents[_currentStep];
                    _currentTarget  = _currentContent.Target.GetComponent <StepTarget>();

                    RestoreStepEvent?.Invoke(_currentContent, _stepContentEnables.ContainsKey(_currentContent.GUID) ? _stepContentEnables[_currentContent.GUID] : false);

                    //创建步骤助手
                    if (_currentHelper == null && _currentContent.Helper != "<None>")
                    {
                        Type type = GlobalTools.GetTypeInRunTimeAssemblies(_currentContent.Helper);
                        if (type != null)
                        {
                            _currentHelper        = Activator.CreateInstance(type) as StepHelper;
                            _currentHelper.Target = _currentTarget;
                            _currentHelper.Task   = StepHelperTask.Restore;
                            _currentHelper.OnInit();
                        }
                        else
                        {
                            GlobalTools.LogError(string.Format("【步骤:{0}】的助手 {1} 丢失!", _currentStep + 1, _currentContent.Helper));
                        }
                    }
                    //助手执行恢复
                    if (_currentHelper != null)
                    {
                        _currentHelper.Task = StepHelperTask.Restore;
                        _currentHelper.OnRestore();
                        _currentHelper.OnTermination();
                        _currentHelper = null;
                    }

                    _currentStep -= 1;
                }

                _currentStep = index;
                BeginCurrentStep();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 恢复到指定步骤
        /// </summary>
        public bool RestoreStep(int stepIndex)
        {
            if (_ongoing && !_running)
            {
                if (stepIndex < 0 || stepIndex >= _currentStep)
                {
                    return(false);
                }

                while (_currentStep >= stepIndex)
                {
                    _currentContent = _stepContents[_currentStep];
                    _currentTarget  = _currentContent.Target.GetComponent <StepTarget>();

                    if (RestoreStepEvent != null)
                    {
                        RestoreStepEvent(_currentContent);
                    }

                    //创建步骤助手
                    if (_currentHelper == null && _currentContent.Helper != "<None>")
                    {
                        Type type = GlobalTools.GetTypeInRunTimeAssemblies(_currentContent.Helper);
                        if (type != null)
                        {
                            _currentHelper        = Activator.CreateInstance(type) as StepHelper;
                            _currentHelper.Target = _currentTarget;
                            _currentHelper.Task   = StepHelperTask.Restore;
                            _currentHelper.OnInit();
                        }
                        else
                        {
                            GlobalTools.LogError("【步骤:" + (_currentStep + 1) + "】的助手 " + _currentContent.Helper + " 丢失!");
                        }
                    }
                    //助手执行恢复
                    if (_currentHelper != null)
                    {
                        _currentHelper.Task = StepHelperTask.Restore;
                        _currentHelper.OnRestore();
                        _currentHelper.OnTermination();
                        _currentHelper = null;
                    }

                    _currentStep -= 1;
                }

                _currentStep = stepIndex;
                BeginCurrentStep();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        private void BeginCurrentStep()
        {
            _running        = false;
            _currentContent = _stepContents[_currentStep];
            _currentTarget  = _currentContent.Target.GetComponent <StepTarget>();

            //UGUI按钮点击型步骤,注册监听
            if (_currentContent.Trigger == StepTrigger.ButtonClick)
            {
                _isButtonClick = false;
                _currentButton = _currentContent.Target.GetComponent <Button>();
                if (_currentButton)
                {
                    _currentButton.onClick.AddListener(ButtonClickCallback);
                }
                else
                {
                    GlobalTools.LogError("【步骤:" + (_currentStep + 1) + "】的目标丢失Button组件!");
                }
            }
            //状态改变触发类型的步骤,自动重置状态
            else if (_currentContent.Trigger == StepTrigger.StateChange)
            {
                _currentTarget.State = StepTargetState.Normal;
            }

            //创建步骤助手
            if (_currentContent.Helper != "<None>")
            {
                Type type = GlobalTools.GetTypeInRunTimeAssemblies(_currentContent.Helper);
                if (type != null)
                {
                    _currentHelper        = Activator.CreateInstance(type) as StepHelper;
                    _currentHelper.Target = _currentTarget;
                    _currentHelper.Task   = StepHelperTask.Execute;
                    _currentHelper.OnInit();
                }
                else
                {
                    GlobalTools.LogError("【步骤:" + (_currentStep + 1) + "】的助手 " + _currentContent.Helper + " 丢失!");
                }
            }

            Main.m_Controller.TheControlMode = _currentContent.InitialMode;
            Main.m_Controller.SetLookPoint(_currentTarget.transform.position + _currentContent.ViewOffset, true);
            Main.m_Controller.SetLookAngle(_currentContent.BestView, true);

            if (BeginStepEvent != null)
            {
                BeginStepEvent(_currentContent);
            }
        }
Ejemplo n.º 6
0
        private IEnumerator SkipStepCoroutine(int index)
        {
            _executing = true;
            _skipIndex = index;

            while (_currentStep < _skipIndex)
            {
                _currentContent = _stepContents[_currentStep];
                _currentTarget  = _currentContent.Target.GetComponent <StepTarget>();
                _currentContent.Skip(this);

                Main.m_Controller.TheControlMode = _currentContent.InitialMode;
                Main.m_Controller.SetLookPoint(_currentTarget.transform.position + _currentContent.ViewOffset, false);
                Main.m_Controller.SetLookAngle(_currentContent.BestView, true);

                SkipStepEvent?.Invoke(_currentContent, _stepContentEnables.ContainsKey(_currentContent.GUID) ? _stepContentEnables[_currentContent.GUID] : false);

                //UGUI按钮点击型步骤,自动执行按钮事件
                if (_currentContent.Trigger == StepTrigger.ButtonClick)
                {
                    if (_currentButton)
                    {
                        _currentButton.onClick.Invoke();
                    }
                    else
                    {
                        _currentButton = _currentContent.Target.GetComponent <Button>();
                        if (_currentButton)
                        {
                            _currentButton.onClick.Invoke();
                        }
                        else
                        {
                            GlobalTools.LogError(string.Format("【步骤:{0}】的目标丢失Button组件!", _currentStep + 1));
                        }
                    }
                    _currentButton = null;
                }

                //创建步骤助手
                if (_currentHelper == null && _currentContent.Helper != "<None>")
                {
                    Type type = GlobalTools.GetTypeInRunTimeAssemblies(_currentContent.Helper);
                    if (type != null)
                    {
                        _currentHelper        = Activator.CreateInstance(type) as StepHelper;
                        _currentHelper.Target = _currentTarget;
                        _currentHelper.Task   = StepHelperTask.Skip;
                        _currentHelper.OnInit();
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("【步骤:{0}】的助手 {1} 丢失!", _currentStep + 1, _currentContent.Helper));
                    }
                }
                //助手执行跳过,等待生命周期结束后销毁助手
                if (_currentHelper != null)
                {
                    _currentHelper.Task = StepHelperTask.Skip;
                    _currentHelper.OnSkip();
                    if (_currentHelper.SkipLifeTime > 0)
                    {
                        yield return(YieldInstructioner.GetWaitForSeconds(_currentHelper.SkipLifeTime / SkipMultiple));
                    }
                    _currentHelper.OnTermination();
                    _currentHelper = null;
                }

                yield return(YieldInstructioner.GetWaitForSeconds(_currentContent.ElapseTime / SkipMultiple));

                _currentStep += 1;
            }

            SkipStepDoneEvent?.Invoke();

            BeginCurrentStep();
        }
Ejemplo n.º 7
0
        //跳过到指定步骤
        private IEnumerator SkipStepCoroutine(int index)
        {
            _executing       = true;
            _skipTargetIndex = index;

            while (_currentStepIndex < _skipTargetIndex)
            {
                _currentContent = _stepContents[_currentStepIndex];
                _currentTarget  = _currentContent.Target.GetComponent <StepTarget>();
                _currentContent.Skip();

                SkipStepEvent?.Invoke(_currentContent, _stepContentEnables.ContainsKey(_currentContent.GUID) ? _stepContentEnables[_currentContent.GUID] : false);

                //UGUI按钮点击型步骤,自动执行按钮事件
                if (_currentContent.Trigger == StepTrigger.ButtonClick)
                {
                    if (_currentButton)
                    {
                        _currentButton.onClick.Invoke();
                        _currentButton.onClick.RemoveListener(ButtonClickCallback);
                    }
                    else
                    {
                        _currentButton = _currentContent.Target.GetComponent <Button>();
                        if (_currentButton)
                        {
                            _currentButton.onClick.Invoke();
                        }
                        else
                        {
                            Log.Error(string.Format("步骤控制器:【步骤:{0}】【{1}】的目标丢失Button组件!", _currentStepIndex + 1, _currentContent.Name));
                        }
                    }
                    _currentButton = null;
                }

                //创建步骤助手
                if (_currentHelper == null && _currentContent.Helper != "<None>")
                {
                    Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(_currentContent.Helper);
                    if (type != null)
                    {
                        _currentHelper            = Activator.CreateInstance(type) as StepHelper;
                        _currentHelper.Parameters = _currentContent.Parameters;
                        for (int i = 0; i < _currentHelper.Parameters.Count; i++)
                        {
                            if (_currentHelper.Parameters[i].Type == StepParameter.ParameterType.GameObject)
                            {
                                if (_targets.ContainsKey(_currentHelper.Parameters[i].GameObjectGUID))
                                {
                                    _currentHelper.Parameters[i].GameObjectValue = _targets[_currentHelper.Parameters[i].GameObjectGUID].gameObject;
                                }
                            }
                        }
                        _currentHelper.Content = _currentContent;
                        _currentHelper.Target  = _currentTarget;
                        _currentHelper.Task    = StepHelperTask.Skip;
                        _currentHelper.OnInit();
                    }
                    else
                    {
                        Log.Error(string.Format("步骤控制器:【步骤:{0}】【{1}】的助手 {2} 丢失!", _currentStepIndex + 1, _currentContent.Name, _currentContent.Helper));
                    }
                }
                //助手执行跳过,等待生命周期结束后销毁助手
                if (_currentHelper != null)
                {
                    _currentHelper.Task = StepHelperTask.Skip;
                    _currentHelper.OnSkip();
                    if (_currentHelper.SkipLifeTime > 0)
                    {
                        yield return(YieldInstructioner.GetWaitForSeconds(_currentHelper.SkipLifeTime / SkipMultiple));
                    }
                    _currentHelper.OnTermination();
                    _currentHelper = null;
                }

                yield return(YieldInstructioner.GetWaitForSeconds(_currentContent.ElapseTime / SkipMultiple));

                _currentStepIndex += 1;
            }

            SkipStepDoneEvent?.Invoke();

            _waitCoroutine = Main.Current.StartCoroutine(WaitCoroutine(BeginCurrentStep, 0));
        }
Ejemplo n.º 8
0
        //步骤开始
        private void BeginCurrentStep()
        {
            _executing      = false;
            _currentContent = _stepContents[_currentStepIndex];
            _currentTarget  = _currentContent.Target.GetComponent <StepTarget>();

            //UGUI按钮点击型步骤,注册监听
            if (_currentContent.Trigger == StepTrigger.ButtonClick)
            {
                _isButtonClick = false;
                _currentButton = _currentTarget.GetComponent <Button>();
                if (_currentButton)
                {
                    _currentButton.onClick.AddListener(ButtonClickCallback);
                }
                else
                {
                    Log.Error(string.Format("步骤控制器:【步骤:{0}】【{1}】的目标丢失Button组件!", _currentStepIndex + 1, _currentContent.Name));
                }
            }
            //状态改变触发类型的步骤,自动重置状态
            else if (_currentContent.Trigger == StepTrigger.StateChange)
            {
                _currentTarget.State = StepTargetState.Normal;
            }

            //创建步骤助手
            if (_currentContent.Helper != "<None>")
            {
                Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(_currentContent.Helper);
                if (type != null)
                {
                    _currentHelper            = Activator.CreateInstance(type) as StepHelper;
                    _currentHelper.Parameters = _currentContent.Parameters;
                    for (int i = 0; i < _currentHelper.Parameters.Count; i++)
                    {
                        if (_currentHelper.Parameters[i].Type == StepParameter.ParameterType.GameObject)
                        {
                            if (_targets.ContainsKey(_currentHelper.Parameters[i].GameObjectGUID))
                            {
                                _currentHelper.Parameters[i].GameObjectValue = _targets[_currentHelper.Parameters[i].GameObjectGUID].gameObject;
                            }
                        }
                    }
                    _currentHelper.Content = _currentContent;
                    _currentHelper.Target  = _currentTarget;
                    _currentHelper.Task    = StepHelperTask.Execute;
                    _currentHelper.OnInit();
                }
                else
                {
                    Log.Error(string.Format("步骤控制器:【步骤:{0}】【{1}】的助手 {2} 丢失!", _currentStepIndex + 1, _currentContent.Name, _currentContent.Helper));
                }
            }

            //未激活的步骤自动跳过
            if (_stepContentEnables.ContainsKey(_currentContent.GUID))
            {
                BeginStepEvent?.Invoke(_currentContent, _stepContentEnables[_currentContent.GUID]);
                if (!_stepContentEnables[_currentContent.GUID])
                {
                    Main.Current.StartCoroutine(SkipCurrentStepCoroutine());
                }
            }
            else
            {
                BeginStepEvent?.Invoke(_currentContent, false);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 恢复到指定步骤
        /// </summary>
        /// <param name="stepID">步骤ID</param>
        /// <returns>恢复成功/失败</returns>
        public bool RestoreStep(string stepID)
        {
            if (_running && !_executing)
            {
                if (_pause)
                {
                    return(false);
                }

                if (!_stepContentIndexs.ContainsKey(stepID))
                {
                    return(false);
                }

                int index = _stepContentIndexs[stepID];
                if (index < 0 || index >= _currentStepIndex)
                {
                    return(false);
                }

                while (_currentStepIndex >= index)
                {
                    _currentContent = _stepContents[_currentStepIndex];
                    _currentTarget  = _currentContent.Target.GetComponent <StepTarget>();

                    RestoreStepEvent?.Invoke(_currentContent, _stepContentEnables.ContainsKey(_currentContent.GUID) ? _stepContentEnables[_currentContent.GUID] : false);

                    //创建步骤助手
                    if (_currentHelper == null && _currentContent.Helper != "<None>")
                    {
                        Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(_currentContent.Helper);
                        if (type != null)
                        {
                            _currentHelper            = Activator.CreateInstance(type) as StepHelper;
                            _currentHelper.Parameters = _currentContent.Parameters;
                            for (int i = 0; i < _currentHelper.Parameters.Count; i++)
                            {
                                if (_currentHelper.Parameters[i].Type == StepParameter.ParameterType.GameObject)
                                {
                                    if (_targets.ContainsKey(_currentHelper.Parameters[i].GameObjectGUID))
                                    {
                                        _currentHelper.Parameters[i].GameObjectValue = _targets[_currentHelper.Parameters[i].GameObjectGUID].gameObject;
                                    }
                                }
                            }
                            _currentHelper.Content = _currentContent;
                            _currentHelper.Target  = _currentTarget;
                            _currentHelper.Task    = StepHelperTask.Restore;
                            _currentHelper.OnInit();
                        }
                        else
                        {
                            Log.Error(string.Format("步骤控制者:【步骤:{0}】的助手 {1} 丢失!", _currentStepIndex + 1, _currentContent.Helper));
                        }
                    }
                    //助手执行恢复
                    if (_currentHelper != null)
                    {
                        _currentHelper.Task = StepHelperTask.Restore;
                        _currentHelper.OnRestore();
                        _currentHelper.OnTermination();
                        _currentHelper = null;
                    }

                    _currentStepIndex -= 1;
                }

                _currentStepIndex = index;
                BeginCurrentStep();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 跳过当前步骤(立即模式)
        /// </summary>
        private void SkipCurrentStepImmediateCoroutine()
        {
            _executing = true;

            SkipStepImmediateEvent?.Invoke(_currentContent, _stepContentEnables.ContainsKey(_currentContent.GUID) ? _stepContentEnables[_currentContent.GUID] : false);

            //UGUI按钮点击型步骤,自动执行按钮事件
            if (_currentContent.Trigger == StepTrigger.ButtonClick)
            {
                if (_currentButton)
                {
                    _currentButton.onClick.Invoke();
                    _currentButton.onClick.RemoveListener(ButtonClickCallback);
                }
                else
                {
                    _currentButton = _currentTarget.GetComponent <Button>();
                    if (_currentButton)
                    {
                        _currentButton.onClick.Invoke();
                    }
                    else
                    {
                        Log.Error(string.Format("步骤控制器:【步骤:{0}】【{1}】的目标丢失Button组件!", _currentStepIndex + 1, _currentContent.Name));
                    }
                }
                _currentButton = null;
            }

            //创建步骤助手
            if (_currentHelper == null && _currentContent.Helper != "<None>")
            {
                Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(_currentContent.Helper);
                if (type != null)
                {
                    _currentHelper            = Activator.CreateInstance(type) as StepHelper;
                    _currentHelper.Parameters = _currentContent.Parameters;
                    for (int i = 0; i < _currentHelper.Parameters.Count; i++)
                    {
                        if (_currentHelper.Parameters[i].Type == StepParameter.ParameterType.GameObject)
                        {
                            if (_targets.ContainsKey(_currentHelper.Parameters[i].GameObjectGUID))
                            {
                                _currentHelper.Parameters[i].GameObjectValue = _targets[_currentHelper.Parameters[i].GameObjectGUID].gameObject;
                            }
                        }
                    }
                    _currentHelper.Content = _currentContent;
                    _currentHelper.Target  = _currentTarget;
                    _currentHelper.Task    = StepHelperTask.SkipImmediate;
                    _currentHelper.OnInit();
                }
                else
                {
                    Log.Error(string.Format("步骤控制器:【步骤:{0}】【{1}】的助手 {2} 丢失!", _currentStepIndex + 1, _currentContent.Name, _currentContent.Helper));
                }
            }

            _currentContent.SkipImmediate();

            //助手执行跳过,等待生命周期结束后销毁助手
            if (_currentHelper != null)
            {
                _currentHelper.Task = StepHelperTask.SkipImmediate;
                _currentHelper.OnSkipImmediate();
                _currentHelper.OnTermination();
                _currentHelper = null;
            }

            ChangeNextStep();
        }
Ejemplo n.º 11
0
        private IEnumerator SkipCurrentStepCoroutine()
        {
            _running = true;

            Main.m_Controller.TheControlMode = _currentContent.InitialMode;
            Main.m_Controller.SetLookPoint(_currentTarget.transform.position + _currentContent.ViewOffset, false);
            Main.m_Controller.SetLookAngle(_currentContent.BestView, true);

            if (SkipStepEvent != null)
            {
                SkipStepEvent(_currentContent);
            }

            //UGUI按钮点击型步骤,自动执行按钮事件
            if (_currentContent.Trigger == StepTrigger.ButtonClick)
            {
                if (_currentButton)
                {
                    _currentButton.onClick.Invoke();
                }
                else
                {
                    _currentButton = _currentContent.Target.GetComponent <Button>();
                    if (_currentButton)
                    {
                        _currentButton.onClick.Invoke();
                    }
                    else
                    {
                        GlobalTools.LogError("【步骤:" + (_currentStep + 1) + "】的目标丢失Button组件!");
                    }
                }
                _currentButton = null;
            }

            //创建步骤助手
            if (_currentHelper == null && _currentContent.Helper != "<None>")
            {
                Type type = GlobalTools.GetTypeInRunTimeAssemblies(_currentContent.Helper);
                if (type != null)
                {
                    _currentHelper        = Activator.CreateInstance(type) as StepHelper;
                    _currentHelper.Target = _currentTarget;
                    _currentHelper.Task   = StepHelperTask.Skip;
                    _currentHelper.OnInit();
                }
                else
                {
                    GlobalTools.LogError("【步骤:" + (_currentStep + 1) + "】的助手 " + _currentContent.Helper + " 丢失!");
                }
            }
            //助手执行跳过,等待生命周期结束后销毁助手
            if (_currentHelper != null)
            {
                _currentHelper.Task = StepHelperTask.Skip;
                _currentHelper.OnSkip();
                if (_currentHelper.SkipLifeTime > 0)
                {
                    yield return(new WaitForSeconds(_currentHelper.SkipLifeTime / SkipMultiple));
                }
                _currentHelper.OnTermination();
                _currentHelper = null;
            }

            _currentContent.Skip(this);

            yield return(new WaitForSeconds(_currentContent.ElapseTime / SkipMultiple));

            ChangeNextStep();
        }
Ejemplo n.º 12
0
        private IEnumerator SkipCurrentStepCoroutine()
        {
            _executing = true;
            _currentContent.Skip(this);

            SkipStepEvent?.Invoke(_currentContent, _stepContentEnables.ContainsKey(_currentContent.GUID) ? _stepContentEnables[_currentContent.GUID] : false);

            //UGUI按钮点击型步骤,自动执行按钮事件
            if (_currentContent.Trigger == StepTrigger.ButtonClick)
            {
                if (_currentButton)
                {
                    _currentButton.onClick.Invoke();
                }
                else
                {
                    _currentButton = _currentContent.Target.GetComponent <Button>();
                    if (_currentButton)
                    {
                        _currentButton.onClick.Invoke();
                    }
                    else
                    {
                        GlobalTools.LogError(string.Format("【步骤:{0}】的目标丢失Button组件!", _currentStep + 1));
                    }
                }
                _currentButton = null;
            }

            //创建步骤助手
            if (_currentHelper == null && _currentContent.Helper != "<None>")
            {
                Type type = GlobalTools.GetTypeInRunTimeAssemblies(_currentContent.Helper);
                if (type != null)
                {
                    _currentHelper            = Activator.CreateInstance(type) as StepHelper;
                    _currentHelper.Parameters = _currentContent.Parameters;
                    for (int i = 0; i < _currentHelper.Parameters.Count; i++)
                    {
                        if (_currentHelper.Parameters[i].Type == StepParameter.ParameterType.GameObject)
                        {
                            if (_targets.ContainsKey(_currentHelper.Parameters[i].GameObjectGUID))
                            {
                                _currentHelper.Parameters[i].GameObjectValue = _targets[_currentHelper.Parameters[i].GameObjectGUID].gameObject;
                            }
                        }
                    }
                    _currentHelper.Content = _currentContent;
                    _currentHelper.Target  = _currentTarget;
                    _currentHelper.Task    = StepHelperTask.Skip;
                    _currentHelper.OnInit();
                }
                else
                {
                    GlobalTools.LogError(string.Format("【步骤:{0}】的助手 {1} 丢失!", _currentStep + 1, _currentContent.Helper));
                }
            }
            //助手执行跳过,等待生命周期结束后销毁助手
            if (_currentHelper != null)
            {
                _currentHelper.Task = StepHelperTask.Skip;
                _currentHelper.OnSkip();
                if (_currentHelper.SkipLifeTime > 0)
                {
                    yield return(YieldInstructioner.GetWaitForSeconds(_currentHelper.SkipLifeTime / SkipMultiple));
                }
                _currentHelper.OnTermination();
                _currentHelper = null;
            }

            yield return(YieldInstructioner.GetWaitForSeconds(_currentContent.ElapseTime / SkipMultiple));

            yield return(WaitCoroutine(ChangeNextStep, 0));
        }