internal GameShips(ContentManager content) { _shipTextures = new Dictionary <KeyValuePair <ShipType, ShipTier>, Texture2D>(); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.BattleCruiser, ShipTier.Tier1), content.Load <Texture2D>("Images\\Ships\\Allies\\BattleCruiser\\Tier1")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.BattleCruiser, ShipTier.Tier2), content.Load <Texture2D>("Images\\Ships\\Allies\\BattleCruiser\\Tier2")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.BattleCruiser, ShipTier.Tier3), content.Load <Texture2D>("Images\\Ships\\Allies\\BattleCruiser\\Tier3")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.BattleCruiser, ShipTier.Tier4), content.Load <Texture2D>("Images\\Ships\\Allies\\BattleCruiser\\Tier4")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.FighterCarrier, ShipTier.Tier1), content.Load <Texture2D>("Images\\Ships\\Allies\\FighterCarrier\\Tier1")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.FighterCarrier, ShipTier.Tier2), content.Load <Texture2D>("Images\\Ships\\Allies\\FighterCarrier\\Tier2")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.FighterCarrier, ShipTier.Tier3), content.Load <Texture2D>("Images\\Ships\\Allies\\FighterCarrier\\Tier3")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.FighterCarrier, ShipTier.Tier4), content.Load <Texture2D>("Images\\Ships\\Allies\\FighterCarrier\\Tier4")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.TorpedoShip, ShipTier.Tier1), content.Load <Texture2D>("Images\\Ships\\Allies\\TorpedoShip\\Tier1")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.TorpedoShip, ShipTier.Tier2), content.Load <Texture2D>("Images\\Ships\\Allies\\TorpedoShip\\Tier2")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.TorpedoShip, ShipTier.Tier3), content.Load <Texture2D>("Images\\Ships\\Allies\\TorpedoShip\\Tier3")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.TorpedoShip, ShipTier.Tier4), content.Load <Texture2D>("Images\\Ships\\Allies\\TorpedoShip\\Tier4")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.Drone, ShipTier.Tier1), content.Load <Texture2D>("Images\\Ships\\Allies\\FighterCarrier\\Drones\\Tier1")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.Drone, ShipTier.Tier2), content.Load <Texture2D>("Images\\Ships\\Allies\\FighterCarrier\\Drones\\Tier2")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.EnemyBattleCruiser, ShipTier.Tier1), content.Load <Texture2D>("Images\\Ships\\Enemies\\BattleCruiser1")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.EnemyBattleCruiser, ShipTier.Tier2), content.Load <Texture2D>("Images\\Ships\\Enemies\\Battlecruiser2")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.EnemyBattleCruiser, ShipTier.Tier3), content.Load <Texture2D>("Images\\Ships\\Enemies\\Battlecruiser3")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.EnemyBattleCruiser, ShipTier.Tier4), content.Load <Texture2D>("Images\\Ships\\Enemies\\Battlecruiser4")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.EnemyFighterCarrier, ShipTier.Tier4), content.Load <Texture2D>("Images\\Ships\\Enemies\\Mothership")); _shipTextures.Add(new KeyValuePair <ShipType, ShipTier>(ShipType.EnemyDrone, ShipTier.Tier1), content.Load <Texture2D>("Images\\Ships\\Enemies\\Scout")); Bullets = new ShipBullets(content); }
public Ship() : base(new Position(X, Y)) { _sprite = new string[3] { @" _|_ ", @" /\_/\ ", @" |_/ \_| " }; _bullets = new ShipBullets(); }
/// <summary> /// The Update method for the ship (Called once every frame) /// </summary> public override void Update() { if (!LifeLost) { // What to write to the buffer WriteToBuffer(); // Check for user input GetInput(); // Moves the ship Move(); } // Update the bullets ShipBullets.UpdateBullets(); }
/// <summary> /// Checks for the user input /// </summary> private void GetInput() { // Create a new ConsoleKeyInfo ConsoleKeyInfo keyInfo = new ConsoleKeyInfo(); // Loop while (Console.KeyAvailable) { // Set the keyInfo to the read key keyInfo = Console.ReadKey(true); } // Check what key the user pressed switch (keyInfo.Key) { // If the user pressed the Left Arrow case ConsoleKey.LeftArrow: // Change the ship movement to go Left currentMove = MoveType.LEFT; break; // If the user pressed the Right Arrow case ConsoleKey.RightArrow: // Change the ship movement to go Right currentMove = MoveType.RIGHT; break; // If the user pressed the X key case ConsoleKey.X: // Stop the ship movement currentMove = MoveType.NONE; break; // If the user pressed space bar case ConsoleKey.Spacebar: ShipBullets.Add(coordinates.X + 3, coordinates.Y, MoveType.UP); break; } }