public void ChangeScene(IGameScreen next)
 {
     if (_activeScene != next)
     {
         _nextScene = next;
     }
 }
Exemple #2
0
        private void ShowGameScreen(IGameScreen NewGameScreen, GameScreenSetup Data, bool RootScreen)
        {
            if (RootScreen)
            {
                while (MainArea.Children.Count > 0)
                {
                    MainArea.Children.RemoveAt(0);
                }

                OpenScreens.Clear();
            }
            else
            {
                (CurrentScreen as UIElement).Visibility = Visibility.Collapsed;
            }


            NewGameScreen.SetupGameScreenData(Data);
            NewGameScreen.SetupData.Parent = this;
            MainArea.Children.Add((UIElement)NewGameScreen);

            OpenScreens.Add(NewGameScreen);
            Headings();
            CreateButtons();
        }
Exemple #3
0
 public void Push(IGameScreen menu)
 {
     lock (_menus)
     {
         _menus.Push(menu);
     }
 }
Exemple #4
0
 public static void AddGameScreen(IGameScreen gameScreen)
 {
     if (gameScreen != null)
     {
         gameScreens.Push(gameScreen);
     }
 }
Exemple #5
0
 public void PushScreen(IGameScreen screen)
 {
     lock (_screens)
     {
         _screens.Push(screen);
     }
 }
        public void ChangeScreen(IGameScreen screen)
        {
            RemoveAllScreens();
            m_gameScreens.Add(screen);

            screen.Init(m_contentManager, m_screenBounds);
        }
Exemple #7
0
 public DungeonEntrance(IGameScreen screenToLoad, ScreenManager screenManager, Texture2D texture, int width, int height, Vector2 position, float rotation = 0, Rectangle source = default(Rectangle))
     : base(texture, width, height, position, rotation, source)
 {
     this.screenManager = screenManager;
     this.screenToLoad  = screenToLoad;
     player             = EntityManager.Instance.GetPlayer() as Player;
 }
Exemple #8
0
        public void ChangeScreen(IGameScreen screen)
        {
            RemoveAllScreens();

            gameScreen.Add(screen);

            screen.Initialize(contentManager);
        }
        public void ChangeScreen(IGameScreen screen)
        {
            RemoveAllScreens();

            m_gameScreens.Add(screen);

            screen.Init(m_contentManager);
        }
Exemple #10
0
 void IScreenListener.OnUpdate(IGameScreen gameScreen, float deltaTime)
 {
     if (!gameScreen.IsOpened)
     {
         return;
     }
     OnUpdate(deltaTime);
 }
Exemple #11
0
        public LoadRaceScreen(IGameScreen parent)
        {
            Parent          = parent;
            _loadingTexture = new PixFile("LOADSCRN.pix").PixMaps[0].Texture;

            //_loadRaceThread = new Thread(LoadRaceThreadProc);
            //_loadRaceThread.Start();
        }
        public void TransitionTo(IGameScreen gameScreen)
        {
            if (gameScreen == null) throw new ArgumentNullException("gameScreen");
            if (gameScreen == this.CurrentScreen) throw new ArgumentException("Cannot transition to the current screen.");

            this.Dismiss(this.CurrentScreen);
            this.Present(gameScreen);
        }
Exemple #13
0
        public LoadRaceScreen(IGameScreen parent)
        {
            Parent = parent;
            _loadingTexture = new PixFile("LOADSCRN.pix").PixMaps[0].Texture;

            //_loadRaceThread = new Thread(LoadRaceThreadProc);
            //_loadRaceThread.Start();
        }
