private void tochar()
        {
            Ship ship = new Ship(currentField);
            Cart cart = new Cart(startpoint);

            EmptyField emptyField = new EmptyField();
            Dock dock = new Dock();
            Rail rail = new Rail('-');
            StartPoint startpointer = new StartPoint('A');
            Storage storage = new Storage();
            Switch switchje = new Switch('S');
            Water water = new Water();

            ship.ToChar();
            cart.ToChar();

            emptyField.ToChar();
            dock.ToChar();
            rail.ToChar();
            startpointer.ToChar();
            storage.ToChar();
            switchje.ToChar();
            water.ToChar();
        }
Exemplo n.º 2
0
 // Rather than have separate factory methods for players and invaders, I combined the code into
 // a ShipControlFactory method to reduce duplicate code and make future changes easier.
 public static FrameworkElement ShipControlFactory(Ship ship, double scale)
 {
     AnimatedImage shipImage = new AnimatedImage();
     if (ship is Invader)
     {
         Invader invader = ship as Invader;
         shipImage = new AnimatedImage(GenerateImageList(invader.InvaderType),
             TimeSpan.FromMilliseconds(500));
     }
     else if (ship is Player)
     {
         Player player = ship as Player;
         shipImage = new AnimatedImage(new List<string>() { "player.png", "player.png" },
             TimeSpan.FromSeconds(1));
     }
     shipImage.Width = ship.Size.Width * scale;
     shipImage.Height = ship.Size.Height * scale;
     SetCanvasLocation(shipImage, ship.Location.X * scale, ship.Location.Y * scale);
     return shipImage;
 }