Example #1
0
        public void Update()
        {
            FrameProcessed = true;
            if (DataManager.Instance.Loading != DataManager.LoadMode.None)
            {
                for (int ii = 0; ii < 100; ii++)
                {
                    CoroutineManager.Instance.Update();
                    if (DataManager.Instance.Loading == DataManager.LoadMode.None)
                    {
                        break;
                    }
                    ForceReady();
                }
            }
            else
            {
                if (!Paused || AdvanceFrame)
                {
                    //if actions are ready for queue, get a new result
                    CoroutineManager.Instance.Update();

                    int speedFactor = 8;
                    speedFactor = (int)Math.Round(speedFactor * Math.Pow(2, (int)DebugSpeed));

                    FrameTick newElapsed = FrameTick.FromFrames(1) * speedFactor / 8;
                    Update(newElapsed);
                }
            }
        }
Example #2
0
        public void BGM(string newBGM, bool fade)
        {
            if (DataManager.Instance.Loading != DataManager.LoadMode.None)
            {
                return;
            }

            if (Song != newBGM || (Song == newBGM && NextSong != null && NextSong != newBGM))
            {
                if (String.IsNullOrEmpty(Song) || !fade)//if the current song is empty, or the game doesn't want to fade it
                {
                    //immediately start
                    MusicFadeTime = FrameTick.Zero;
                }
                else if (NextSong != null)
                {
                    //do nothing, and watch it tick down
                }
                else
                {
                    //otherwise, set up the tick-down
                    MusicFadeTime = FrameTick.FromFrames(MUSIC_FADE_TOTAL);
                }
                NextSong = newBGM;
            }
        }
Example #3
0
        public void Fanfare(string newSE)
        {
            if (DataManager.Instance.Loading != DataManager.LoadMode.None)
            {
                return;
            }
            if (Song == "" || NextSong == "")
            {
                SE(newSE);
                return;
            }

            if (String.IsNullOrEmpty(QueuedFanfare))          //assume no fanfares happen within the same period
            {
                if (CurrentFanfarePhase == FanfarePhase.None) //begin the brief fade out if playing music as normal
                {
                    CurrentFanfarePhase = FanfarePhase.PhaseOut;
                    FanfareTime         = FrameTick.FromFrames(FANFARE_FADE_START);
                    QueuedFanfare       = newSE;
                }
                else if (CurrentFanfarePhase == FanfarePhase.PhaseIn)//fade from the partial progress
                {
                    CurrentFanfarePhase = FanfarePhase.PhaseOut;
                    FanfareTime         = FrameTick.FromFrames((FANFARE_FADE_END - FanfareTime.DivOf(FANFARE_FADE_END)) * FANFARE_FADE_START / FANFARE_FADE_END);
                    QueuedFanfare       = newSE;
                }
            }
        }
Example #4
0
        public void Update(InputManager input)
        {
            if (!Text.Finished)
            {
                //if (input[FrameInput.InputType.Cancel] && (input.JustPressed(FrameInput.InputType.Confirm) || input.JustPressed(FrameInput.InputType.Start)))
                //{
                //    Text.CurrentCharIndex = Text.Text.Length;
                //    CurrentTextTime = new FrameTick();
                //    Pauses.Clear();
                //}
                //else
                //{
                TextPause textPause    = getCurrentTextPause();
                bool      continueText = false;
                if (textPause != null)
                {
                    if (textPause.Time > 0)
                    {
                        continueText = CurrentTextTime >= textPause.Time;
                    }
                    else
                    {
                        continueText = (input.JustPressed(FrameInput.InputType.Confirm) || input[FrameInput.InputType.Cancel]);
                    }
                }
                else
                {
                    continueText = CurrentTextTime >= FrameTick.FromFrames(TEXT_TIME);
                }

                if (continueText)
                {
                    CurrentTextTime = new FrameTick();
                    Text.CurrentCharIndex++;
                    if (Sound && Text.CurrentCharIndex % 3 == 0)
                    {
                        GameManager.Instance.SE("Menu/Speak");
                    }

                    if (textPause != null)    //remove last text pause
                    {
                        Pauses.RemoveAt(0);
                    }
                }
                //}
            }
            else
            {
                ProcessTextDone(input);
            }
        }
Example #5
0
        public TitleDialog(string message, bool fadeIn, int holdTime, Action action)
        {
            Visible     = true;
            this.action = action;
            FadeIn      = fadeIn;
            showing     = true;
            if (!FadeIn)
            {
                CurrentFadeTime = FrameTick.FromFrames(FADE_TIME);
            }

            HoldTime = holdTime;

            //message will contain pauses, which get parsed here.
            //and colors, which will get parsed by the text renderer

            Pauses = new List <TextPause>();
            int startIndex = 0;
            int tabIndex   = message.IndexOf("[pause=", startIndex, StringComparison.OrdinalIgnoreCase);

            while (tabIndex > -1)
            {
                int endIndex = message.IndexOf("]", tabIndex);
                if (endIndex == -1)
                {
                    break;
                }
                int param;
                if (Int32.TryParse(message.Substring(tabIndex + "[pause=".Length, endIndex - (tabIndex + "[pause=".Length)), out param))
                {
                    TextPause pause = new TextPause();
                    pause.LetterIndex = tabIndex;
                    pause.Time        = param;
                    message           = message.Remove(tabIndex, endIndex - tabIndex + "]".Length);
                    Pauses.Add(pause);

                    tabIndex = message.IndexOf("[pause=", startIndex, StringComparison.OrdinalIgnoreCase);
                }
                else
                {
                    break;
                }
            }
            string newMessage = message;

            Text = new DialogueText(newMessage, new Loc(GraphicsManager.ScreenWidth / 2, GraphicsManager.ScreenHeight / 2), GraphicsManager.ScreenWidth, TEXT_SPACE, true, FadeIn ? -1 : 0);
        }