Exemple #14
0
 public void Enter(IGameScreen previous)
 {
     if (previous != game.LevelSelectScreen && previous != game.CreditsScreen)
     {
         MediaPlayer.Play(Music);
         MediaPlayer.IsRepeating = true;
     }
 }
        }         // InGame

        /// <summary>
        /// Add game screen, which will be used until we quit it or add
        /// another game screen on top of it.
        /// </summary>
        /// <param name="newGameScreen">New game screen</param>
        public void AddGameScreen(IGameScreen newGameScreen)
        {
            gameScreens.Push(newGameScreen);

            inGame                 = newGameScreen.GetType() == typeof(Mission);
            camera.InGame          = inGame;
            Sound.CurrentMusicMode = inGame;
        }         // AddGameScreen(newGameScreen)
        /// <summary>
        /// Add game screen
        /// </summary>
        /// <param name="gameScreen">Game screen</param>
        public static void AddGameScreen(IGameScreen gameScreen)
        {
            // Play sound for screen click
            Sound.Play(Sound.Sounds.ScreenClick);

            // Add the game screen
            gameScreens.Push(gameScreen);
        }
Exemple #17
0
 public BaseMenuScreen(IGameScreen parent)
 {
     Parent = parent;
     Viewport viewport = Engine.Device.Viewport;
     _rect = new Rectangle(0, 0, Engine.Device.Viewport.Width, Engine.Device.Viewport.Height);
     Engine.Camera = new SimpleCamera();
     _font = Engine.ContentManager.Load<SpriteFont>("content/Fontana");
 }
 public void Leave(IGameScreen next)
 {
     if (next != game.MenuScreen)
     {
         MediaPlayer.Stop();
     }
     tinyFire.Clear();
 }
 public void Enter(IGameScreen previous)
 {
     if (previous != game.MenuScreen)
     {
         MediaPlayer.Play(menu.Music);
         MediaPlayer.IsRepeating = true;
     }
 }
Exemple #20
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            FullLoad();

            BuildScreenList();
            screen = screenList.Current;
        }
        public void AddScreen(GameScreenType screenType, IGameScreen gameScreen)
        {
            if (this.Contains(screenType))
            {
                throw new GameScreenTypeException("gameScreen", "The screen already exists.");
            }

            this.screens[screenType] = gameScreen;
        }
        private static void Run(Deck deck, Hero hero1, Hero hero2, IGameScreen gameScreen)
        {
            while (true)
            {
                TakeTurn(hero1, hero2, deck, gameScreen);

                TakeTurn(hero2, hero1, deck, gameScreen);
            }
        }
Exemple #23
0
        public BaseMenuScreen(IGameScreen parent)
        {
            Parent = parent;
            Viewport viewport = Engine.Device.Viewport;

            _rect         = new Rectangle(0, 0, Engine.Device.Viewport.Width, Engine.Device.Viewport.Height);
            Engine.Camera = new SimpleCamera();
            _font         = Engine.ContentManager.Load <SpriteFont>("content/Fontana");
        }
Exemple #24
0
 public GameOver(Image canvas, Bitmap prevState, Game game, IGameScreen screen)
 {
     _canvas    = canvas;
     _prevState = prevState;
     _game      = game;
     _screen    = screen;
     _buffer    = new Bitmap(180, 360);
     Redraw();
 }
Exemple #25
0
 public void Leave(IGameScreen next)
 {
     if (next != game.LevelSelectScreen && next != game.CreditsScreen)
     {
         MediaPlayer.Stop();
     }
     fire.Clear();
     tinyFire.Clear();
 }
Exemple #26
0
        public void ChangeScreen(IGameScreen screen)
        {
            if (this.screen != null)
            {
                this.screen.Dispose();
            }

            this.screen = screen;
        }
Exemple #27
0
        public void ChangeScreen(IGameScreen screen)
        {
            Stopped = true;

            GameScreen = screen;
            GameScreen.Init(this.Content);

            Stopped = false;
        }
