Exemple #1
0
        protected void MainUpdate(GameTime gameTime, KeyboardState KCurrent)
        {
            if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape))
            {
                if (ScriptProcessor.ActiveGame())
                {
                    if (!ButtonScripts.Paused)
                    {
                        ButtonScripts.Pause();
                    }
                    else
                    {
                        ButtonScripts.Unpause();
                    }
                }
                else
                {
                    ButtonScripts.Quit();
                }
            }
            if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.OemTilde) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.OemTilde))
            {
                if (!ConsoleOpen)
                {
                    ButtonScripts.OpenAndConstructConsole();
                    ConsoleOpen = true;
                }
                else
                {
                    ButtonScripts.CloseConsole();
                    ConsoleOpen = false;
                }
            }
            if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.H) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.H) && ScriptProcessor.ActiveGame())
            {
                ButtonScripts.RefreshUIHideState();
            }
            if (AutoCamera != null && LooseCamera)
            {
                if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.R) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.R))
                {
                    AutoCamera.CenterDefault();
                    AutoCamera.ResetZoom();
                }
                AutoCamera.MouseDragEnabled = KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F);
                if (!UpdateQueue.Contains(AutoCamera))
                {
                    UpdateQueue.Add(AutoCamera);
                }
            }
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed || ExitOut)
            {
                Exit();
            }
            if (((KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter) && !ConsoleOpen) || DoNextShifter) && AllowEnter)
            {
                DoNextShifter = false;
                Boolean Found = false;
                foreach (WorldEntity E in UpdateQueue)
                {
                    if (E is TextEntity && E.Name == "TEXT_MAIN")
                    {
                        if (((TextEntity)E).WrittenAll())
                        {
                            GlobalWorldState = "CONTINUE";
                        }
                        ((TextEntity)E).SkipWrite();
                        Found = true;
                        break;
                    }
                }
                if (!Found)
                {
                    GlobalWorldState = "CONTINUE";
                }
            }
            if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F11) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F11))
            {
                ToggleFullscreen();
            }
            if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up))
            {
                UpKeyPress?.Invoke();
            }
            if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
            {
                DownKeyPress?.Invoke();
            }
            LastKeyState = KCurrent;
            foreach (WorldEntity E in UpdateQueue)
            {
                E.Update();
            }
            foreach (WorldEntity E in DeleteQueue)
            {
                if (UpdateQueue.Contains(E))
                {
                    UpdateQueue.Remove(E);
                }
                if (RenderQueue.Contains(E))
                {
                    RenderQueue.Remove(E);
                }
                if (NonSerializables.Contains(E))
                {
                    NonSerializables.Remove(E);
                }
                E.ManualDispose();
            }
            DeleteQueue = new ArrayList();
            foreach (VoidDel V in RunQueue)
            {
                V();
            }
            RunQueue = new ArrayList();
            if (FadeoutAmount != -100)
            {
                if (MediaPlayer.Volume > 0)
                {
                    MediaPlayer.Volume -= FadeoutAmount;
                }
                else
                {
                    MediaPlayer.Volume = GlobalVolume;
                    if (QueuedSong != null)
                    {
                        MediaPlayer.Play(QueuedSong);
                    }
                    else
                    {
                        MediaPlayer.Stop();
                    }
                    QueuedSong    = null;
                    FadeoutAmount = -100;
                }
            }
            ArrayList RemSounds = new ArrayList();

            if (!(CaptureVolume is null) && CaptureVolume.Enabled)
            {
                if (CaptureVolume.Output() != LastCapturedVol)
                {
                    GlobalVolume = CaptureVolume.Output();
                }
                LastCapturedVol = CaptureVolume.Output();
            }
            foreach (SoundEffectInstance S in ActiveSounds)
            {
                if (S.State == SoundState.Stopped)
                {
                    RemSounds.Add(S);
                }
            }
            foreach (SoundEffectInstance RS in RemSounds)
            {
                ActiveSounds.Remove(RS);
            }
            if (!(CaptureTextrate is null) && CaptureTextrate.Enabled)
            {
                if (CaptureTextrate.Output() != LastCapturedText)
                {
                    TextEntity.TickWriteInterval = TextEntity.GetTicksFromSliderValue(CaptureTextrate.Output());
                    if (!(CaptureRateDisplay is null))
                    {
                        CaptureRateDisplay.Text = TextEntity.TickWriteInterval + (TextEntity.TickWriteInterval != 1 ? " milliseconds" : " millisecond");
                        CaptureRateDisplay.ReWrite();
                    }
                }
                LastCapturedText = CaptureTextrate.Output();
            }
            MouseState Current = Mouse.GetState();

            if (Current.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && LastMouseState.LeftButton != Microsoft.Xna.Framework.Input.ButtonState.Pressed && MouseLeftClick != null)
            {
                MouseLeftClick();
            }
            LastMouseState = Current;
            if (GlobalVoid != null)
            {
                GlobalVoid();
                GlobalVoid = null;
            }
        }