Exemplo n.º 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));
        }
Exemplo n.º 2
0
        private IEnumerator SkipCurrentStepCoroutine()
        {
            _executing = true;
            _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));

            ChangeNextStep();
        }
Exemplo n.º 3
0
        //跳过当前步骤
        private IEnumerator SkipCurrentStepCoroutine()
        {
            _executing = true;
            _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 = _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.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;
            }

            _waitCoroutine = Main.Current.StartCoroutine(WaitCoroutine(ChangeNextStep, _currentContent.ElapseTime / SkipMultiple));
        }