Exemple #28
0
        public void Init(ContentManager content, SpriteBatch spriteBatch, GraphicsDeviceManager graphics, Game game)
        {
            this.GraphicsSettings     = new GraphicsSettings();
            GraphicsSettings.Vignette = true;
            this.Stopped               = false;
            this.ThisGame              = game;
            this.Content               = content;
            this.SpriteBatch           = spriteBatch;
            this.GraphicsDeviceManager = graphics;

            // load essential assets and sounds.
            GlobalAssets.SoundEffects.Add("torch", Content.Load <SoundEffect>("sound/torch"));
            GlobalAssets.SoundEffects.Add("doorOpen", Content.Load <SoundEffect>("sound/door_open"));
            GlobalAssets.SoundEffects.Add("doorClose", Content.Load <SoundEffect>("sound/door_close"));
            GlobalAssets.Arial12 = Content.Load <SpriteFont>("arial12");
            GlobalAssets.Arial24 = Content.Load <SpriteFont>("arial24");
            GlobalAssets.Arial18 = Content.Load <SpriteFont>("arial18");
            GlobalAssets.Arsenal = Content.Load <SpriteFont>("Arsenal");
            Black            = Content.Load <Texture2D>("black");
            pausedMenuTitle  = Content.Load <Texture2D>("invTitle");
            controllerCursor = Content.Load <Texture2D>("ui/controller_mouse");
            GlobalAssets.SpeechDialogTexture = Content.Load <Texture2D>("ui/speech_dialog");

            GameScreen = new SGame.Screens.MenuGameScreen();
            GameScreen.Init(this.Content);

            GameManager.Game.ConsoleInterpreter.RegisterCommand("fullscreen", (o) =>
            {
                try
                {
                    GraphicsDeviceManager.IsFullScreen = bool.Parse(o[0]);
                    GraphicsDeviceManager.ApplyChanges();
                    return("Set fullscreen mode to " + o[0]);
                }
                catch
                {
                    return(o[0] + " is not a valid input.");
                }
            });
            GameManager.Game.ConsoleInterpreter.RegisterCommand("res", (o) =>
            {
                try
                {
                    GraphicsDeviceManager.PreferredBackBufferWidth  = int.Parse(o[0]);
                    GraphicsDeviceManager.PreferredBackBufferHeight = int.Parse(o[1]);
                    GraphicsDeviceManager.ApplyChanges();
                    return("Set res to " + o[0] + "x" + o[1]);
                }
                catch
                {
                    return("Not a valid input.");
                }
            });

            this.ControllerCursorPos = ScreenSize / 2;
        }
Exemple #29
0
 public void RestartGame()
 {
     if (ActualScreen != null)
     {
         ActualScreen.Hide();
     }
     GameState = GameStateEnum.CHOOSE_SCENARIO;
     ActualScreen = new ChooseScenarioScreen();
     ActualScreen.Show();
 }
        public void AddPopup(IGameScreen screen)
        {
            if (this.Current != null)
            {
                this.Current.State = GameScreenState.Paused;
            }

            screen.State = GameScreenState.Activated;
            this.AddScreen(screen);
        }
Exemple #31
0
        public void LoadScreen(IGameScreen screen)
        {
            _activeScreen?.UnloadContent();
            _activeScreen?.Dispose();

            screen.ScreenManager = this;
            screen.Initialize();
            screen.LoadContent();
            _activeScreen = screen;
        }
        public ScreenManagerComponent(Game game, IGameScreen initalGameScreen, BeeWorldManager beeWorldManager)
            : base(game)
        {
            if (initalGameScreen == null) throw new ArgumentNullException("initialGameScreen");
            if (beeWorldManager == null) throw new ArgumentNullException("beeWorldManager");

            this.mBeeWorldManager = beeWorldManager;

            this.Present(initalGameScreen);
        }
