Exemplo n.º 1
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));
        }
Exemplo n.º 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();
        }
Exemplo n.º 3
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, _stepContentEnables.ContainsKey(_currentContent.GUID) ? _stepContentEnables[_currentContent.GUID] : false);

                //助手执行跳过,等待生命周期结束后销毁助手
                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));
        }