コード例 #1
0
        public void Resume()
        {
            if (!HasStarted)
            {
                throw new System.InvalidOperationException("Can't resume an uninitiated State Machine, call Start() first.");
            }

            if (IsRunning)
            {
                return;
            }

            if (CurrentCoroutine != null)
            {
                if (!CurrentCoroutine.HasEnded)
                {
                    CurrentCoroutine.Resume();

                    if (!Coroutines.Instance.Has(CurrentCoroutine))
                    {
                        Coroutines.Instance.Start(CurrentCoroutine);
                    }
                }
                else
                {
                    CurrentCoroutine = null;
                }
            }

            IsRunning = true;
        }
コード例 #2
0
        public void Pause()
        {
            if (!HasStarted)
            {
                throw new System.InvalidOperationException("Can't pause an uninitiated State Machine, call Start() first.");
            }

            if (!IsRunning)
            {
                return;
            }

            if (CurrentCoroutine != null)
            {
                if (CurrentCoroutine.HasEnded)
                {
                    CurrentCoroutine = null;
                }
                else
                {
                    CurrentCoroutine.Pause();
                }
            }

            IsRunning = false;
        }
コード例 #3
0
        private void UpdateState()
        {
            ProcessStateLeave(CurrentState.OnLeave);

            CurrentCoroutine?.Stop();

            PreviousState = CurrentState;
            CurrentState  = NextState;
            NextState     = null;

            if (CurrentState == null)
            {
                return;
            }

            ProcessStateEnter(CurrentState.OnEnter);
            CurrentCoroutine = Coroutines.Instance.Start(ProcessStateUpdate(CurrentState.OnUpdate));
        }
コード例 #4
0
        public void Stop()
        {
            if (!HasStarted)
            {
                return;
            }

            NextState = PreviousState = CurrentState = StartState = null;

            if (CurrentCoroutine != null)
            {
                Coroutines.Instance.Remove(CurrentCoroutine);
                CurrentCoroutine.Stop();
                CurrentCoroutine = null;
            }

            HasStarted = IsRunning = false;
        }
コード例 #5
0
        public override void Update(DwarfTime gameTime)
        {
            CompositeLibrary.Update();
            MainWindow.LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2);
            Input.Update();
            GUI.Update(gameTime);

            if (CurrentAction != null)
            {
                if (CurrentCoroutine == null)
                {
                    CurrentCoroutine  = CurrentAction.Action();
                    CurrentEnumerator = CurrentCoroutine.GetEnumerator();
                }

                if (CurrentCoroutine != null)
                {
                    SpeechNode node = CurrentEnumerator.Current;

                    if (node != null)
                    {
                        Transition(node);
                        CurrentCoroutine = null;
                        CurrentAction    = null;
                    }
                    else
                    {
                        if (!CurrentEnumerator.MoveNext())
                        {
                            CurrentCoroutine  = null;
                            CurrentAction     = null;
                            CurrentEnumerator = null;
                            Transition(DialougeTree);
                        }
                    }
                }
            }

            base.Update(gameTime);
        }