Exemple #33
0
        public void PushScreen(IGameScreen screen)
        {
            screen.ScreenManager = this;
            activeGameScreens.Add(screen);

            screen.Initialize(contentManager);

            Mouse.SetCursor(screen.CursorInfo.CursorTexture);
            Game.IsMouseVisible = screen.CursorInfo.ShowCursor;
        }
        public void AddExclusive(IGameScreen screen)
        {
            if (this.Current != null)
            {
                this.Current.State = GameScreenState.Deactivated;
            }

            screen.State = GameScreenState.Activated;
            this.AddScreen(screen);
        }
        public void Push(IGameScreen gameScreen)
        {
            if (_gameScreens.Count > 0)
            {
                ActiveGameScreen.Deactivate();
            }
            _gameScreens.Push(gameScreen);

            gameScreen.Activate();
        }
Exemple #36
0
        public void PushScreen(IGameScreen screen)
        {
            if (!IsScreenListEmpty)
            {
                var currentScreen = GetCurrentSreen();
                currentScreen.Pause();
            }

            _gameScreens.Add(screen);
            screen.Init(_contentManager);
        }
Exemple #37
0
 public void Switch(IGameScreen newScreen, double delay = 1000.0d)
 {
     newScreen.LoadContent(ContentManager);
     lastScreen = currentScreen;
     currentScreen = newScreen;
     lastAlpha = 1.0f;
     currentAlpha = 0.0f;
     delayTime = delay;
     delayCounter = 0.0d;
     transition = true;
 }
Exemple #38
0
        protected override void Initialize()
        {
            Screen = new GamePlayScreen(this, TouchPanel.GetState().IsConnected ? (IInputControl) new TouchControl() : (IInputControl) new MouseControl());

            IsMouseVisible = true;

            SpriteBatch = new SpriteBatch(GraphicsDevice);
            Screen.Initialize();

            base.Initialize();
        }
Exemple #39
0
        public void NumOfHeroesChoosen(NumOfHeroesChoosenEvent sourceEvent)
        {
            if (ActualScreen != null)
            {
                ActualScreen.Hide();
            }

            NumOfHeroes = sourceEvent.NumOfHeroes;
            GameState = GameStateEnum.PICK_HEROES;
            ActualScreen = new ChooseHerosScreen(NumOfHeroes);
            ActualScreen.Show();
        }
        public void Push(IGameScreen gameScreen)
        {
            if (_gameScreens.Count > 0)
            {
                ActiveGameScreen.Deactivate();
            }
            _gameScreens.Push(gameScreen);

            gameScreen.Activate();


        }
Exemple #41
0
        public void ScenarioChoosen(ScenarioChoosenEvent sourceEvent)
        {
            if (ActualScreen != null)
            {
                ActualScreen.Hide();
            }

            GameplayProgress.Instance.Scenario = sourceEvent.SelectedScenario;
            GameState = GameStateEnum.CHOOSE_NUM_OF_HEROES;
            ActualScreen = new ChooseNumberOfHeroesScreen();
            ActualScreen.Show();
        }
        public IGameScreen Pop()
        {
            IGameScreen poppedGameScreen = _gameScreens.Pop();

            poppedGameScreen.Deactivate();

            if (_gameScreens.Count > 0)
            {
                ActiveGameScreen.Activate();
            }

            return(poppedGameScreen);
        }
Exemple #43
0
        public PlayGameScreen(IGameScreen parent)
        {
            Parent = parent;
            GC.Collect();

            _race = new Race(GameVars.BasePath + "races\\" + GameVars.SelectedRaceInfo.RaceFilename, GameVars.SelectedCarFileName);

            _modes.Add(new StandardGameMode());
            _modes.Add(new FlyMode());
            _modes.Add(new OpponentEditMode());
            _modes.Add(new PedEditMode());
            GameMode.Current = _modes[_currentEditMode];
        }
