The background screen sits behind all the other menu screens. It draws a background image that remains fixed in place regardless of whatever transitions the screens on top of it may be doing.
Inheritance: GameScreen
Ejemplo n.º 1
0
        private void AddInitialScreens()
        {
            BackgroundScreen backgroundScreen = new BackgroundScreen();
            screenManager.AddScreen(backgroundScreen, null);

            #if WINDOWS_PHONE
            screenManager.AddScreen(new PhoneMainMenuScreen(backgroundScreen), null);
            #else
            screenManager.AddScreen(new MainMenuScreen(), null);
            #endif
        }
Ejemplo n.º 2
0
 /// <summary>
 /// The "Exit" button handler uses the LoadingScreen to take the user out to the main menu.
 /// </summary>
 void exitButton_Tapped(object sender, EventArgs e)
 {
     BackgroundScreen background = new BackgroundScreen();
     LoadingScreen.Load(ScreenManager, false, null, background,
                                                    new PhoneMainMenuScreen(background));
 }
Ejemplo n.º 3
0
 public PhoneMainMenuScreen(BackgroundScreen background)
     : base("")
 {
     this.background = background;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the state of the game. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                                       bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, false);
            TouchCollection touchCollection = TouchPanel.GetState();
            if (!world.Game.Components.Contains(world.player))
                world.Game.Components.Add(world.player);
            // Gradually fade in or out depending on whether we are covered by the pause screen.
            if (coveredByOtherScreen)
                pauseAlpha = Math.Min(pauseAlpha + 1f / 32, 1);
            else
                pauseAlpha = Math.Max(pauseAlpha - 1f / 32, 0);

            if (IsActive)
            {
                if (!hasStarted && touchCollection.Count>0)
                {
                    TouchLocation tl = touchCollection[0];
                    world.player.IsAlive = true;
                    world.fillBegin(((int)tl.Position.X)+1, TouchPanel.DisplayHeight - (int)tl.Position.Y);
                    world.player.setActive();
                    hasStarted = true;
                }
                else if (/*!hasStarted ||*/ world.player.IsAlive && !world.player.gameOver)
                {
                    #region GAME LOGIC

                    for (int i = 0; i < gameTime.ElapsedGameTime.Milliseconds; i++)
                    {

                        

                        world.removeLine(0);
                        pressedLastX--;

                        // create gates
                        if (world.player.Score.Points > 0 & world.player.Score.Points % 5000 == 0)
                        {
                            world.createGates();
                        }

                        //update gates
                        world.updateGates();

                        if (touchCollection.Count == 0)
                        {
                            isPressed = false;
                            world.addLine(-1);
                        }
                        else
                        {
                            foreach (TouchLocation tl in touchCollection)
                            {
                                if (!hasStarted)
                                {
                                    world.getPlayer().setActive();
                                    world.fillBegin((int)tl.Position.X, TouchPanel.DisplayHeight - (int)tl.Position.Y);
                                    hasStarted = true;
                                }

                                touchPosition.X = tl.Position.X;
                                touchPosition.Y = tl.Position.Y;

                                if (tl.State == TouchLocationState.Pressed || (tl.State == TouchLocationState.Moved))
                                {
                                    if (world.getLineQueue()[(int)Math.Max(1, pressedLastX) - 1].Height == -1)
                                    {
                                        pressedLastY = (int)touchPosition.Y;
                                    }
                                    if (touchPosition.X > pressedLastX)
                                    {
                                        for (; pressedLastX < touchPosition.X; pressedLastX++)
                                        {
                                            if (pressedLastY == 0)
                                            {
                                                pressedLastY = (int)touchPosition.Y;
                                            }

                                            newLineY = pressedLastY;

                                            if (isPressed)
                                            {
                                                if (pressedLastY < touchPosition.Y)
                                                {
                                                    // Decreasing
                                                    newLineY = (int)touchPosition.Y;
                                                }
                                                else if (pressedLastY > touchPosition.Y)
                                                {
                                                    // Increasing
                                                    newLineY -= 2;
                                                }
                                                else
                                                {
                                                    // No change
                                                    // Do nothing
                                                }

                                                world.addLine(pressedLastX, TouchPanel.DisplayHeight - newLineY);
                                                pressedLastY = newLineY;
                                            }
                                        }
                                        /*
                                        lineQueue.Insert((int)touchPosition.X, new WorldLine(480 - (int)touchPosition.Y));
                                        if (isPressed) // is touch being held?
                                        {
                                            int diffx = Math.Abs(pressedLastX - (int)touchPosition.X);
                                            int diffy = Math.Abs(pressedLastY - (int)touchPosition.Y);
                                            int step = 0;
                                            if (diffx > 0 & diffy > 0)
                                            {
                                                step = Math.Max(diffx, diffy) / Math.Min(diffx, diffy);

                                                for (int i = pressedLastX - 1; i < (int)touchPosition.X; i++)
                                                {
                                                    lineQueue.RemoveAt(i);
                                                    if (diffx > diffy)
                                                    {
                                                        for (int j = 0; j < step; j++)
                                                        {
                                                            lineQueue.Insert(i, new WorldLine(480 - pressedLastY + j));
                                                            i += j;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        lineQueue.Insert(i, new WorldLine(480 - pressedLastY + step));
                                                    }
                                                }
                                            }
                                        }
                                        pressedLastX = (int)touchPosition.X;
                                        pressedLastY = (int)touchPosition.Y;
                                        */
                                    }
                                    else
                                    {
                                        world.addLine(-1);
                                    }
                                    isPressed = true;
                                }

                                // Detect player-gate collision
                                Gate nextGate = world.getClosestGate(world.player);// Get gates closest intersecting gate

                                if (nextGate != null)    // there is a next gate
                                {
                                    if (!nextGate.isHit)  // gate not yet hit
                                    {
                                        // Add score * ++mutiplier
                                        world.player.Score.Points += 10000 * (++world.player.Score.Multiplier);
                                        // Set gate off
                                        nextGate.myTexture = Gate.gatePassed;
                                        nextGate.isHit = true;
                                    }
                                }
                                else
                                {
                                    // Check multiplier and reset if needed
                                    if (world.player.Score.Multiplier > 0)
                                    {
                                        world.player.Score.Multiplier = 0;
                                    }
                                }

                                break;
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    //gameover

                    //TouchCollection touchCollection = TouchPanel.GetState();
                    foreach (TouchLocation tl in touchCollection)
                    {
                        if (tl.State == TouchLocationState.Pressed || (tl.State == TouchLocationState.Moved))
                        {
                        BackgroundScreen background = new BackgroundScreen();
                            ScreenManager.RemoveScreen(this);
                            ScreenManager.AddScreen(background, null);
                            ScreenManager.AddScreen(new PhoneMainMenuScreen(background), null);

                            //long highscore = Highscore.Load();
                            long playerScore = (world.player.Score.Points / 100) * 10;

                            //if (highscore > playerScore)
                            //{
                                //Highscore.Save(highscore);
                                //world.player.Score.Highscore = highscore;
                            //}
                        }
                    }
                }
                // particles
                part.EmitterLocation = new Vector2(world.player.Position.X - 35, world.player.Position.Y + 75);
                part.Update();
            }
        }