public ScoreboardPopupMenuScreen( ScreenManager screenManager, Slot[] slots ) { ScreenManager = screenManager; this.slots = slots; IsPopup = true; ContentManager content = screenManager.Game.Content; GraphicsDevice device = screenManager.GraphicsDevice; ImageMenuEntry entry; float x = device.Viewport.Width / 2; float yStart = .8f * device.Viewport.Height; float ySpace = .06f * device.Viewport.Height; float y = yStart; float screenScale = (float)device.Viewport.Height / 1080f; // Play Again entry = new ImageMenuEntry( this, new Vector2( x, y ), content.Load<Texture2D>( "Textures/playAgainText" ), null ); entry.Selected += PlayAgain; entry.TransitionOnPosition = entry.TransitionOffPosition = entry.Position + new Vector2( 0, ySpace * 5 ); entry.IdleScale = entryIdleScale * screenScale; entry.FocusScale = entryFocusScale * screenScale; entry.Focused = true; MenuItems.Add( entry ); // High Scores y += ySpace; entry = new ImageMenuEntry( this, new Vector2( x, y ), content.Load<Texture2D>( "Textures/highScoresText" ), null ); entry.Selected += ViewHighScores; entry.TransitionOnPosition = entry.TransitionOffPosition = entry.Position + new Vector2( 0, ySpace * 5 ); entry.IdleScale = entryIdleScale * screenScale; entry.FocusScale = entryFocusScale * screenScale; MenuItems.Add( entry ); // Exit y += ySpace; entry = new ImageMenuEntry( this, new Vector2( x, y ), content.Load<Texture2D>( "Textures/exitText" ), null ); entry.Selected += Exit; entry.TransitionOnPosition = entry.TransitionOffPosition = entry.Position + new Vector2( 0, ySpace * 5 ); entry.IdleScale = entryIdleScale * screenScale; entry.FocusScale = entryFocusScale * screenScale; MenuItems.Add( entry ); }
public void OnButtonAHit( PlayerIndex playerIndex, ref SignInSlot slot ) { if ( slot.Slot.Player < PlayerIndex.One ) { if ( Guide.IsTrialMode && slots.Count( s => s.Slot.Player.IsHuman() ) > 0 ) { nagText.DeathBegin = (float)lastGameTime.TotalGameTime.TotalSeconds; MessageBoxScreen messageBox = new MessageBoxScreen( "Full version required for Multiplayer. " + "Buy Avatar Hamster Panic now?" ); messageBox.Accepted += GameCore.Instance.ShowBuy; ScreenManager.AddScreen( messageBox, null ); } else { bool found = false; foreach ( SignedInGamer gamer in Gamer.SignedInGamers ) { if ( gamer.PlayerIndex == playerIndex ) { found = true; break; } } if ( !found ) { Guide.ShowSignIn( 4, false ); autoSignIn = true; } else { AddPlayer( ref slot, playerIndex ); } } } else if ( slot.Ready == false ) { GameCore.Instance.AudioManager.Play2DCue( "readyUp", 1f ); slot.Ready = true; } if ( slots.Count( s => s.Slot.Player.IsHuman() ) != 0 ) { if ( slots.Count( s => s.Slot.Player.IsHuman() && !s.Ready ) == 0 ) { Slot[] initSlots = new Slot[4]; for ( int i = 0; i < 4; ++i ) initSlots[i] = slots[i].Slot; GameCore.Instance.AudioManager.Play2DCue( "startGame", 1f ); //ScreenManager.MenuTrack.Pause(); LoadingScreen.Load( ScreenManager, true, playerIndex, new GameplayScreen( initSlots ) ); } } }
/// <summary> /// Constructor. /// </summary> public GameplayScreen( Slot[] slots ) { TransitionOnTime = TimeSpan.FromSeconds( .5 ); TransitionOffTime = TimeSpan.FromSeconds( .75 ); initSlotInfo = slots; Instance = this; }
public ScoreboardMenuScreen( ScreenManager screenManager, Slot[] slots ) { TransitionOnTime = TimeSpan.FromSeconds( 0 ); ScreenManager = screenManager; ContentManager content = ScreenManager.Game.Content; podiumModel = content.Load<CustomModel>( "Models/podium" ); foreach ( CustomModel.ModelPart part in podiumModel.ModelParts ) { part.Effect.CurrentTechnique = part.Effect.Techniques["DiffuseColor"]; } swipeMask = content.Load<Texture2D>( "Textures/swipeMask" ); podiumTransform = Matrix.CreateScale( podiumSize ); spriteBatch = ScreenManager.SpriteBatch; float aspect = ScreenManager.GraphicsDevice.Viewport.AspectRatio; camera = new Camera( MathHelper.PiOver4, aspect, 1f, 100f, new Vector3( 0, 2, 10 ), new Vector3( 0, 2, 0 ) ); device = ScreenManager.GraphicsDevice; renderState = device.RenderState; screenScale = (float)device.Viewport.Height / 1080f; screenTextureQuad = new VertexPositionTexture[4]; screenTextureQuad[0].Position = new Vector3( 0, 0, 0 ); screenTextureQuad[1].Position = new Vector3( device.Viewport.Width, 0, 0 ); screenTextureQuad[2].Position = new Vector3( device.Viewport.Width, device.Viewport.Height, 0 ); screenTextureQuad[3].Position = new Vector3( 0, device.Viewport.Height, 0 ); screenTextureQuad[0].TextureCoordinate = new Vector2( 0, 0 ); screenTextureQuad[1].TextureCoordinate = new Vector2( 1, 0 ); screenTextureQuad[2].TextureCoordinate = new Vector2( 1, 1 ); screenTextureQuad[3].TextureCoordinate = new Vector2( 0, 1 ); screenColorQuad = new VertexPositionColor[4]; screenColorQuad[0].Position = new Vector3( 0, 0, 0 ); screenColorQuad[1].Position = new Vector3( device.Viewport.Width, 0, 0 ); screenColorQuad[2].Position = new Vector3( device.Viewport.Width, device.Viewport.Height, 0 ); screenColorQuad[3].Position = new Vector3( 0, device.Viewport.Height, 0 ); for ( int i = 0; i < 4; ++i ) screenColorQuad[i].Color = Color.Black; swipeQuad = new VertexPositionTexture[4]; float a = device.Viewport.Width / 2; float b = device.Viewport.Height / 2; maskRadius = (float)Math.Sqrt( a * a + b * b ); float xMin = a - maskRadius; float xMax = a + maskRadius; float yMin = b - maskRadius; float yMax = b + maskRadius; swipeQuad[0].Position = new Vector3( xMin, yMin, 0 ); swipeQuad[1].Position = new Vector3( xMax, yMin, 0 ); swipeQuad[2].Position = new Vector3( xMax, yMax, 0 ); swipeQuad[3].Position = new Vector3( xMin, yMax, 0 ); swipeQuad[0].TextureCoordinate = new Vector2( 0, 0 ); swipeQuad[1].TextureCoordinate = new Vector2( 1, 0 ); swipeQuad[2].TextureCoordinate = new Vector2( 1, 1 ); swipeQuad[3].TextureCoordinate = new Vector2( 0, 1 ); vertexBuffer = new VertexPositionTexture[4]; vertexBuffer[0].TextureCoordinate = new Vector2( 0, 0 ); vertexBuffer[1].TextureCoordinate = new Vector2( 1, 0 ); vertexBuffer[2].TextureCoordinate = new Vector2( 1, 1 ); vertexBuffer[3].TextureCoordinate = new Vector2( 0, 1 ); screenCenter = new Vector3( a, b, 0 ); effect = ScreenQuadEffect.CreateScreenQuadEffect( device, content ); dadtOut = MathHelper.Pi * maskRadius * maskRadius / swipeOutDuration; dadtIn = MathHelper.Pi * maskRadius * maskRadius / swipeInDuration; players = new ScoreboardPlayer[4]; places = new Vector3[4]; places[0] = podiumTransform.Translation + new Vector3( 0, podiumSize, 0 ); places[1] = places[0] + new Vector3( -podiumSize, -.4f * podiumSize, 0 ); places[2] = places[0] + new Vector3( podiumSize, -.5f * podiumSize, 0 ); places[3] = podiumTransform.Translation + new Vector3( 3 * podiumSize, .125f, 0 ); animSpeeds = new float[4]; animSpeeds[0] = .95f; animSpeeds[1] = .8f; animSpeeds[2] = 1.1f; animSpeeds[3] = 1f; popupScreen = new ScoreboardPopupMenuScreen( screenManager, slots ); pressAToContinueText = content.Load<Texture2D>( "Textures/pressAToContinueText" ); pressAPosition = new Vector2( screenCenter.X, .8f * device.Viewport.Height ); pressAOrigin = new Vector2( pressAToContinueText.Width, pressAToContinueText.Height ) / 2; loserBoxModel = content.Load<CustomModel>( "Models/loserBox" ); foreach ( CustomModel.ModelPart part in loserBoxModel.ModelParts ) part.Effect.CurrentTechnique = part.Effect.Techniques["Color"]; loserBoxTransform = Matrix.CreateTranslation( 3 * podiumSize, 0, 0 ); int rectWidth = (int)( 900 * screenScale + .5f ); int rectHeight = (int)( 245 * screenScale + .5f ); scoreboardRect = new Rectangle( ( device.Viewport.Width - rectWidth ) / 2, (int)( 60 * screenScale + .5f ), rectWidth, rectHeight ); playerScoreBar = content.Load<Texture2D>( "Textures/playerScoreboardBar" ); playerNameBox = content.Load<Texture2D>( "Textures/playerNameBox" ); scoreText = content.Load<Texture2D>( "Textures/scoreText" ); winsText = content.Load<Texture2D>( "Textures/winsText" ); playerScoreBarPositions = new Vector2[4]; int y = scoreboardRect.Top + (int)( 41 * screenScale + .5f ); for ( int i = 0; i < 4; ++i ) { playerScoreBarPositions[i] = new Vector2( scoreboardRect.Left + 1, y ); y += (int)( playerScoreBar.Height * screenScale ) + (int)( 4 * screenScale + .5f ); } playerNameBoxPositions = new Vector2[4]; for ( int i = 0; i < 4; ++i ) { Vector2 pos = Vector2.Zero; pos.X = scoreboardRect.Left + 58 * screenScale; pos.Y = playerScoreBarPositions[i].Y + 5 * screenScale; playerNameBoxPositions[i] = pos; } scoreboardFont = content.Load<SpriteFont>( "Fonts/scoreboardFont" ); scoreboardNumberFont = content.Load<SpriteFont>( "Fonts/scoreboardNumberFont" ); scoreboardSubscriptFont = content.Load<SpriteFont>( "Fonts/scoreboardSubscriptFont" ); stringBuffer = new StringBuilder( 2 ); cpuNameString = "CPU"; addColorEffect = content.Load<Effect>( "Effects/addColorEffect" ); addColorEffect.CurrentTechnique = addColorEffect.Techniques[0]; background = content.Load<Texture2D>( "Textures/menuBackground" ); scoresRecorded = false; }