Example #1
0
        /// <summary>
        /// 跳过当前步骤
        /// </summary>
        private IEnumerator SkipCurrentStepCoroutine()
        {
            _executing = true;

            CurrentTask = StepHelperTask.Skip;

            //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)
            {
                _currentHelper = CreateHelper(_currentContent, StepHelperTask.Skip);
            }

            _currentContent.Skip();

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

            float elapseTime = _currentContent.Instant ? 0 : (_currentHelper != null ? _currentHelper.ElapseTime : _currentContent.ElapseTime);

            //助手执行跳过,等待生命周期结束后销毁助手
            if (_currentHelper != null)
            {
                _currentHelper.Task = StepHelperTask.Skip;
                _currentHelper.OnSkip();
                if (_currentHelper.SkipLifeTime > 0)
                {
                    yield return(YieldInstructioner.GetWaitForSeconds(_currentHelper.SkipLifeTime));
                }
                _currentHelper.OnTermination();
                _currentHelper = null;
            }

            _waitCoroutine = Main.Current.StartCoroutine(WaitCoroutine(ChangeNextStep, elapseTime));
        }
Example #2
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();
        }
Example #3
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));
        }
Example #4
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();
        }
Example #5
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));
        }
Example #6
0
        /// <summary>
        /// 跳过到指定步骤
        /// </summary>
        /// <param name="index">步骤索引</param>
        private IEnumerator SkipStepCoroutine(int index)
        {
            _executing       = true;
            _skipTargetIndex = index;

            CurrentTask = StepHelperTask.Skip;

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

                //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)
                {
                    _currentHelper = CreateHelper(_currentContent, StepHelperTask.Skip);
                }

                _currentContent.Skip();

                SkipStepEvent?.Invoke(_currentContent, _currentContent.IsEnable && _currentContent.IsEnableRunTime);

                float elapseTime = _currentContent.Instant ? 0 : (_currentHelper != null ? _currentHelper.ElapseTime : _currentContent.ElapseTime);

                //助手执行跳过,等待生命周期结束后销毁助手
                if (_currentHelper != null)
                {
                    _currentHelper.Task = StepHelperTask.Skip;
                    _currentHelper.OnSkip();
                    if (_currentHelper.SkipLifeTime > 0)
                    {
                        yield return(YieldInstructioner.GetWaitForSeconds(_currentHelper.SkipLifeTime));
                    }
                    _currentHelper.OnTermination();
                    _currentHelper = null;
                }

                yield return(YieldInstructioner.GetWaitForSeconds(elapseTime));

                _currentStepIndex += 1;
            }

            SkipStepDoneEvent?.Invoke();

            _waitCoroutine = Main.Current.StartCoroutine(WaitCoroutine(BeginCurrentStep, 0));
        }