示例#1
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();
        }
示例#2
0
 /**
  * Constructs a list containing the elements of the specified collection, in the order they are returned by the
  * collection's iterator.
  *
  * @param tc
  *            the collection whose elements are to be placed into this list
  * @throws NullPointerException
  *            if the specified collection is null
  */
 public TileCollection(TileCollection tc) : base(tc)
 {
 }
示例#3
0
        // ---- Mutator methods ----

        /**
         * Sets this player's selected tiles buffer to the given TileCollection
         *
         * @param tc
         *            the TileCollection representing the tiles this player selected
         */
        public void setSelectedTiles(TileCollection tc)
        {
            selectedTiles = tc;
            updateButtons();
        }