/// <summary> /// Create all of the aliens when a level starts /// </summary> public void CreateAliens() { Sprites.RemoveAll(s => s is AlienSprite); aliens.Clear(); AlienCount = 0; // Create 55 alien sprites in 5 rows of 11 for (int row = 1; row <= 5; row++) { for (int col = 1; col <= 11; col++) { AlienSprite newAlien = AddSprite <AlienSprite>(); newAlien.X = -100 + col * 14; newAlien.Y = 80 - row * 10; newAlien.Col = col; newAlien.Row = row; if (row == 1) { newAlien.Setup(3); } if (row == 2 || row == 3) { newAlien.Setup(2); } if (row == 4 || row == 5) { newAlien.Setup(1); } aliens.Add(newAlien); AlienCount++; } } }
/// <summary> /// Start the title screen /// This happens at the beginning of the game, and when you're done playing /// </summary> public override void StartScene() { Texts.Clear(); Sprites.Clear(); // Add the title text AddText(new Text { Value = "Space Invaders", Position = new Vector2(0f, 80f), Alignment = HorizontalAlignments.Center, AnimationType = TextAnimations.Typewriter, AnimationSeconds = 0.15, Scale = 1f, //Font = FancyFont, OnAnimationComplete = (Text text) => { // When the title text is done typing, show the high score HighScoreText = AddText(new Text { Value = "High Score:", Position = new Vector2(80f, 90f), Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Top, AnimationType = TextAnimations.SeeSaw, AnimationSeconds = 0.2, AnimationIntensity = 0.15, Scale = 0.4f, }); UfoSprite ufo = AddSprite <UfoSprite>(); ufo.X = -49; ufo.Y = 45; Wait(2.3f, () => { AlienSprite alien = AddSprite <AlienSprite>(); alien.X = -40; alien.Y = 13; alien.Setup(1); }); Wait(5.2f, () => { AlienSprite alien = AddSprite <AlienSprite>(); alien.X = -40; alien.Y = -13; alien.Setup(2); }); Wait(8.7, () => { AlienSprite alien = AddSprite <AlienSprite>(); alien.X = -40; alien.Y = -43; alien.Setup(3); }); AlienScoreText = AddText(new Text { Value = "= ? POINTS" + Text.NewLine + Text.NewLine + "= 10 POINTS" + Text.NewLine + Text.NewLine + "= 20 POINTS" + Text.NewLine + Text.NewLine + "= 30 POINTS", Position = new Vector2(0, 0), Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Center, AnimationType = TextAnimations.Typewriter, AnimationSeconds = 0.2, Scale = 0.8f, Color = Color.White }); } }); // Add the 1p start key text Player1StartText = AddText(new Text { Value = "1 Player Start", Position = new Vector2(-65f, -85f), Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Center, AnimationType = TextAnimations.None, AnimationIntensity = 0.2, Scale = 0.6f, Color = Color.Lime }); // Add the 2p start key text Player2StartText = AddText(new Text { Value = "2 Player Start", Position = new Vector2(65f, -85f), Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Center, AnimationType = TextAnimations.None, AnimationIntensity = 0.2, Scale = 0.6f, Color = Color.Lime }); if (SpaceInvaders.NumberOfPlayers == 1) { Player1StartText.AnimationType = TextAnimations.Throb; Player1StartText.Scale = 0.6f; Player1StartText.Start(); } else { Player2StartText.AnimationType = TextAnimations.Throb; Player2StartText.Scale = 0.6f; Player2StartText.Start(); } }