protected override void InternalLoad()
        {
            if (ShowSplashScreen)
            {
                _currentAlpha = 0;
                _time = 0;
                _src = new Rectangle(0, 0, 375, 106);
                _dst = new Rectangle((int)(Resolution.VirtualWidth - _src.Width) / 2, (Resolution.VirtualHeight - _src.Height) / 2, _src.Width, _src.Height);

                SceneCamera.FadeOut(70f, () =>
                {
                    // GB sound
                    Application.MagicContentManager.GetSound("s_gameboy").Play(0.5f, 0f, 0f);

                    Timer.Create(3f, false, (t =>
                    {
                        SceneCamera.FadeIn(120f, () =>
                        {

                            ChangeCurrentGameState = true;
                            NextGameState = Application.GameStateManager.GetGameState<HomeState>();
                            SceneCamera.FadeOut(80f, null);

                        });
                    }));
                });
            }
            else
            {
                ChangeCurrentGameState = true;
                NextGameState = Application.GameStateManager.GetGameState<HomeState>();
            }
        }
예제 #2
0
        private void getInput()
        {
            foreach (Device device in Application.InputManager.GetLinkedDevices(LogicalPlayerIndex.One))
            {
                // Zoom
                if (device.GetState(MappingButtons.LB).IsDown)
                {
                    SceneCamera.Zoom += 0.025f;
                    //Console.WriteLine(SceneCamera.Zoom);
                }
                else if (device.GetState(MappingButtons.RB).IsDown)
                {
                    SceneCamera.Zoom -= 0.025f;
                    //Console.WriteLine(SceneCamera.Zoom);
                }

            #if DEBUG
                if (device.GetState(MappingButtons.Back).IsPressed)
                {
                    Application.IsDebugMode = !Application.IsDebugMode;
                }
            #endif

                // Pause game
                if (device.GetState(MappingButtons.Start).IsPressed)
                {
                    _isPaused = !_isPaused;

                    if (_isPaused)
                    {
                        _alphaPauseDelta = 0.025f;
                    }
                    else
                    {
                        _alphaPauseDelta = -0.025f;
                    }
                }

                // Quit game
                if (device.GetState(MappingButtons.Back).IsPressed)
                {
                    if (_isPaused)
                    {
                        ChangeCurrentGameState = true;
                        NextGameState = Application.GameStateManager.GetGameState<HomeState>();
                    }
                }
            }
        }
예제 #3
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Application.IsApplicationActive)
            {
                getInput();
            }

            // Stop physics in pause
            Application.PhysicsManager.IsEnable = !_isPaused;

            if (_isPaused == false)
            {
                // Tic, tac, tic, tac, time is running out!
                _elapsedTime += ((float)gameTime.ElapsedGameTime.TotalSeconds);

                float timeLeft = MaxTime - _elapsedTime;
                Application.ScriptManager.SetFlag(LapinsScript.TimeLeft, timeLeft);

                if (timeLeft <= 0)
                {
                    Application.ScriptManager.SetFlag(LapinsScript.EscapeState, 2);
                }

                // Update elements
                _skybox.Update(gameTime);
                _level.Update(gameTime);
                _compass.Update(gameTime);

                if (_level.Player != null)
                {
                    // Generate asteroids if player is instanciated
                    _bgAsteroidGenerator.Update(gameTime);
                    _asteroidGenerator.Update(gameTime);
                }
                else
                {
                    // Center camera on player spawn
                    Application.GameStateManager.CurrentGameState.SceneCamera.Location = _level.SpawnLocation;
                }

                // Back to home if player is dead
                int endState = Application.ScriptManager.GetFlag<int>(LapinsScript.EscapeState);

                if ((endState != 0) && (_isEnded == false))
                {
                    // Launch animation
                    _isEnded = true;

                    // Win
                    if (endState == 1)
                    {
                        Timer.Create(2f, false, t =>
                        {
                            SceneCamera.FadeIn(60f, () =>
                            {
                                SpecialEffectsHelper.ShakeScreen(Vector2.Zero, 1f);

                                ChangeCurrentGameState = true;
                                NextGameState = Application.GameStateManager.GetGameState<GameOverState>();
                            });
                        });
                    }
                    else
                    {
                        Timer.Create(1f, false, t =>
                        {
                            // Lose
                            SceneCamera.FadeIn(30f, () =>
                            {
                                SpecialEffectsHelper.ShakeScreen(Vector2.Zero, 1f);

                                ChangeCurrentGameState = true;
                                NextGameState = Application.GameStateManager.GetGameState<GameOverState>();
                            }, Color.White);
                        });
                    }
                }
                else
                {
                    if (Level.CurrentLevel.Player != null)
                    {
                        // Center camera on player if it's not the end
                        Application.GameStateManager.CurrentGameState.SceneCamera.Location = _level.Player.Location;
                    }
                }

                _hud.Update(gameTime);
            }

            if (_alphaPauseDelta != 0)
            {
                _alphaPause += _alphaPauseDelta;
                if (_alphaPause > 0.75f)
                {
                    _alphaPause = 0.75f;
                    _alphaPauseDelta = 0f;
                }
                else if (_alphaPause < 0f)
                {
                    _alphaPause = 0f;
                    _alphaPauseDelta = 0f;
                }
            }
        }
예제 #4
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (_lastItem < ScoreLines)
            {
                _currentAlpha += 0.015f;

                if (_currentAlpha >= 1f)
                {
                    _currentAlpha = 0f;
                    _lastItem++;
                }
            }
            else
            {
                // New highscore ?

                foreach (Device device in Application.InputManager.GetLinkedDevices(LogicalPlayerIndex.One))
                {
                    if ((device.GetState(MappingButtons.A).IsPressed) || (device.GetState(MappingButtons.B).IsPressed) || (device.GetState(MappingButtons.Y).IsPressed) || (device.GetState(MappingButtons.Start).IsPressed))
                    {
                        ChangeCurrentGameState = true;
                        NextGameState = Application.GameStateManager.GetGameState<HighscoreState>();
                        ((HighscoreState)NextGameState).Rank = _rank;
                        ((HighscoreState)NextGameState).UseRank = true;
                    }
                }
            }
        }
예제 #5
0
        private void changeState()
        {
            UseLoading = false;

            switch (_menuCurrent)
            {
                case MenuValues.MenuNewgame:
                    NextGameState = Application.GameStateManager.GetGameState<PlayState>();
                    UseLoading = true;
                    break;

                //case MenuValues.MenuOptions:
                //ChangeCurrentGameState = false;
                //NextGameState = Application.GameStateManager.GetGameState<PlayState>();
                //break;

                case MenuValues.MenuHighscores:
                    NextGameState = Application.GameStateManager.GetGameState<HighscoreState>();
                    break;

                case MenuValues.MenuCredits:
                    NextGameState = Application.GameStateManager.GetGameState<CreditsState>();
                    break;

                case MenuValues.MenuQuit:
                    ChangeCurrentGameState = false;
                    Application.Quit();
                    break;
            }

            SceneCamera.FadeIn(30f, () =>
            {
                ChangeCurrentGameState = true;
            });
        }
예제 #6
0
 public void SetNextGameState(GameState nextGameState)
 {
     NextGameState = nextGameState;
 }