Пример #1
0
        public override void Update(GameTime gameTime)
        {
            if (Pause)
            {
                return;
            }

            float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (State == ConversationState.None)
            {
                if (fade > 0)
                {
                    fade -= dt * fadeSpd;
                }
                return;
            }

            if (fade < 1)
            {
                fade += dt * fadeSpd;
                return;
            }

            if (_activeConversation.TypeOfConversation == ConversationType.Active)
            {
                if (GamePadApi.IsButtonClick(Buttons.A) || KeyboardAPI.IsKeyPressed(Keys.Enter))
                {
                    _activeConversation.Confirm();
                    return;
                }

                if (GamePadApi.IsButtonClick(Buttons.B) || KeyboardAPI.IsKeyPressed(Keys.Escape))
                {
                    _activeConversation.JumpToEnd();
                }
            }
            //fade = 0;
            _activeConversation.Update(dt);
            base.Update(gameTime);
        }
Пример #2
0
        public void Update(float dt)
        {
            if (_activeSnippit == -1)
            {
                return;
            }

            if (delay > 0)
            {
                delay -= dt;
                return;
            }

            if (_currentChar != _lastChar)
            {
                if (_chat.OnNextChar != null)
                {
                    _chat.OnNextChar(_currentChar);
                }
                _lastChar = _currentChar;
            }
            float spd = TextSpeed * dt;

            if (SpeedUpText)
            {
                spd *= 4f;
            }

            _textProgress += dt / ((float)_snippits[_activeSnippit].Text.Length / spd);

            if (_responces.Count > 0) //make sure we have responces
            {
                if (TypeOfConversation == ConversationType.Passive)
                {
                    throw new Exception("Cannot have a passive conversation with responces");
                }
                if (KeyboardAPI.IsKeyPressed(Keys.Left) || GamePadApi.DPadDirectionClicked(DPadDirection.Left) ||
                    GamePadApi.LeftThumbStickFlickLeft)
                {
                    if (_responceSelected > 0)
                    {
                        _responceSelected--;
                    }
                }

                if (KeyboardAPI.IsKeyPressed(Keys.Right) || GamePadApi.DPadDirectionClicked(DPadDirection.Right) ||
                    GamePadApi.LeftThumbStickFlickRight)
                {
                    if (_responceSelected < _responces.Count - 1)
                    {
                        _responceSelected++;
                    }
                }
            }

            if (_textProgress >= 1)
            {
                _flasher += dt;
                if (_flasher > 1)
                {
                    _flasher -= 2;
                }
            }

            if (_responces.Count <= 1 && _textProgress > 1)
            {
                if (TypeOfConversation == ConversationType.Passive)
                {
                    if (_snippits[_activeSnippit].Requirment != null)
                    {
                        if (_snippits[_activeSnippit].Requirment()) //check to see if requirment met
                        {
                            if (_snippits[_activeSnippit].Pause)
                            {
                                return;
                            }
                            Confirm();
                            return;
                        }
                    }
                    else
                    {
                        _autoEndTimer += dt;
                        if (_autoEndTimer >= 1)
                        {
                            if (_snippits[_activeSnippit].Pause)
                            {
                                return;
                            }
                            Confirm();
                            return;
                        }
                    }
                }

                if (_snippits[_activeSnippit].AutoEndSnippit) //if we are going to auto end a snippit
                {
                    _autoEndTimer += dt;
                    if (_autoEndTimer >= 1)
                    {
                        Confirm();
                    }
                }
            }
        }