public void LoadLevel(int n)
        {
            Canvas.Children.Clear();
            String[] lines = System.IO.File.ReadAllLines("Level" + n + ".txt");
            int      h     = lines.Length;
            int      w     = lines[0].Length;

            game = new Sprite[h, w];
            for (int j = 0; j < h; j++)
            {
                for (int i = 0; i < w; i++)
                {
                    char letter = lines[j][i];
                    if (letter == 'X')
                    {
                        ImageSprite a = new ImageSprite(Image.FromFile("acorn.png"), i * unitSize, j * unitSize);
                        game[j, i] = a;
                        a.Width    = unitSize;
                        a.Height   = unitSize;
                        Canvas.Children.Add(a);
                    }
                    if (letter == 'B')
                    {
                        bulldozer        = new PhysicsSprite(Image.FromFile("acorn.png"), i * unitSize, j * unitSize);
                        game[j, i]       = bulldozer;
                        bulldozer.Width  = unitSize * .5;
                        bulldozer.Height = unitSize * .5;
                        Canvas.Children.Add(bulldozer);
                        bulldozerX = i;
                        bulldozerY = j;
                    }
                }
            }
        }
        public void LoadLevel(int lvl)
        {
            paused        = true;
            lines         = System.IO.File.ReadAllLines("Level" + lvl + ".txt");
            Canvas        = new Sprite(0, 0, -255, -255, true);
            Canvas.Width  = lines[0].Length * unitSize;
            Canvas.Height = lines.Length * unitSize;
            firstPause    = true;
            ninja         = new Player(Image.FromFile("ninja.png"), unitSize, unitSize, unitSize, unitSize, 1, 1, true);
            Animation move = new Animation();

            move.IList    = new int[] { 0, 1, 2, 3, 4 };
            move.JList    = new int[] { 0, 0, 0, 0, 0 };
            move.TimeList = new int[] { 1, 1, 1, 1, 1 };
            ninja.Animations.Add("move", move);
            Animation stand = new Animation();

            stand.IList    = new int[] { 0, 0, 0, 0, 0 };
            stand.JList    = new int[] { 0, 0, 0, 0, 0 };
            stand.TimeList = new int[] { 1, 1, 1, 1, 1 };
            ninja.Animations.Add("stand", stand);
            for (int j = 0; j < lines.Length; j++)
            {
                for (int i = 0; i < lines[j].Length; i++)
                {
                    char letter = lines[j][i];
                    if (letter == 'X')
                    {
                        ImageSprite a = new ImageSprite(Image.FromFile("wall.png"), i * unitSize, j * unitSize, i, j, true);
                        a.Width  = unitSize;
                        a.Height = unitSize;
                        Canvas.Children.Add(a);
                    }
                    else if (letter == 'G')
                    {
                        ImageSprite a = new GoalSprite(Image.FromFile("green.png"), i * unitSize, j * unitSize, i, j, false);
                        a.Width  = unitSize;
                        a.Height = unitSize;
                        Canvas.Children.Add(a);
                    }
                    else if (letter == 'M')
                    {
                        ImageSprite a = new PhysicsSprite(Image.FromFile("crate.jpg"), i * unitSize, j * unitSize, i, j, false);
                        a.Width  = unitSize;
                        a.Height = unitSize;
                        Canvas.Children.Add(a);
                    }
                }
            }
            Canvas.Children.Add(ninja);
            Width         = lines[0].Length * unitSize;
            Height        = lines.Length * unitSize;
            Canvas.XScale = (float)Width / (float)Canvas.Width;
            Canvas.YScale = (float)Height / (float)Canvas.Height;
        }
        public void Pause()
        {
            if (firstPause)
            {
                firstPause = false;
                mainMenu   = new ImageSprite(Image.FromFile("green.png"), Width / 4, Height / 8, -255, -255, true);

                mainMenu.Width  = Width / 2;
                mainMenu.Height = Height / 4;
                Canvas.Children.Add(mainMenu);

                menuText = new TextSprite("Reset", Width / 4, Height / 8, -255, -255, true);
                mainMenu.Children.Add(menuText);


                next = new ImageSprite(Image.FromFile("FullBlock.png"), Width / 4, Height / 8 * 5, -269, -255, true);

                next.Width  = Width / 2;
                next.Height = Height / 4;
                Canvas.Children.Add(next);

                nextText = new TextSprite("Next Level", Width / 4, Height / 8, -255, -255, true);
                next.Children.Add(nextText);
            }
            if (paused)
            {
                next.Visible = false;
            }
            if (paused)
            {
                mainMenu.Visible = false;
            }
            paused = !paused;

            foreach (Sprite child in Canvas.Children)
            {
                child.Visible = !child.Visible;
            }
        }
 public SokobanGame() : base()
 {
     bulldozer        = new PhysicsSprite(Image.FromFile("acorn.png"), unitSize, unitSize);
     bulldozer.Width  = unitSize;
     bulldozer.Height = unitSize;
     String[] lines = System.IO.File.ReadAllLines("Level1.txt");
     for (int j = 0; j < lines.Length; j++)
     {
         for (int i = 0; i < lines[j].Length; i++)
         {
             char letter = lines[j][i];
             if (letter == 'X')
             {
                 ImageSprite a = new ImageSprite(Image.FromFile("acorn.png"), i * unitSize, j * unitSize);
                 a.Width  = unitSize;
                 a.Height = unitSize;
                 Canvas.Children.Add(a);
             }
         }
     }
     Canvas.Children.Add(bulldozer);
 }