Example #6
0
        public void Update(InputManager input)
        {
            if (!showing || CurrentFadeTime < FADE_TIME)
            {
                if (!showing && CurrentFadeTime <= 0)
                {
                    //close this
                    MenuManager.Instance.RemoveMenu();

                    //do what it wants
                    action();
                }
            }
            else if (!Text.Finished)
            {
                TextPause textPause    = getCurrentTextPause();
                bool      continueText = false;
                if (textPause != null)
                {
                    if (textPause.Time > 0)
                    {
                        continueText = CurrentTextTime >= textPause.Time;
                    }
                    else
                    {
                        continueText = (input.JustPressed(FrameInput.InputType.Confirm));
                    }
                }
                else
                {
                    continueText = CurrentTextTime >= FrameTick.FromFrames(TEXT_TIME);
                }

                if (continueText)
                {
                    CurrentTextTime = new FrameTick();
                    Text.CurrentCharIndex++;

                    if (textPause != null)//remove last text pause
                    {
                        Pauses.RemoveAt(0);
                    }
                }
            }
            else
            {
                bool exit = false;
                if (HoldTime > -1)
                {
                    if (CurrentTextTime >= HoldTime)
                    {
                        exit = true;
                    }
                }
                else
                {
                    if (input.JustPressed(FrameInput.InputType.Confirm) || input[FrameInput.InputType.Cancel])
                    {
                        exit = true;
                    }
                }

                if (exit)
                {
                    if (FadeIn)
                    {
                        showing = false;
                    }
                    else
                    {
                        //close this
                        MenuManager.Instance.RemoveMenu();

                        //do what it wants
                        action();
                    }
                }
            }
        }
Example #7
0
        public void Update(FrameTick elapsedTime)
        {
            GraphicsManager.TotalFrameTick += (ulong)elapsedTime.Ticks;

            //update music
            float musicFadeFraction = 1;

            if (NextSong != null)
            {
                MusicFadeTime -= elapsedTime;
                if (MusicFadeTime <= FrameTick.Zero)
                {
                    if (System.IO.File.Exists(DataManager.MUSIC_PATH + NextSong))
                    {
                        Song     = NextSong;
                        NextSong = null;
                        SoundManager.PlayBGM(DataManager.MUSIC_PATH + Song);
                    }
                    else
                    {
                        Song = "";
                        SoundManager.PlayBGM(Song);
                    }
                }
                else
                {
                    musicFadeFraction *= MusicFadeTime.FractionOf(MUSIC_FADE_TOTAL);
                }
            }
            if (CurrentFanfarePhase != FanfarePhase.None)
            {
                FanfareTime -= elapsedTime;
                if (CurrentFanfarePhase == FanfarePhase.PhaseOut)
                {
                    musicFadeFraction *= FanfareTime.FractionOf(FANFARE_FADE_START);
                    if (FanfareTime <= FrameTick.Zero)
                    {
                        int pauseFrames = 0;
                        if (!String.IsNullOrEmpty(QueuedFanfare) && System.IO.File.Exists(DataManager.SOUND_PATH + QueuedFanfare + ".ogg"))
                        {
                            pauseFrames = SoundManager.PlaySound(DataManager.SOUND_PATH + QueuedFanfare + ".ogg", 1) + FANFARE_WAIT_EXTRA;
                        }
                        CurrentFanfarePhase = FanfarePhase.Wait;
                        if (FanfareTime < pauseFrames)
                        {
                            FanfareTime = FrameTick.FromFrames(pauseFrames);
                        }
                        QueuedFanfare = null;
                    }
                }
                else if (CurrentFanfarePhase == FanfarePhase.Wait)
                {
                    musicFadeFraction *= 0;
                    if (FanfareTime <= FrameTick.Zero)
                    {
                        CurrentFanfarePhase = FanfarePhase.PhaseIn;
                        FanfareTime         = FrameTick.FromFrames(FANFARE_FADE_END);
                    }
                }
                else if (CurrentFanfarePhase == FanfarePhase.PhaseIn)
                {
                    musicFadeFraction *= (1f - FanfareTime.FractionOf(FANFARE_FADE_END));
                    if (FanfareTime <= FrameTick.Zero)
                    {
                        CurrentFanfarePhase = FanfarePhase.None;
                    }
                }
            }
            SoundManager.SetBGMVolume(musicFadeFraction);
            if (timeSinceError > 0)
            {
                timeSinceError--;
            }

            MenuManager.Instance.ProcessActions(elapsedTime);

            //keep border flash off by default
            MenuBase.BorderFlash = 0;

            CurrentScene.Update(elapsedTime);
        }
Example #8
0
 public void ForceReady()
 {
     Update(FrameTick.FromFrames(3600));
 }