Example #1
0
        /// <summary>
        /// PigWorld already has gaps between each pair of cells,
        /// so put walls in some of them, for demonstration purposes.
        /// </summary>
        private void CreateDemoWalls()
        {
            PigWorld.FillVerticalGap(1, 2);
            PigWorld.FillVerticalGap(2, 2);
            PigWorld.FillVerticalGap(3, 2);
            PigWorld.FillVerticalGap(4, 2);
            PigWorld.FillVerticalGap(5, 2);
            PigWorld.FillVerticalGap(2, 4);
            PigWorld.FillVerticalGap(3, 4);
            PigWorld.FillVerticalGap(4, 4);
            PigWorld.FillVerticalGap(5, 4);
            PigWorld.FillHorizontalGap(6, 0);
            PigWorld.FillHorizontalGap(6, 1);
            PigWorld.FillHorizontalGap(6, 2);
            PigWorld.FillHorizontalGap(6, 3);

            PigWorld.FillVerticalGap(0, 5);
            PigWorld.FillVerticalGap(1, 5);
            PigWorld.FillVerticalGap(2, 5);
            PigWorld.FillVerticalGap(3, 5);
            PigWorld.FillVerticalGap(4, 5);
            PigWorld.FillVerticalGap(5, 5);

            PigWorld.FillVerticalGap(3, 7);
            PigWorld.FillVerticalGap(4, 7);
            PigWorld.FillVerticalGap(6, 7);
            PigWorld.FillVerticalGap(7, 7);
            PigWorld.FillVerticalGap(8, 7);
        }
Example #2
0
        /// <summary>
        /// Set-up the third demo, by adding various objects (and walls) to PigWorld.
        /// </summary>
        public void SetupDemo3()
        {
            BoyPig  boyPig  = new BoyPig(PigWorld, new Position(4, 3));
            GirlPig girlPig = new GirlPig(PigWorld, new Position(4, 5));

            Tree tree1 = new Tree(PigWorld, new Position(0, 4));
            Tree tree2 = new Tree(PigWorld, new Position(4, 4));
            Tree tree3 = new Tree(PigWorld, new Position(8, 4));

            Wolf wolf = new Wolf(PigWorld, new Position(0, 0));

            PigFood pigFood1 = new PigFood(PigWorld, new Position(8, 0));
            PigFood pigFood2 = new PigFood(PigWorld, new Position(8, 1));
            PigFood pigFood3 = new PigFood(PigWorld, new Position(7, 0));
            PigFood pigFood4 = new PigFood(PigWorld, new Position(1, 8));
            PigFood pigFood5 = new PigFood(PigWorld, new Position(0, 8));
            PigFood pigFood6 = new PigFood(PigWorld, new Position(0, 7));

            PigWorld.FillVerticalGap(2, 5);
            PigWorld.FillVerticalGap(3, 1);
            PigWorld.FillVerticalGap(3, 6);
            PigWorld.FillVerticalGap(4, 1);
            PigWorld.FillVerticalGap(4, 6);
            PigWorld.FillVerticalGap(5, 1);
            PigWorld.FillVerticalGap(5, 6);
            PigWorld.FillVerticalGap(6, 2);

            PigWorld.FillHorizontalGap(1, 3);
            PigWorld.FillHorizontalGap(1, 4);
            PigWorld.FillHorizontalGap(1, 5);
            PigWorld.FillHorizontalGap(3, 1);
            PigWorld.FillHorizontalGap(3, 7);
            PigWorld.FillHorizontalGap(4, 0);
            PigWorld.FillHorizontalGap(4, 8);
            PigWorld.FillHorizontalGap(6, 3);
            PigWorld.FillHorizontalGap(6, 4);
            PigWorld.FillHorizontalGap(6, 5);
        }