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(); } } }
/* * 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; }
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; }
public void updateResourceDisplays() { for (int i = 0; i < 5; i++) { Board.ResourceType rType = (Board.ResourceType)i; resourceDisplays[i].setCount(this.getResourceCount(rType)); } }
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; }
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(); }
/** * 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); }
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); }
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(); }
/** * 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); }
/* * 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); }
public static string PlayerGotResourceFromPlayer(Player toPlayer, Player fromPlayer, Board.ResourceType res) { return(toPlayer.getName() + " got " + Board.RESOURCE_NAMES[(int)res] + " from " + fromPlayer.getName() + "."); }
public void setType(Board.ResourceType rType) { type = rType; //Set the icon. pbIcon.BackgroundImage = new Bitmap("Resources/" + Board.iconImageResourceNames[(int)type]); }
public ResourceCard(Board.ResourceType resource) { this.resourceType = resource; }
public void setTradeOutputResource(Board.ResourceType res) { tradeOutputResource = res; }
public Harbor(int requiredCount, Board.ResourceType resource) { tradeRequiredResourceCount = requiredCount; tradeOutputResource = resource; validTradeLocations = new List <Settlement>(); }