예제 #1
0
        // ---- Get/check state methods ----

        /**
         * Returns a TileCollection representing the tiles currently on the given build row
         *
         * @param row
         *            the build row
         * @return a TileCollection representing the tiles currently on the given build row
         */
        public TileCollection getBuildRowTiles(int row)
        {
            TileCollection tc = new TileCollection();
            BuildRow       br = buildRows[row];

            tc.addTiles(br.color, br.count);
            return(tc);
        }
예제 #2
0
            /**
             * Gets the discard tiles from tiling this row
             *
             * @return the discard tiles from tiling this row
             */
            public TileCollection getDiscard()
            {
                TileCollection discard = new TileCollection();

                // Equal to the row number because one is kept for the wall
                discard.addTiles(color, row);
                count = 0;
                color = null;
                return(discard);
            }
예제 #3
0
        //private bool netGame;
        //private bool host;
        //HubConnection connection;

        public Game(int players, string[] names)//, HubConnection conn = null, bool host = false)
        {
            //netGame = (conn != null);
            //if (netGame)
            //{
            //    connection = conn;
            //}
            //this.host = host;

            locs[2] = loc5;
            locs[3] = loc7;
            locs[4] = loc9;

            InitializeComponent();
            SuspendLayout();
            ClientSize   = new Size(1040, 1040);
            oldSize      = BaseSize;
            FormClosing += OnFormClosing;

            if (players < 2 || players > 4)
            {
                throw new ArgumentException("Invalid number of players, must be 2-4.");
            }
            numPlayers   = players;
            playerBoards = new PlayerBoard[numPlayers];
            if (names.Length < numPlayers)
            {
                throw new ArgumentException("Not enough names given for the number of players");
            }
            for (int i = 0; i < numPlayers; ++i)
            {
                playerBoards[i] = new PlayerBoard(this, names[i]);
            }

            bag = new TileCollection();
            bag.addTiles(Color.BLUE, 20);
            bag.addTiles(Color.YELLOW, 20);
            bag.addTiles(Color.RED, 20);
            bag.addTiles(Color.BLACK, 20);
            bag.addTiles(Color.TEAL, 20);

            myLocs       = locs[numPlayers];
            factories    = new TileCollection[myLocs.Length];
            factoryViews = new Factory[myLocs.Length];
            for (int i = 0; i < myLocs.Length; ++i)
            {
                factories[i]    = new TileCollection();
                factoryViews[i] = new Factory(this, i)
                {
                    Location = myLocs[i], TabIndex = i
                };
                Controls.Add(factoryViews[i]);
            }

            centerArea = new TileCollection();

            boxLid = new TileCollection();

            winner = "none";
            // Randomize first player
            curPlayer = (int)(Utils.rand() * numPlayers);
            playerBoards[curPlayer].updateTitle(true);
            for (int i = 0; i < numPlayers; ++i)
            {
                playerBoards[i].Show();
            }
            resetCenter();

            // Make common area window ~70% of screen height
            int height = (int)(Screen.PrimaryScreen.Bounds.Height * 0.7);

            ClientSize = new Size(height, height);
            UpdateScale(height);

            ResumeLayout();
        }