public static Wall CopyAndFlip(Wall wall, CoordinateFlipper flipper, Dictionary<int, Entity> flippedEntities) { if (flippedEntities.ContainsKey(wall.Id)) return (Wall) flippedEntities[wall.Id]; var copy = new Wall(wall) { X = flipper.CalculateFlippedX(wall.X), Y = flipper.CalculateFlippedY(wall.Y) }; flippedEntities.Add(copy.Id, copy); return copy; }
public static Ship CopyAndFlip(Ship ship, CoordinateFlipper flipper, Dictionary<int, Entity> flippedEntities) { if (flippedEntities.ContainsKey(ship.Id)) return (Ship) flippedEntities[ship.Id]; var copy = new Ship(ship) { PlayerNumber = ship.PlayerNumber == 1 ? 2 : 1, X = flipper.CalculateFlippedX(ship.X + (ship.Width - 1)), Y = flipper.CalculateFlippedY(ship.Y) }; flippedEntities.Add(copy.Id, copy); return copy; }
public static Bullet CopyAndFlip(Bullet bullet, CoordinateFlipper flipper, Dictionary<int, Entity> flippedEntities) { if (flippedEntities.ContainsKey(bullet.Id)) return (Bullet) flippedEntities[bullet.Id]; var copy = new Bullet(bullet) { PlayerNumber = bullet.PlayerNumber == 1 ? 2 : 1, X = flipper.CalculateFlippedX(bullet.X), Y = flipper.CalculateFlippedY(bullet.Y) }; flippedEntities.Add(copy.Id, copy); return copy; }
public static Missile CopyAndFlip(Missile missile, CoordinateFlipper flipper, Dictionary<int, Entity> flippedEntities) { if (flippedEntities.ContainsKey(missile.Id)) return (Missile) flippedEntities[missile.Id]; var copy = new Missile(missile) { PlayerNumber = missile.PlayerNumber == 1 ? 2 : 1, X = flipper.CalculateFlippedX(missile.X), Y = flipper.CalculateFlippedY(missile.Y) }; flippedEntities.Add(copy.Id, copy); return copy; }
public static AlienFactory CopyAndFlip(AlienFactory alienFactory, CoordinateFlipper flipper, Dictionary<int, Entity> flippedEntities) { if (flippedEntities.ContainsKey(alienFactory.Id)) return (AlienFactory) flippedEntities[alienFactory.Id]; var copy = new AlienFactory(alienFactory) { PlayerNumber = alienFactory.PlayerNumber == 1 ? 2 : 1, X = flipper.CalculateFlippedX(alienFactory.X + (alienFactory.Width - 1)), Y = flipper.CalculateFlippedY(alienFactory.Y) }; flippedEntities.Add(copy.Id, copy); return copy; }
public static Shield CopyAndFlip(Shield shield, CoordinateFlipper flipper, Dictionary<int, Entity> flippedEntities) { if (flippedEntities.ContainsKey(shield.Id)) return (Shield) flippedEntities[shield.Id]; var copy = new Shield(shield) { PlayerNumber = shield.PlayerNumber == 1 ? 2 : 1, X = flipper.CalculateFlippedX(shield.X), Y = flipper.CalculateFlippedY(shield.Y) }; flippedEntities.Add(copy.Id, copy); return copy; }
public static Alien CopyAndFlip(Alien alien, CoordinateFlipper flipper, Dictionary<int, Entity> flippedEntities) { if (flippedEntities.ContainsKey(alien.Id)) return (Alien) flippedEntities[alien.Id]; var copy = new Alien(alien) { PlayerNumber = alien.PlayerNumber == 1 ? 2 : 1, DeltaX = -alien.DeltaX, DeltaY = -alien.DeltaY, X = flipper.CalculateFlippedX(alien.X), Y = flipper.CalculateFlippedY(alien.Y) }; flippedEntities.Add(copy.Id, copy); return copy; }