Update() public method

public Update ( ) : void
return void
Exemplo n.º 1
0
    public void Update()
    {
        MessageLog.Update();
        if (CurrentServer != null)
        {
            if (Input.GetKeyDown("f8"))
            {
                uLink.Network.Disconnect();
            }
        }

        // Hide/show options
        if (Input.GetKeyDown(KeyCode.Escape) && !MessageLog.HasInputOpen)
        {
            ShowOptions = !ShowOptions;
        }

        if (CurrentServer == null)
        {
            TimeUntilRefresh -= Time.deltaTime;
            if (TimeUntilRefresh <= 0f)
            {
                TimeUntilRefresh += TimeBetweenRefreshes;
                ExternalServerList.Refresh();
            }

            OptionsMenu.ShouldDisplaySpectateButton = false;
        }

        // TODO this generates a lot of garbage, probably should be removed down the line...
        var sb = new StringBuilder();

        sb.AppendLine(PlayerScript.UnsafeAllEnabledPlayerScripts.Count + " PlayerScripts");
        sb.Append(PlayerPresence.UnsafeAllPlayerPresences.Count + " PlayerPresences");
        ScreenSpaceDebug.AddLineOnce(sb.ToString());

        for (int i = 0; i < PlayerScript.UnsafeAllEnabledPlayerScripts.Count; i++)
        {
            var character    = PlayerScript.UnsafeAllEnabledPlayerScripts[i];
            var presenceName = character.Possessor == null ? "null" : character.Possessor.Name;
            ScreenSpaceDebug.AddLineOnce("Character: " + character.name + " possessed by " + presenceName);
        }
        for (int i = 0; i < PlayerPresence.UnsafeAllPlayerPresences.Count; i++)
        {
            var presence      = PlayerPresence.UnsafeAllPlayerPresences[i];
            var characterName = presence.Possession == null ? "null" : presence.Possession.name;
            ScreenSpaceDebug.AddLineOnce("Presence: " + presence.Name + " possessing " + characterName);
        }

        OptionsMenu.Update();
        //Cursor.visible = !PlayerScript.lockMouse;
    }
Exemplo n.º 2
0
 static public void Update(GameTime gameTime, Game1 game)
 {
     if (game.gameState == Game1.GameState.running)
     {
         menuInGame.update(gameTime);
     }
     if (game.gameState == Game1.GameState.Options)
     {
         optionsMenu.Update(gameTime, game);
     }
     if (game.gameState == Game1.GameState.Menu)
     {
         menuPrincipal.update(gameTime, game);
     }
 }
Exemplo n.º 3
0
 static public void Update(GameTime gameTime, Map map, Game1 game, ContentManager content, Camera2D cam, hud Interface)
 {
     if (game.gameState == Game1.GameState.Menu)
     {
         menuPrincipal.update(gameTime, game);
         return;
     }
     if (game.gameState == Game1.GameState.Paused)
     {
         menuInGame.update(gameTime, game, content);
         return;
     }
     if (game.gameState == Game1.GameState.Options)
     {
         optionsMenu.Update(gameTime, game);
         return;
     }
     if (game.gameState == Game1.GameState.CharacterChoose)
     {
         characterChoose.Update(gameTime, game, content);
         return;
     }
     if (game.gameState == Game1.GameState.MapChoose)
     {
         mapChooser.update(gameTime, game, map);
         return;
     }
     if (game.gameState == Game1.GameState.OpeningCutScene)
     {
         OpeningCutScene.Update(gameTime, game);
         return;
     }
     if (game.gameState == Game1.GameState.Win)
     {
         winMenu.update(gameTime, game, content, cam);
         return;
     }
     if (game.gameState == Game1.GameState.CharacterChangeScene)
     {
         characterChanged.update(gameTime, Interface, game);
         return;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        ///
        /// Select - Layer5 added by Matthew Baldock
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //Allows game to exit.
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }


            //particleEngine.EmitterLocation = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
            particleEngine.Update(gameTime);

            //Update the current state
            switch (currentGameState)
            {
            case GameState.Login:
                login_menu.Update(gameTime);
                break;

            case GameState.MainMenu:
                main_menu.Update(gameTime);
                break;

            case GameState.Multiplayer:
                multiplayer_menu.Update(gameTime);
                break;

            case GameState.Options:
                options_menu.Update(gameTime);
                break;

            case GameState.Credits:
                credits_menu.Update(gameTime);
                break;

            case GameState.CreateLobby:
                create_lobby_menu.Update(gameTime);
                break;

            case GameState.LobbyBrowser:
                lobby_browser_menu.Update(gameTime);
                break;

            case GameState.Lobby:
                lobby_menu.Update(gameTime);
                break;

            case GameState.Playing:
                gameplayScreen.Update(gameTime);
                break;

            case GameState.Select:
                shipselectionScreen.update();
                break;

            case GameState.ControlMenu:
                control_menu.Update(gameTime);
                break;

            default:
                break;
            }

            base.Update(gameTime);
        }
