Пример #1
0
    public void Show(string screenToShowTitle = null)
    {
        this.gameObject.SetActive(true);
        this.enabled = true;
        if (screens.Count > 0)
        {
            var screenToShow = string.IsNullOrEmpty(screenToShowTitle) ? screens.First() : screens.Find(x => x.Title == screenToShowTitle);
            if (screenToShow == null)
            {
                screenToShow = screens.First();
            }
            if (this.activeScreen != null && screenToShow != this.activeScreen)
            {
                this.activeScreen.Hide();
            }
            this.activeScreen = screenToShow;
            screenToShow.Show();
            if (this.ScreenTitle != null)
            {
                this.ScreenTitle.text = screenToShow.Title;
            }

            var allOtherScreens = this.screens.Where(x => x != screenToShow);
            foreach (var screen in allOtherScreens)
            {
                screen.Hide();
            }
        }
    }
Пример #2
0
 /// <summary>
 ///     Pauses the game and shows the pause menu screen
 /// </summary>
 public void PauseGame()
 {
     Loop.Stop();
     _screenPauseMenu = new PauseMenuScreen();
     Canvas.SetTop(_screenPauseMenu, 0);
     Canvas.SetLeft(_screenPauseMenu, 0);
     DrawingPanel.Children.Add(_screenPauseMenu);
 }
Пример #3
0
 public void Hide()
 {
     this.enabled = false;
     this.gameObject.SetActive(false);
     if (this.activeScreen != null)
     {
         this.activeScreen.Hide();
         this.activeScreen = null;
     }
 }
Пример #4
0
 // Use this for initialization
 void Start()
 {
     Screen.lockCursor = true;
     Menu = GetComponent<PauseMenuScreen>();
     Time.timeScale = 1;
 }
Пример #5
0
        private void _pause()
        {
            var pause = new PauseMenuScreen(this);

            XnaDartsGame.ScreenManager.AddScreen(pause);
        }
Пример #6
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if ( Content == null )
            Content = new ContentManager( ScreenManager.Game.Services, "Content" );

              Game game = ScreenManager.Game;

              // initialize physics
              PhysicsSpace = new PhysicsSpace();
              PhysicsSpace.Gravity = new Vector2( 0f, -8f );

              // render targets
              GraphicsDevice device = ScreenManager.GraphicsDevice;
              PostProcessor.Initialize( device, ScreenManager.SpriteBatch, Content );
              PresentationParameters pars = device.PresentationParameters;
              basicSceneRenderTarget = new RenderTarget2D( device, pars.BackBufferWidth, pars.BackBufferHeight, 1, pars.BackBufferFormat );
              maskRenderTarget = new RenderTarget2D( device, pars.BackBufferWidth, pars.BackBufferHeight, 1, SurfaceFormat.Bgr32 );

              screenRectangle = new Rectangle( 0, 0, pars.BackBufferWidth, pars.BackBufferHeight );

              // this prevents the game from pausing after the player presses start to exit the loading screen
              firstFrame = true;

              // load fonts
              gameFont = Content.Load<SpriteFont>( "Fonts/gamefont" );
              Content.Load<SpriteFont>( "Fonts/HUDNameFont" );

              // load screens ahead of time
              scoreboardMenuScreen = new ScoreboardMenuScreen( ScreenManager, initSlotInfo );
              pauseScreen = new PauseMenuScreen( ScreenManager );

              // model explosion particles
              ParticleManager = new ParticleManager( game, Content );
              ParticleManager.Initialize();
              components.Add( ParticleManager );

              // other particles
              PixieParticleSystem = new PixieParticleSystem( game, Content );
              SparkParticleSystem = new SparkParticleSystem( game, Content );
              PinkPixieParticleSystem = new PinkPixieParticleSystem( game, Content );
              components.Add( PixieParticleSystem );
              components.Add( SparkParticleSystem );
              components.Add( PinkPixieParticleSystem );

              foreach ( DrawableGameComponent component in components )
            component.Initialize();

              // pre-load
              LaserBeam.Initialize();
              Content.Load<CustomAvatarAnimationData>( "Animations/Walk" );
              Content.Load<CustomAvatarAnimationData>( "Animations/Run" );
              backgroundTexture = Content.Load<Texture2D>( "Textures/gameBackground" );
              int left = -( backgroundTexture.Width - ScreenManager.GraphicsDevice.Viewport.Width ) / 2;
              Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
              if ( left > 0 )
            backgroundRect = new Rectangle( 0, 0, viewport.Width, viewport.Height );
              else
            backgroundRect = new Rectangle( left, 0, backgroundTexture.Width, viewport.Height );

              // init game stuff
              ObjectTable = new ObjectTable<GameObject>();

              // ready, go!
              ObjectTable.Add( new ReadyGo( this, new Vector2( viewport.Width / 2, viewport.Height / 2 ) ) );

              float fov = MathHelper.ToRadians( 30f );
              float aspect = ScreenManager.GraphicsDevice.DisplayMode.AspectRatio;
              Camera = new Camera( fov, aspect, 1f, 100f, new Vector3( 0f, 0f, cameraDistance ), Vector3.Zero );

              winnerSpring = new SpringInterpolater( 1, 10, SpringInterpolater.GetCriticalDamping( 10 ) );
              winnerSpring.SetSource( 1 );
              winnerSpring.SetDest( 0 );

              FloorBlock.Initialize( this );
              Powerup.Initialize( this );

              lastRowY = rowSpacing - Player.Size * 1.5f;

              InitSafeRectangle();
              InitStage();

              CountdownTime = 0f;
              CountdownEnd = 3f;

              lastCamY = Camera.Position.Y;
              SpawnRows(); // spawn additional rows before loading screen is over

              gameClock = new GameTimer( TimeSpan.FromMinutes( 2 ) );
              ObjectTable.Add( gameClock );

              ScreenManager.Game.ResetElapsedTime();
        }