예제 #1
0
        public static void Generate(int width, int height, int numPlayers, out BdtBoard board, out BoardCell[][] cells)
        {
            // create the board
            board = new BdtBoard(numPlayers);

            board.BeginSetup();
            {
                // cities
                var miami    = board.AddCity("Miami").SetCoordinates(top: 100, left: 100, width: 100, height: 100);
                var olympia  = board.AddCity("Olympia").SetCoordinates(top: 100, left: 400, width: 100, height: 100);
                var austin   = board.AddCity("Austin").SetCoordinates(top: 400, left: 400, width: 100, height: 100);
                var kirkland = board.AddCity("Kirland").SetCoordinates(top: 400, left: 100, width: 100, height: 100);

                // tracks
                board.AddTrack(color: TrenColor.Red, position: TrackPosition.Middle, length: 3, new TrenElement[] { miami, olympia });
                board.AddTrack(color: TrenColor.Green, position: TrackPosition.Middle, length: 4, new TrenElement[] { olympia, austin });
                board.AddTrack(color: TrenColor.Yellow, position: TrackPosition.Middle, length: 3, new TrenElement[] { austin, kirkland });
                board.AddTrack(color: TrenColor.Pink, position: TrackPosition.Middle, length: 4, new TrenElement[] { kirkland, miami });

                // destinations
                board.AddDestination(miami, austin);
                board.AddDestination(miami, olympia);
                board.AddDestination(miami, kirkland);
                board.AddDestination(olympia, austin);
                board.AddDestination(olympia, kirkland);
                board.AddDestination(austin, kirkland);
            }
            board.EndSetup();

            // button locations
            var left    = 10;
            var top     = height - 100;
            var bwidth  = 100;
            var bheight = 50;
            var buttons = new Dictionary <TrenElementButtonType, BoardCell>()
            {
                { TrenElementButtonType.DestinationDraw, new BoardCell(new Point[]
                    {
                        new engine.Common.Point(x: (left + (bwidth * 0)), y: top, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 0)), y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 0)) + bwidth, y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 0)) + bwidth, y: top, z: 0)
                    }) },
                { TrenElementButtonType.TrenBlindDraw, new BoardCell(new Point[]
                    {
                        new engine.Common.Point(x: (left + (bwidth * 1.1f)), y: top, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 1.1f)), y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 1.1f)) + bwidth, y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 1.1f)) + bwidth, y: top, z: 0)
                    }) },
                { TrenElementButtonType.TrenDraw1, new BoardCell(new Point[]
                    {
                        new engine.Common.Point(x: (left + (bwidth * 2.2f)), y: top, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 2.2f)), y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 2.2f)) + bwidth, y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 2.2f)) + bwidth, y: top, z: 0)
                    }) },
                { TrenElementButtonType.TrenDraw2, new BoardCell(new Point[]
                    {
                        new engine.Common.Point(x: (left + (bwidth * 3.3f)), y: top, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 3.3f)), y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 3.3f)) + bwidth, y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 3.3f)) + bwidth, y: top, z: 0)
                    }) },
                { TrenElementButtonType.TrenDraw3, new BoardCell(new Point[]
                    {
                        new engine.Common.Point(x: (left + (bwidth * 4.4f)), y: top, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 4.4f)), y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 4.4f)) + bwidth, y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 4.4f)) + bwidth, y: top, z: 0)
                    }) },
                { TrenElementButtonType.TrenDraw4, new BoardCell(new Point[]
                    {
                        new engine.Common.Point(x: (left + (bwidth * 5.5f)), y: top, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 5.5f)), y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 5.5f)) + bwidth, y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 5.5f)) + bwidth, y: top, z: 0)
                    }) },
                { TrenElementButtonType.TrenDraw5, new BoardCell(new Point[]
                    {
                        new engine.Common.Point(x: (left + (bwidth * 6.6f)), y: top, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 6.6f)), y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 6.6f)) + bwidth, y: top + bheight, z: 0),
                        new engine.Common.Point(x: (left + (bwidth * 6.6f)) + bwidth, y: top, z: 0)
                    }) }
            };

            // convert to cells
            cells = Generate(board, buttons);
        }