Exemplo n.º 5
0
        public void Update(GameTime gt)
        {
            if (OptionsMenu.bIsRunning) //copied from gameprocessor
            {
                Utilities.Control.Player.PlayerController.Update(gt);
                OptionsMenu.Update(gt);
                return;
            }

            if (currentScreen == Screens.start)
            {
                if (currentStartScreen != StartScreens.loading)
                {
                    Utilities.Control.Player.PlayerController.Update(gt);
                }
            }
            else
            {
                Utilities.Control.Player.PlayerController.Update(gt);
            }



            switch (currentScreen)
            {
            case Screens.start:
                #region
                switch (currentStartScreen)
                {
                case StartScreens.main:
                    UpdateMain(gt);
                    break;

                case StartScreens.load:
                    break;

                case StartScreens.loading:
                    UpdateLoading(gt);
                    break;

                default:
                    break;
                }
                #endregion
                break;

            case Screens.load:
                #region
                if (lgs != null)
                {
                    lgs.Update(gt);
                }
                if (loadGameDataTimer != null)
                {
                    loadGameDataTimer.Tick(gt);
                    if (!loadGameDataTimer.IsActive())
                    {
                        loadGameDataTimer = null;
                    }
                }
                #endregion
                break;

            default:
                break;
            }
        }
Exemplo n.º 6
0
        protected override void Update(GameTime gameTime)
        {
#if !DEBUG
            if (!IsActive)
            {
                return;
            }
#endif

            if (_wantsToQuit)
            {
                Exit();
            }

            SteamAPI.RunCallbacks();

            GameTime = gameTime;
            GameUpdateCalled?.Invoke();

            InputSystem.Update();

            _frameRateTimer += gameTime.ElapsedGameTime.TotalMilliseconds;
            if (_frameRateTimer > 1000f)
            {
                FPS             = _totalFrames;
                _totalFrames    = 0;
                _frameRateTimer = 0;
            }

            IsMouseVisible = false;

            Cursor.Update();
            SoundtrackManager.Update();

            MessageBox.Update();
            if (MessageBox.IsActive)
            {
                return;
            }

            TextInputBox.Update();
            if (TextInputBox.IsActive)
            {
                return;
            }

            GameDebug.Update();
            if (GameDebug.IsTyping)
            {
                return;
            }

            PauseMenu.Update();
            OptionsMenu.Update();
            if (OptionsMenu.IsActive)
            {
                return;
            }
            if (PauseMenu.IsActive)
            {
                return;
            }

            Dialog.Update();

            Overlay.Update();
            KeyPopUp.Update();

            Player player = GameWorld.GetPlayers()[0];

            Session.Update();

            //Update the game based on what GameState it is
            switch (CurrentGameState)
            {
            case GameState.MainMenu:
                MainMenu.Update();
                if (GameWorld.TileArray != null && GameWorld.TileArray.Length != 0)
                {
                    goto case GameState.GameWorld;
                }
                break;

            case GameState.LoadingScreen:
                LoadingScreen.Update();

                if (!IsLoadingContent)
                {
                    CurrentGameState = _desiredGameState;
                }
                break;

            case GameState.GameWorld:
                if (IsLoadingContent)
                {
                    return;
                }
                if (GameWorld.IsOnDebug)
                {
                    break;
                }
                GameWorld.TotalUpdateTimer.Start();
                if (!TimeFreeze.IsTimeFrozen())
                {
                    GameWorld.UpdateWorld();
                }
                GameWorld.UpdateVisual();
                GameWorld.TotalUpdateTimer.Measure();


                if (StoryTracker.IsInStoryMode)
                {
                    StoryTracker.Update();
                }
                break;
            }

            base.Update(gameTime);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // Update all input
            Input.Update();

            switch (StateManager.GameState)
            {
            case StateManager.EGameState.MainMenu:
                m_mainMenu.Update();
                m_mainMenu.Hover();
                break;

            case StateManager.EGameState.Game:
                World.Update();
                break;

            case StateManager.EGameState.HowTo:
                m_howToMenu.Update();
                m_howToMenu.Hover();
                break;

            case StateManager.EGameState.Options:
                m_optionsMenu.Update();
                m_optionsMenu.Hover();
                m_optionsMenu.VolumeBar.Update();
                break;

            case StateManager.EGameState.Pause:
                m_pauseMenu.Update();
                m_pauseMenu.Hover();
                break;

            case StateManager.EGameState.LevelUp:
                m_levelUpMenu.Update();
                m_levelUpMenu.Hover();
                break;

            case StateManager.EGameState.RedLevelUp:
                Dungeon.MainPlayer.LevelUp("red");
                StateManager.SetState(StateManager.EGameState.Game);
                break;

            case StateManager.EGameState.GreenLevelUp:
                Dungeon.MainPlayer.LevelUp("green");
                StateManager.SetState(StateManager.EGameState.Game);
                break;

            case StateManager.EGameState.BlueLevelUp:
                Dungeon.MainPlayer.LevelUp("blue");
                StateManager.SetState(StateManager.EGameState.Game);
                break;

            case StateManager.EGameState.GameOver:
                m_gameOverMenu.Update();
                m_gameOverMenu.Hover();
                break;

            case StateManager.EGameState.Exit:
                Exit();
                break;
            }

            base.Update(gameTime);
        }
