コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public static MissileController CopyAndFlip(MissileController missileController, CoordinateFlipper flipper,
                                                    Dictionary <int, Entity> flippedEntities)
        {
            if (flippedEntities.ContainsKey(missileController.Id))
            {
                return((MissileController)flippedEntities[missileController.Id]);
            }

            var copy = new MissileController(missileController)
            {
                PlayerNumber = missileController.PlayerNumber == 1 ? 2 : 1,
                X            = flipper.CalculateFlippedX(missileController.X + (missileController.Width - 1)),
                Y            = flipper.CalculateFlippedY(missileController.Y)
            };

            flippedEntities.Add(copy.Id, copy);
            return(copy);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }