コード例 #1
0
        private void createResourceSelectors(bool playerControlsEnabled, bool otherPartyControlsEnabled)
        {
            //Create the player resource selectors
            for (int i = 0; i < 5; i++)
            {
                Board.ResourceType resType        = (Board.ResourceType)i;
                ResourceSelector   playerSelector = new ResourceSelector(resType);
                playerResourceSelectors.Add(playerSelector);
                pnlPlayer.Controls.Add(playerSelector);
                playerSelector.Location = new Point(5, i * playerSelector.Height + 1);
                if (!playerControlsEnabled)
                {
                    playerSelector.hideControls();
                }

                ResourceSelector otherSelector = new ResourceSelector(resType);
                otherResourceSelectors.Add(otherSelector);
                pnlOther.Controls.Add(otherSelector);
                otherSelector.Location = new Point(5, i * otherSelector.Height + 1);
                if (!otherPartyControlsEnabled)
                {
                    otherSelector.hideControls();
                }
            }
        }
コード例 #2
0
        /*
         * This will allow the player to choose what resources they loose when
         * the dice land on a "7" while the player has more than 7 resources on hand.
         */
        public void loadPlayerResourceLoss(Player pl)
        {
            //Load the player's resource selectors
            for (int i = 0; i < 5; i++)
            {
                Board.ResourceType resType        = (Board.ResourceType)i;
                ResourceSelector   playerSelector = new ResourceSelector(resType);
                playerResourceSelectors.Add(playerSelector);
                pnlPlayer.Controls.Add(playerSelector);
                playerSelector.Location = new Point(5, i * playerSelector.Height + 1);
                playerSelector.hideControls();
                playerSelector.Click += playerClickResourceSelectorRobber;
            }
            lblInstructions.Visible  = true;
            btnAccept.Enabled        = false;
            initiatingPlayer         = pl;
            lblPlayerTitle.Text      = pl.getName();
            lblPlayerTitle.BackColor = pl.getColor();
            //Disable the cancel button
            btnCancel.Visible = false;
            int numToGive = pl.getTotalResourceCount() / 2; //Since this is an integer, VS will automatically drop the decimal which is essentailly the same as floor(count/2)

            minimumPlayerInput = numToGive;
            //Hide the other section
            lblTradeName.Text = "";
            pnlOther.Visible  = false;
            //Show the player some instructions.
            lblInstructions.Text = "Please select " + numToGive + " resource to give up.";

            btnClearSelection.Click += playerClickResourceSelectorRobber;
        }
コード例 #3
0
 public ResourceSelector(Board.ResourceType type)
 {
     InitializeComponent();
     pictureBox1.BackgroundImage = new Bitmap("Resources/" + Board.iconImageResourceNames[(int)type]);
     lblResName.Text             = Board.RESOURCE_NAMES[(int)type];
     this.type = type;
 }
コード例 #4
0
 public void updateResourceDisplays()
 {
     for (int i = 0; i < 5; i++)
     {
         Board.ResourceType rType = (Board.ResourceType)i;
         resourceDisplays[i].setCount(this.getResourceCount(rType));
     }
 }
コード例 #5
0
        public TerrainTile(Panel p, Board.ResourceType resourceType, Bitmap image) : base(p)
        {
            this.tileType        = resourceType;
            adjascentSettlements = new List <Settlement>();
            adjascentRoads       = new List <Road>();

            //Atuomatically determine what image we need to display depending on the resource type
            this.BackgroundImage = image;
            this.Size            = BackgroundImage.Size;
            this.BackColor       = Color.Transparent;
        }
コード例 #6
0
 private void acceptClickMonopoly(object sender, EventArgs e)
 {
     //Somehow transfer all resources to the initiating player from other player's hands.
     //Determine the selected resource
     foreach (ResourceSelector resSelect in playerResourceSelectors)
     {
         if (resSelect.getSelected())
         {
             this.selectedResource = resSelect.type;
         }
     }
     this.Close();
 }
コード例 #7
0
        /**
         *  Gets the number of the specified resource type.
         */
        public int getResourceCount(Board.ResourceType type)
        {
            int count = 0;

            foreach (ResourceCard res in resources)
            {
                if (res.getResourceType() == type)
                {
                    count++;
                }
            }
            return(count);
        }
コード例 #8
0
        public bool canGiveOutResource(Board.ResourceType type, int count)
        {
            bool can       = false;
            int  cardCount = 0;

            foreach (ResourceCard rc in resources)
            {
                if (rc.getResourceType() == type)
                {
                    cardCount++;
                }
            }
            if (cardCount >= count)
            {
                can = true;
            }
            return(can);
        }
コード例 #9
0
 public override void executeUpdate(Object sender, EventArgs e)
 {
     //We know what resource was selected by asking the trade window.
     Board.ResourceType selectedResource = tradeWindow.selectedResource;
     foreach (Player player in theBoard.playerOrder)
     {
         if (player != theBoard.currentPlayer)
         {
             int count = player.getResourceCount(selectedResource);
             for (int i = 0; i < count; i++)
             {
                 theBoard.currentPlayer.giveResource(player.takeResource(selectedResource));
             }
         }
     }
     MessageBox.Show(theBoard.currentPlayer.getName() + " has taken " + Board.RESOURCE_NAMES[(int)selectedResource] + " from all players.");
     endExecution();
 }
コード例 #10
0
        /**
         *  Gets a resource card witht the matching type from the player's
         *  deck. If no available card exists null is returned.
         */
        public ResourceCard takeResource(Board.ResourceType type)
        {
            ResourceCard rCard = null;

            foreach (ResourceCard res in resources)
            {
                if (res.getResourceType() == type)
                {
                    rCard = res;
                }
            }
            if (rCard != null)
            {
                resources.Remove(rCard);
            }
            updateResourceDisplays();
            return(rCard);
        }
コード例 #11
0
        /*
         *  Players can get this type of resource. If no resource is available, none is given.
         */
        public ResourceCard giveOutResource(Board.ResourceType type)
        {
            ResourceCard c = null;

            for (int i = 0; i < resources.Count; i++)
            {
                if (resources[i].getResourceType() == type)
                {
                    c = resources[i];
                    i = resources.Count;
                }
            }

            if (c != null)
            {
                resources.Remove(c);
            }
            else
            {
                //MessageBox.Show("There are no more resource cards in the deck.");
            }
            return(c);
        }
コード例 #12
0
 public static string PlayerGotResourceFromPlayer(Player toPlayer, Player fromPlayer, Board.ResourceType res)
 {
     return(toPlayer.getName() + " got " + Board.RESOURCE_NAMES[(int)res] + " from " + fromPlayer.getName() + ".");
 }
コード例 #13
0
 public void setType(Board.ResourceType rType)
 {
     type = rType;
     //Set the icon.
     pbIcon.BackgroundImage = new Bitmap("Resources/" + Board.iconImageResourceNames[(int)type]);
 }
コード例 #14
0
 public ResourceCard(Board.ResourceType resource)
 {
     this.resourceType = resource;
 }
コード例 #15
0
 public void setTradeOutputResource(Board.ResourceType res)
 {
     tradeOutputResource = res;
 }
コード例 #16
0
 public Harbor(int requiredCount, Board.ResourceType resource)
 {
     tradeRequiredResourceCount = requiredCount;
     tradeOutputResource        = resource;
     validTradeLocations        = new List <Settlement>();
 }