Exemple #44
0
        public PlayGameScreen(IGameScreen parent)
        {
            Parent = parent;
            GC.Collect();

            _race = new Race(GameVars.BasePath + "races\\" + GameVars.SelectedRaceInfo.RaceFilename, GameVars.SelectedCarFileName);

            _modes.Add(new StandardGameMode());
            _modes.Add(new FlyMode());
            _modes.Add(new OpponentEditMode());
            _modes.Add(new PedEditMode());
            GameMode.Current = _modes[_currentEditMode];
        }
        private void AddScreen(IGameScreen screen)
        {
            if (!this.SaveScreen)
            {
                this.RemoveScreen(screen);
            }

            this.Screens.Add(screen);
        }
 public void AddImmediately(IGameScreen screen)
 {
     this.AddScreen(screen);
 }
Exemple #47
0
        public override void Update(GameTime gameTime)
        {
            input.Update();

            if (currentScreen != _prevFrameScreen) {
                DefineGesturesForCurrentScreen();

                if (input.TouchState.Count > 0)
                    waitForRelease = true;

                // Don't allow any gestures generated on previous screen to be handled by the new one
                while (input.Gestures.Count > 0)
                    input.Gestures.Clear();

                if (currentScreen == GameScreen.MainMenuScreen) {
                    GameInProgress = false;
                    Option = 0;
                    UFOsManager.Instance.Reset();
                }

                _prevFrameScreen = currentScreen;
            }

            HandleInput(gameTime);

            if (currentScreen == GameScreen.GameplayScreen) {
                if (StarShip.ShipState == ShipState.Destroyed) {
                    currentScreen = GameScreen.GameOverScreen;
                    GameInProgress = false;
                    DelayStart = Environment.TickCount;
                    SoundManager.Instance.Play(InvasionGame.gameOverSoundEffect);
                }
            }

            StarShip.Update(gameTime);

            TickLast = Environment.TickCount;
        }
        public IGameScreen Switch(IGameScreen screen, GameScreenModality modality)
        {
            int screenCount = this.gameScreens.Count;

            if (screenCount == 0)
            {
                Push(screen, modality);
                return null;
            }

            int lastScreenIndex = screenCount - 1;
            KeyValuePair<IGameScreen, GameScreenModality> old = this.gameScreens[lastScreenIndex];
            IGameScreen previousScreen = old.Key;

            // Notify the previous screen that it's being left and kill it if desired
            previousScreen.Leave();
            DisposeIfSupportedAndDesired(previousScreen);

            // If the switched-to screen is exclusive, we need to clear the update
            // and draw lists. If not, depending on whether the previous screen was
            // a popup screen, we might have to
            if (old.Value == GameScreenModality.Popup)
            {
                RemoveFromUpdateableAndDrawableList(previousScreen);
            }
            else
            {
                this.updateableScreens.Clear();
                this.drawableScreens.Clear();
            }

            // Now swap out the screen and put it in the update and draw lists. If we're
            // switching from an exclusive to a pop-up screen, the draw and update lists need
            // to be rebuilt.
            var newScreen = new KeyValuePair<IGameScreen, GameScreenModality>(screen, modality);
            this.gameScreens[lastScreenIndex] = newScreen;
            if (old.Value == GameScreenModality.Exclusive && modality == GameScreenModality.Popup)
            {
                RebuildUpdateableAndDrawableListRecursively(lastScreenIndex);
            }
            else
            {
                AppendToUpdateableAndDrawableList(screen);
            }

            // Let the screen know that it has been entered
            screen.Enter();

            return previousScreen;
        }
 public IGameScreen Switch(IGameScreen screen)
 {
     return Switch(screen, GameScreenModality.Exclusive);
 }
Exemple #50
0
        public static void SetupNewGame()
        {
            GameInProgress = true;

            Level = 0;

            StarShip.Reset();

            InvasionGame.Scoreboard.Score = 0;

            DelayStart = Environment.TickCount;
            currentScreen = InitNextLevel(Level++, StarShip);
        }
        /// <summary>
        /// Add game screen, which will be used until we quit it or add
        /// another game screen on top of it.
        /// </summary>
        /// <param name="newGameScreen">New game screen</param>
        public void AddGameScreen(IGameScreen newGameScreen)
        {
            gameScreens.Push(newGameScreen);

            inGame = newGameScreen.GetType() == typeof(Mission);
            camera.InGame = inGame;
            Sound.CurrentMusicMode = inGame;
        }
 public void RemoveScreen(IGameScreen screen)
 {
     for (int i = 0; i < this.Screens.Count; )
     {
         if (this.Screens[i].Name == screen.Name)
         {
             this.Screens.RemoveAt(i);
         }
         else
         {
             ++i;
         }
     }
 }