Exemplo n.º 8
0
    public void UpdateOnStart()
    {
        logo.Update();
        switch (state)
        {
        case StarMenu.MenuItemId.Start_Menu:
            textMenu.Update();

            if (ButtonManager.GetDown(ButtonManager.ButtonID.X, this))
            {
                StarMenu.MenuItemId nextState = (StarMenu.MenuItemId)(textMenu.menuIndex.Get());
                if (!hasSelectedSave)
                {
                    nextState++;
                }

                if (!hasSomeSave)
                {
                    if (nextState >= StarMenu.MenuItemId.Load_Game)
                    {
                        nextState++;
                    }
                }

                switch (nextState)
                {
                case StarMenu.MenuItemId.New_Game:
                    gameManager.NewGame();
                    break;

                case StarMenu.MenuItemId.Continue:
                    gameManager.LoadGame();
                    break;

                case StarMenu.MenuItemId.Exit:
                    Application.Quit();
                    break;

                default:
                    ChangeState(nextState);
                    break;
                }
            }

            break;

        case StarMenu.MenuItemId.Options:
            options.Update();

            if (ButtonManager.GetDown(ButtonManager.ButtonID.X, this))
            {
                for (int i = 0; i < gameManager.menuJson.optionsMenu.Length; i++)
                {
                    for (int j = 0; j < gameManager.menuJson.optionsMenu[i].items.Length; j++)
                    {
                        switch (gameManager.menuJson.optionsMenu[i].items[j].type)
                        {
                        case MenuJson.OptionMenuTab.OptionsMenuItem.Type.Special:
                            switch (gameManager.menuJson.optionsMenu[i].items[j].special)
                            {
                            case MenuJson.OptionMenuTab.OptionsMenuItem.SpecialType.Language:
                                break;

                            case MenuJson.OptionMenuTab.OptionsMenuItem.SpecialType.TitleFont:
                                gameManager.saveJson.config.titleFontIndex = gameManager.menuJson.optionsMenu[i].items[j].comboSelected.Get();
                                break;

                            case MenuJson.OptionMenuTab.OptionsMenuItem.SpecialType.TextFont:
                                gameManager.saveJson.config.textFontIndex = gameManager.menuJson.optionsMenu[i].items[j].comboSelected.Get();
                                break;

                            case MenuJson.OptionMenuTab.OptionsMenuItem.SpecialType.ComboTexture:
                                ButtonManager.SetControllerTexture((ButtonManager.Controll)gameManager.menuJson.optionsMenu[i].items[j].comboSelected.Get());
                                break;
                            }
                            break;
                        }
                    }
                }
                gameManager.ChangeLanguage(gameManager.languagues[gameManager.menuJson.optionsMenu[0].items[0].comboSelected.Get()].name);
                ChangeState(StarMenu.MenuItemId.Start_Menu);
            }

            break;

        case StarMenu.MenuItemId.Load_Game:
            loadZone.Update();
            load.Update();

            if (ButtonManager.GetDown(ButtonManager.ButtonID.TRIANGLE, this))
            {
                gameManager.RemoveGame(load.menuIndex.Get());
                if (gameManager.saveJson.saves.Length == 0)
                {
                    ChangeState(StarMenu.MenuItemId.Start_Menu);
                }
                load.Init();
            }
            else if (ButtonManager.GetDown(ButtonManager.ButtonID.X, this))
            {
                gameManager.LoadGame(load.menuIndex.Get());
            }
            break;

        default:
            ChangeState(StarMenu.MenuItemId.Start_Menu);
            break;
        }

        if (ButtonManager.GetDown(ButtonManager.ButtonID.CIRCLE, this))
        {
            ChangeState(StarMenu.MenuItemId.Start_Menu);
        }
    }