/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { base.Initialize(); //контроллер _keyboardController = new KeyboardController(this); //игрок Player = new Player(_PlayerTexture); Player._laser = _PlayerLaser; Player.SetPosition(120, graphics.PreferredBackBufferHeight / 2); Player.SetScale(0.5f); _keyboardController.Attach(Player); //фон Background = new Background(_t); //астероиды _asteroid1 = new Asteroids(_asteroidTexture1, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); _asteroid2 = new Asteroids(_asteroidTexture2, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); _asteroid3 = new Asteroids(_asteroidTexture3, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); _asteroid4 = new Asteroids(_asteroidTexture4, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); _asteroid5 = new Asteroids(_asteroidTexture5, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); //бонусы _bonusHeals = new Bonuses(_heart); _bonusHeals.SetPosition(500, 500); _bonusHeals.SetScale(0.6f); _bonusHeals.SetVelocity(new Vector2(-1, 0)); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); Texture2D ship = Content.Load <Texture2D>("ship_2"); Texture2D invader = Content.Load <Texture2D>("invader_1"); player = new Player(ship, new Vector2(GraphicsDevice.Viewport.Width / 2 - (ship.Width / 2) * scale, GraphicsDevice.Viewport.Height - ship.Height * scale)); player.SetScale(scale); int invaderCount = 8; int rows = 4; Random random = new Random(); for (int a = 0; a < rows; a++) { invaders.Add(new List <Invader>()); for (int i = 0; i < invaderCount; i++) { invaders[a].Add(new Invader( invader, new Vector2(((GraphicsDevice.Viewport.Width / invaderCount) * i), 10 - (invader.Height + 20) * a), new Vector2(4, 0.25f), random.Next(160, 300) )); } } Texture2D background = this.Content.Load <Texture2D>("galaxy"); backgroundImage = new Sprite(background, new Vector2(0, 0)); font = this.Content.Load <SpriteFont>("Font"); availablePowerups.Add(new Powerup(this.Content.Load <Texture2D>("shield"), new Vector2(player.Position.X, player.Position.Y), "shield", 60 * 30)); /* * this.graphics.PreferredBackBufferWidth = this.backgroundTexture.Width; * this.graphics.PreferredBackBufferHeight = this.backgroundTexture.Height; * this.graphics.ApplyChanges(); */ // TODO: use this.Content to load your game content here }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { font1 = Content.Load<SpriteFont>("Fonts/MyFont"); leo = new Player("Leo1"); taskMaster = new Boss_TaskMaster(); leo.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Actors/Leo/Stance")); leo.SetFrameDelay(Animation.State.STANCE, 5); leo.AddSprite(Animation.State.WALK_TOWARDS, new Sprite("Sprites/Actors/Leo/Walk", Animation.Type.REPEAT)); leo.SetSpriteOffSet(Animation.State.WALK_TOWARDS, 0, 240f); leo.AddSprite(Animation.State.JUMP_START, new Sprite("Sprites/Actors/Leo/JumpStart", Animation.Type.ONCE)); leo.SetSpriteOffSet(Animation.State.JUMP_START, 20, 10); leo.SetFrameDelay(Animation.State.JUMP_START, 5); leo.AddSprite(Animation.State.LAND, new Sprite("Sprites/Actors/Leo/Land", Animation.Type.ONCE)); leo.SetSpriteOffSet(Animation.State.LAND, 30, -11); leo.SetFrameDelay(Animation.State.LAND, 5); leo.AddSprite(Animation.State.JUMP, new Sprite("Sprites/Actors/Leo/Jump", Animation.Type.REPEAT, 13)); leo.SetFrameDelay(Animation.State.JUMP, 5); leo.SetSpriteOffSet(Animation.State.JUMP, 10, -80); leo.AddSprite(Animation.State.JUMP_TOWARDS, new Sprite("Sprites/Actors/Leo/JumpTowards", Animation.Type.REPEAT, 13)); leo.SetFrameDelay(Animation.State.JUMP_TOWARDS, 5); leo.SetFrameDelay(Animation.State.JUMP_TOWARDS, 1, 6); leo.SetSpriteOffSet(Animation.State.JUMP_TOWARDS, 10, -80); leo.AddAnimationLink(new Animation.Link(Animation.State.JUMP_START, Animation.State.JUMP, leo.GetSprite(Animation.State.JUMP_START).GetFrames())); leo.SetTossFrame(Animation.State.JUMP, 1); leo.SetTossFrame(Animation.State.JUMP_TOWARDS, 1); leo.AddSprite(Animation.State.FALL1, new Sprite("Sprites/Actors/Leo/Falling", Animation.Type.REPEAT, 5)); leo.SetSpriteOffSet(Animation.State.FALL1, 10, -80); leo.SetAnimationState(Animation.State.STANCE); leo.SetSpriteOffSet(Animation.State.WALK_TOWARDS, 30, -5); leo.SetResetFrame(Animation.State.WALK_TOWARDS, 3); leo.SetMoveFrame(Animation.State.WALK_TOWARDS, 3); leo.SetHeight(180); leo.SetFrameDelay(Animation.State.WALK_TOWARDS, 5); leo.SetFrameDelay(Animation.State.WALK_TOWARDS, 1, 6); leo.SetFrameDelay(Animation.State.WALK_TOWARDS, 2, 6); leo.SetFrameDelay(Animation.State.WALK_TOWARDS, 3, 6); leo.AddSprite(Animation.State.ATTACK1, new Sprite("Sprites/Actors/Leo/Attack1", Animation.Type.ONCE)); leo.SetSpriteOffSet(Animation.State.ATTACK1, 40, -35); leo.SetFrameDelay(Animation.State.ATTACK1, 4); leo.SetFrameDelay(Animation.State.ATTACK1, 1, 5); leo.SetFrameDelay(Animation.State.ATTACK1, 2, 5); leo.AddBox(Animation.State.ATTACK1, 6, new CLNS.AttackBox(100, 80, 132, 45)); //leo.GetAttackBox(Animation.State.ATTACK1, 6).SetComboStep(0); leo.AddBox(Animation.State.ATTACK1, 6, new CLNS.AttackBox(100, 80, 59, 99, 1)); leo.AddBox(Animation.State.ATTACK1, 6, new CLNS.AttackBox(100, 80, 159, 99, 1)); //leo.GetAttackBox(Animation.State.ATTACK1, 6).SetComboStep(1); leo.AddBox(Animation.State.ATTACK1, 7, new CLNS.AttackBox(150, 50, -10, 210, 1)); leo.AddBox(Animation.State.ATTACK1, 7, new CLNS.AttackBox(150, 50, -60, 160, 1)); leo.GetAttackBox(Animation.State.ATTACK1, 7).SetComboStep(0); leo.AddSprite(Animation.State.ATTACK2, new Sprite("Sprites/Actors/Leo/Attack2", Animation.Type.ONCE)); leo.SetSpriteOffSet(Animation.State.ATTACK2, 25, -37); leo.SetFrameDelay(Animation.State.ATTACK2, 4); leo.AddBox(Animation.State.ATTACK2, 6, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddBox(Animation.State.ATTACK2, 6, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddBox(Animation.State.ATTACK2, 6, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddSprite(Animation.State.ATTACK3, new Sprite("Sprites/Actors/Leo/Attack3", Animation.Type.ONCE)); leo.SetSpriteOffSet(Animation.State.ATTACK3, 60, -10); leo.SetFrameDelay(Animation.State.ATTACK3, 4); leo.AddBox(Animation.State.ATTACK3, 6, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddBox(Animation.State.ATTACK3, 6, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddBox(Animation.State.ATTACK3, 5, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddSprite(Animation.State.ATTACK4, new Sprite("Sprites/Actors/Leo/Attack4", Animation.Type.ONCE)); leo.SetSpriteOffSet(Animation.State.ATTACK4, 30, 3); leo.SetFrameDelay(Animation.State.ATTACK4, 4); leo.AddBox(Animation.State.ATTACK4, 3, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddBox(Animation.State.ATTACK4, 5, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddSprite(Animation.State.ATTACK5, new Sprite("Sprites/Actors/Leo/Attack5", Animation.Type.ONCE)); leo.SetSpriteOffSet(Animation.State.ATTACK5, 50, -25); leo.SetFrameDelay(Animation.State.ATTACK5, 4); leo.AddBox(Animation.State.ATTACK5, 6, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddBox(Animation.State.ATTACK5, 6, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddSprite(Animation.State.ATTACK6, new Sprite("Sprites/Actors/Leo/Attack6", Animation.Type.ONCE), true); leo.SetSpriteOffSet(Animation.State.ATTACK6, 35, -41); leo.SetFrameDelay(Animation.State.ATTACK6, 4); leo.AddBox(Animation.State.ATTACK6, 5, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddBox(Animation.State.ATTACK6, 6, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddBox(Animation.State.ATTACK6, 5, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddBox(Animation.State.ATTACK6, 5, new CLNS.AttackBox(220, 230, 20, 30)); leo.AddSprite(Animation.State.JUMP_ATTACK1, new Sprite("Sprites/Actors/Leo/JumpAttack1", Animation.Type.ONCE), true); leo.SetSpriteOffSet(Animation.State.JUMP_ATTACK1, 60, -70); leo.SetFrameDelay(Animation.State.JUMP_ATTACK1, 4); leo.SetFrameDelay(Animation.State.JUMP_ATTACK1, 1, 4); leo.SetFrameDelay(Animation.State.JUMP_ATTACK1, 2, 4); leo.AddSprite(Animation.State.JUMP_TOWARD_ATTACK1, new Sprite("Sprites/Actors/Leo/JumpAttack2", Animation.Type.ONCE), true); leo.SetSpriteOffSet(Animation.State.JUMP_TOWARD_ATTACK1, 30, -60); leo.SetFrameDelay(Animation.State.JUMP_TOWARD_ATTACK1, 4); leo.SetFrameDelay(Animation.State.JUMP_TOWARD_ATTACK1, 1, 4); leo.SetFrameDelay(Animation.State.JUMP_TOWARD_ATTACK1, 2, 4); leo.SetTossFrame(Animation.State.JUMP_ATTACK1, 1); leo.SetTossFrame(Animation.State.JUMP_TOWARD_ATTACK1, 1); leo.AddSprite(Animation.State.JUMP_RECOVER1, new Sprite("Sprites/Actors/Leo/JumpRecover1", Animation.Type.REPEAT, 3)); leo.SetSpriteOffSet(Animation.State.JUMP_RECOVER1, 20, -80); leo.SetFrameDelay(Animation.State.JUMP_RECOVER1, 5); leo.SetFrameDelay(Animation.State.JUMP_RECOVER1, 1, 6); leo.SetFrameDelay(Animation.State.JUMP_RECOVER1, 2, 6); leo.AddAnimationLink(new Animation.Link(Animation.State.JUMP_ATTACK1, Animation.State.JUMP_RECOVER1, 8)); leo.AddAnimationLink(new Animation.Link(Animation.State.JUMP_TOWARD_ATTACK1, Animation.State.JUMP_RECOVER1, 9)); leo.SetDefaultAttackChain(new ComboAttack.Chain(new List<ComboAttack.Move>{ new ComboAttack.Move(Animation.State.ATTACK1, 222000, 7), new ComboAttack.Move(Animation.State.ATTACK1, 222000, 7), new ComboAttack.Move(Animation.State.ATTACK1, 222000, 7)/*, new ComboAttack.Move(Animation.State.ATTACK4, 222000, 4), new ComboAttack.Move(Animation.State.ATTACK4, 222000, 4), new ComboAttack.Move(Animation.State.ATTACK4, 222000, 4), new ComboAttack.Move(Animation.State.ATTACK2, 222000, 8), new ComboAttack.Move(Animation.State.ATTACK3, 222000, 7), new ComboAttack.Move(Animation.State.ATTACK3, 222000, 7), new ComboAttack.Move(Animation.State.ATTACK3, 222000, 7), new ComboAttack.Move(Animation.State.ATTACK5, 222000, 7), new ComboAttack.Move(Animation.State.ATTACK6, 222000, 8)*/ })); /*leo.SetFrameDelay(Animation.State.ATTACK1, 1); leo.SetFrameDelay(Animation.State.ATTACK2, 1); leo.SetFrameDelay(Animation.State.ATTACK3, 1); leo.SetFrameDelay(Animation.State.ATTACK4, 1); leo.SetFrameDelay(Animation.State.ATTACK5, 1); leo.SetFrameDelay(Animation.State.ATTACK6, 1);*/ leo.AddBoundsBox(new CLNS.BoundsBox(125, 283, -30, 80, 40)); leo.SetScale(1.6f, 2.2f); leo.SetPostion(400, 0, 200); drum = new Entity(Entity.EntityType.OBSTACLE, "DRUM1"); drum.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Misc/Drum")); drum.SetAnimationState(Animation.State.STANCE); //drum.AddBox(new CLNS.BoundingBox(CLNS.BoxType.BODY_BOX, 125, 210, -30, 80)); drum.AddBoundsBox(new CLNS.BoundsBox(125, 210, -30, 80, 20)); drum.SetScale(2.2f, 2.6f); drum.SetPostion(700, 0, 200); drum.SetSpriteOffSet(Animation.State.STANCE, 32, 90); drum.SetDepthOffset(-5); drum.SetDepth(20); drum.SetHeight(170); drum.SetWidth(125); drum2 = new Entity(Entity.EntityType.OBSTACLE, "DRUM2"); drum2.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Misc/Drum")); drum2.SetAnimationState(Animation.State.STANCE); drum2.AddBox(new CLNS.BoundingBox(CLNS.BoxType.BODY_BOX, 125, 210, -30, 80)); drum2.AddBoundsBox(new CLNS.BoundsBox(125, 210, -30, 80, 20)); drum2.SetScale(2.2f, 2.6f); drum2.SetPostion(500, 0, 200); drum2.SetSpriteOffSet(Animation.State.STANCE, 32, 90); drum2.SetDepthOffset(-5); drum2.SetDepth(20); drum2.SetHeight(170); drum2.SetWidth(125); drum3 = new Entity(Entity.EntityType.OBSTACLE, "DRUM3"); drum3.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Misc/Drum")); drum3.SetAnimationState(Animation.State.STANCE); drum3.AddBox(new CLNS.BoundingBox(CLNS.BoxType.BODY_BOX, 125, 210, -30, 80)); drum3.AddBoundsBox(new CLNS.BoundsBox(125, 210, -30, 80, 20)); drum3.SetScale(2.2f, 2.6f); drum3.SetPostion(290, -180, 200); drum3.SetGroundBase(-180); drum3.SetSpriteOffSet(Animation.State.STANCE, 32, 90); drum3.SetDepthOffset(-5); drum3.SetDepth(20); drum3.SetHeight(170); drum3.SetWidth(125); drum4 = new Entity(Entity.EntityType.OBSTACLE, "DRUM4"); drum4.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Misc/Drum")); drum4.SetAnimationState(Animation.State.STANCE); drum4.AddBox(new CLNS.BoundingBox(CLNS.BoxType.BODY_BOX, 125, 210, -30, 80)); drum4.AddBoundsBox(new CLNS.BoundsBox(125, 210, -30, 80, 20)); drum4.SetScale(2.2f, 2.6f); drum4.SetPostion(1200, -320, 200); drum4.SetGroundBase(-320); drum4.SetSpriteOffSet(Animation.State.STANCE, 32, 90); drum4.SetDepthOffset(-5); drum4.SetDepth(20); drum4.SetHeight(170); drum4.SetWidth(125); drum4.SetDimension(125, 170); drum3.SetDimension(125, 170); drum2.SetDimension(125, 170); drum.SetDimension(125, 170); /*hitSpark1 = new Entity(Entity.EntityType.OTHER, "SPARK1"); hitSpark1.AddSprite(Animation.State.STANCE, new Sprite("Sprites/Actors/Leo/Spark1", Animation.Type.REPEAT)); hitSpark1.SetAnimationState(Animation.State.STANCE); hitSpark1.SetFrameDelay(Animation.State.STANCE, 40); hitSpark1.SetScale(1.2f, 1.2f); hitSpark1.SetPostion(600, 0, 400); hitSpark1.SetFade(225);*/ leo.SetScale(1.8f, 2.6f); leo.SetHeight(180); level1 = new Stage1(); bar = new LifeBar(0, 0); renderManager = new RenderManager(); renderManager.AddEntity(leo); renderManager.AddEntity(taskMaster); /*renderManager.AddEntity(drum); renderManager.AddEntity(drum2); renderManager.AddEntity(drum3); renderManager.AddEntity(drum4); renderManager.AddLevel(level1); *///renderManager.AddEntity(hitSpark1); collisionManager = new CollisionManager(renderManager); collisionManager.AddEntity(leo); //collisionManager.AddEntity(leo2); /*collisionManager.AddEntity(drum); collisionManager.AddEntity(drum2); collisionManager.AddEntity(drum3); collisionManager.AddEntity(drum4); */ command = new InputHelper.CommandMove("TEST", Animation.State.ATTACK6, new List<InputHelper.KeyState> { new InputHelper.KeyState(InputHelper.KeyPress.A | InputHelper.KeyPress.X, InputHelper.ButtonState.Pressed), new InputHelper.KeyState(InputHelper.KeyPress.RIGHT, InputHelper.ButtonState.Held, (float)9, 30), new InputHelper.KeyState(InputHelper.KeyPress.RIGHT, InputHelper.ButtonState.Released, 30), new InputHelper.KeyState(InputHelper.KeyPress.RIGHT, InputHelper.ButtonState.Released, 30), new InputHelper.KeyState(InputHelper.KeyPress.RIGHT, InputHelper.ButtonState.Pressed), new InputHelper.KeyState(InputHelper.KeyPress.RIGHT, InputHelper.ButtonState.Released) }); leo.AddCommandMove(command); leo.SetAnimationState(Animation.State.STANCE); leo.SetBaseOffset(-60, -30f); //control = new InputControl(leo, PlayerIndex.One); inputManager = new InputManager(); inputManager.AddControl(leo, PlayerIndex.One); // TODO: use this.Content to load your game content here }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } KeyboardState state = Keyboard.GetState(); if (currentState == GameState.Playing || currentState == GameState.Victory) { // Moving Logic if (state.IsKeyDown(Keys.A)) { player.Position.X -= 7; } if (state.IsKeyDown(Keys.D)) { player.Position.X += 7; } // Collision Logic if (player.Position.X >= GraphicsDevice.Viewport.Width - player.GetWidth()) { player.Position.X = GraphicsDevice.Viewport.Width - player.GetWidth(); } else if (player.Position.X <= 0) { player.Position.X = 0; } // Shooting if (state.IsKeyDown(Keys.Space) && cooldown >= 30) { Texture2D bullet = Content.Load <Texture2D>("blast_shot_blue"); playerBullets.Add( new Bullet(bullet, new Vector2(player.Position.X + player.GetWidth() / 2 - bullet.Width / 2, player.Position.Y), player, new Vector2(0, -8) )); cooldown = 0; } // Player Bullets Logic for (int i = 0; i < playerBullets.Count; i++) { Bullet bullet = playerBullets[i]; bullet.Move(); bullet.UpdateLogic(); if (bullet.Position.Y <= 0 - bullet.GetHeight() || bullet.Position.Y >= GraphicsDevice.Viewport.Height) { playerBullets.Remove(bullet); } foreach (List <Invader> invadersList in invaders) { foreach (Invader invader in invadersList) { invader.UpdateLogic(); if (bullet.Intersects(invader.Box) && invader.IsShot == false) { invader.IsShot = true; bullet.isUsed = true; break; } } } for (int a = 0; a < invaders.Count; a++) { List <Invader> invadersList = invaders[a]; for (int b = 0; b < invadersList.Count; b++) { if (invadersList[b].IsShot) { invadersList.Remove(invadersList[b]); } } } if (bullet.isUsed) { playerBullets.Remove(bullet); } } // Invaders moving foreach (List <Invader> invadersList in invaders) { foreach (Invader invader in invadersList) { invader.Move(); if (invader.Position.X >= GraphicsDevice.Viewport.Width - invader.GetWidth()) { invader.Position.X = GraphicsDevice.Viewport.Width - invader.GetWidth(); invader.ChangeVelocityXSign(); } if (invader.Position.X <= 0) { invader.Position.X = 0; invader.ChangeVelocityXSign(); } invader.UpdateLogic(); } } // Invaders Shooting Random random = new Random(); foreach (List <Invader> invadersList in invaders) { foreach (Invader invader in invadersList) { if (invader.Position.Y >= 0 - invader.GetHeight() && invader.Cooldown >= invader.MaxCooldown) { Texture2D bullet = Content.Load <Texture2D>("blast_shot_red"); invaderBullets.Add( new Bullet(bullet, new Vector2(invader.Position.X + invader.GetWidth() / 2 - bullet.Width / 2, invader.Position.Y + invader.GetHeight()), invader, new Vector2(0, 8) )); invader.ResetCooldown(); } else if (invader.Position.Y >= 0 - invader.GetHeight()) { invader.IncreaseCooldown(); } } } // Invaders Bullets Logic for (int i = 0; i < invaderBullets.Count; i++) { Bullet bullet = invaderBullets[i]; bullet.Move(); bullet.UpdateLogic(); if (bullet.Position.Y <= 0 - bullet.GetHeight() || bullet.Position.Y >= GraphicsDevice.Viewport.Height) { invaderBullets.Remove(bullet); } if (player.IntersectsCut(bullet.Box, 30)) { bullet.isUsed = true; currentState = GameState.GameOver; } if (bullet.isUsed) { invaderBullets.Remove(bullet); } } // Check if row is empty for (int a = 0; a < invaders.Count; a++) { if (invaders[a].Count == 0) { invaders.Remove(invaders[a]); } } // Victory Conditions if (invaders.Count == 0) { currentState = GameState.Victory; } player.UpdateLogic(); invaderCooldown += 1; cooldown += 1; } // Fullscreen on or off if (state.IsKeyDown(Keys.F)) { if (graphics.IsFullScreen == true) { graphics.IsFullScreen = false; } else if (graphics.IsFullScreen == false) { graphics.IsFullScreen = true; } graphics.ApplyChanges(); } // Runs this if it is game over. if (currentState == GameState.GameOver || currentState == GameState.Victory) { if (state.IsKeyDown(Keys.R)) { currentState = GameState.Restarting; } } // Runs when restarting if (currentState == GameState.Restarting) { if (restartingCounter == 0) { restartingCounter = 180; currentState = GameState.Playing; } if (restartingCounter == 180) { Texture2D ship = Content.Load <Texture2D>("ship_2"); Texture2D invader = Content.Load <Texture2D>("invader_1"); player = new Player(ship, new Vector2(GraphicsDevice.Viewport.Width / 2 - (ship.Width / 2) * scale, GraphicsDevice.Viewport.Height - ship.Height * scale)); player.SetScale(scale); int invaderCount = 8; int rows = 4; invaders = new List <List <Invader> >(); playerBullets = new List <Bullet>(); invaderBullets = new List <Bullet>(); Random random = new Random(); for (int a = 0; a < rows; a++) { invaders.Add(new List <Invader>()); for (int i = 0; i < invaderCount; i++) { invaders[a].Add(new Invader( invader, new Vector2(((GraphicsDevice.Viewport.Width / invaderCount) * i), 10 - (invader.Height + 20) * a), new Vector2(4, 0.25f), random.Next(160, 300) )); } } } restartingCounter -= 1; } base.Update(gameTime); }