Exemple #53
0
        public void Update(GameTime gameTime)
        {
            if (delayCounter < 0.0d)
            {

            }
            else if (delayCounter < delayTime)
            {
                float diff = (float)((1.0d / delayTime) * gameTime.ElapsedGameTime.TotalMilliseconds);
                lastAlpha -= diff;
                currentAlpha += diff;
                delayCounter += gameTime.ElapsedGameTime.TotalMilliseconds;
                transition = true;
            }
            else
            {
                delayCounter = -1.0d;
                lastScreen.Remove();
                lastScreen = null;
                transition = false;
            }
            currentScreen.Update(gameTime);
            currentScreen.InjectInput(Keyboard.GetState(), Mouse.GetState());
        }
 private void DisposeIfSupportedAndDesired(IGameScreen screen)
 {
     if (this.disposeDroppedScreens)
     {
         var disposable = screen as IDisposable;
         if (disposable != null)
         {
             disposable.Dispose();
         }
     }
 }
        public void Push(IGameScreen screen, GameScreenModality modality)
        {
            Pause();

            // If this game screen is modal, take all game screens that came before it
            // from the draw and update lists
            if (modality == GameScreenModality.Exclusive)
            {
                this.drawableScreens.Clear();
                this.updateableScreens.Clear();
            }

            // Add the new screen to the update and draw lists if it implements
            // the required interfaces
            this.gameScreens.Add(new KeyValuePair<IGameScreen, GameScreenModality>(screen, modality));
            AppendToUpdateableAndDrawableList(screen);

            // Screen is set, now try to enter it
            #if DEBUG
            screen.Enter();
            #else
            try
            {
                screen.Enter();
            }
            catch (Exception)
            {
                Pop();
                throw;
            }
            #endif
        }
        private void AppendToUpdateableAndDrawableList(IGameScreen screen)
        {
            IUpdateable updateable = screen as IUpdateable;
            if (updateable != null)
            {
                this.updateableScreens.Add(updateable);
            }

            IDrawable drawable = screen as IDrawable;
            if (drawable != null)
            {
                this.drawableScreens.Add(drawable);
            }
        }
        /// <summary>
        /// Add game screen
        /// </summary>
        /// <param name="gameScreen">Game screen</param>
        public static void AddGameScreen(IGameScreen gameScreen)
        {
            // Play sound for screen click
            Sound.Play(Sound.Sounds.ScreenClick);

            // Add the game screen
            gameScreens.Push(gameScreen);
        }
Exemple #58
0
 public void SetScreen(IGameScreen screen)
 {
     currentScreen = screen;
 }
        private void RemoveFromUpdateableAndDrawableList(IGameScreen screen)
        {
            int lastDrawableIndex = this.drawableScreens.Count - 1;

            if (lastDrawableIndex > -1)
            {
                if (ReferenceEquals(this.drawableScreens[lastDrawableIndex], screen))
                {
                    this.drawableScreens.RemoveAt(lastDrawableIndex);
                }
            }

            int lastUpdateableIndex = this.updateableScreens.Count - 1;
            if (lastUpdateableIndex > -1)
            {
                if (ReferenceEquals(this.updateableScreens[lastUpdateableIndex], screen))
                {
                    this.updateableScreens.RemoveAt(lastUpdateableIndex);
                }
            }
        }
 public void Push(IGameScreen screen)
 {
     Push(screen, GameScreenModality.Exclusive);
 }