Esempio n. 1
0
        /// <summary>
        /// 跳过到指定步骤(立即模式)
        /// </summary>
        /// <param name="index">步骤索引</param>
        private void SkipStepImmediateCoroutine(int index)
        {
            _executing       = true;
            _skipTargetIndex = index;

            CurrentTask = StepHelperTask.SkipImmediate;

            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.SkipImmediate);
                }

                _currentContent.SkipImmediate();

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

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

                _currentStepIndex += 1;
            }

            BeginCurrentStep();
        }
Esempio n. 2
0
        /// <summary>
        /// 跳过当前步骤(立即模式)
        /// </summary>
        private void SkipCurrentStepImmediateCoroutine()
        {
            _executing = true;

            CurrentTask = StepHelperTask.SkipImmediate;

            //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.SkipImmediate);
            }

            _currentContent.SkipImmediate();

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

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

            ChangeNextStep();
        }
Esempio n. 3
0
        /// <summary>
        /// 跳过到指定步骤(立即模式)
        /// </summary>
        /// <param name="index">步骤索引</param>
        private void SkipStepImmediateCoroutine(int index)
        {
            _executing       = true;
            _skipTargetIndex = index;

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

                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 = _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.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;
                }

                _currentStepIndex += 1;
            }

            BeginCurrentStep();
        }