public BoardBuilder() { this.status = FIELDSTATUS.NORMAL; this.tempBuilding = new Building(); this.tempUnit = new Unit(); //set initial info label parameters this.infoMenu.AutoSize = true; this.infoMenu.Location = new System.Drawing.Point(0, 0); this.infoMenu.Size = new System.Drawing.Size(35, 13); this.infoMenu.TopLevel = false; this.infoMenu.Parent = this; this.infoMenu.BackColor = Color.White; this.infoMenu.Name = "infoMenu"; this.Controls.Add(this.infoMenu); //set initial hoverForm this.LocationChanged += BoardBuilder_LocationChanged; //update hoverform this.hoverForm.Location = this.Location; this.hoverForm.Name = "hoverForm"; this.hoverForm.Click += hoverForm_Click; InitializeComponent(); List <string> DebugPlayerList = new List <string>(); DebugPlayerList.Add("Hans"); DebugPlayerList.Add("Kurt"); generateBoard(10, 10, DebugPlayerList); }
//check if unit can be paid and init hoverform for placement selection private void prepareUnit() { //check for building cost if (mainBoard.getActivePlayer().pay(tempUnit.getRecruitmentCost())) { status = FIELDSTATUS.RECRUITING; hoverForm.setSize(1); hoverForm.Show(this); } else { MessageBox.Show(this, "Not enough ressources. Need " + tempUnit.getRecruitmentCost().ToString()); //not enough cards to pay } }
//check if building can be paid and init hoverform for placement selection private void prepareBuild() { //check for building cost if (mainBoard.getActivePlayer().pay(tempBuilding.getBuildCost())) { status = FIELDSTATUS.BUILDING; hoverForm.setSize(tempBuilding.getBuildPlace().Count); hoverForm.Show(this); } else { MessageBox.Show(this, "Not enough ressources. Need " + tempBuilding.getBuildCost().ToString()); //not enough cards to pay } }
/** * HANDLERS FOR BUTTON MOUSE EVENTS * */ #region BUTTONMOUSEEVENTS //handles click on hoverform void hoverForm_Click(object sender, EventArgs e) { if (status == FIELDSTATUS.BUILDING) { //check for building place if (checkFieldTypeForBuild()) { tempBuilding.build(hoverPosition[0], hoverPosition[1]); //build building mainBoard.getField(hoverPosition[0], hoverPosition[1]).building = tempBuilding; //add to field mainBoard.getActivePlayer().addBuilding(ref mainBoard.getField(hoverPosition[0], hoverPosition[1]).building); //add to players buildings mainField[hoverPosition[0], hoverPosition[1]].setBuildingImage(tempImage); } else { mainBoard.getActivePlayer().addCard(new List <Card>(tempBuilding.getBuildCost())); //reimburse player for payed cost } status = FIELDSTATUS.NORMAL; hoverForm.Hide(); } else if (status == FIELDSTATUS.RECRUITING) { //check for building place if (checkFieldTypeForSpawn()) { tempUnit.rectruit(hoverPosition[0], hoverPosition[1]); //spawn unit mainBoard.getField(hoverPosition[0], hoverPosition[1]).unit = tempUnit; //add to field mainBoard.getActivePlayer().addUnit(tempUnit); //add to players units mainField[hoverPosition[0], hoverPosition[1]].setUnitImage(tempImage); } else { mainBoard.getActivePlayer().addCard(new List <Card>(tempUnit.getRecruitmentCost())); //reimburse player for payed cost } status = FIELDSTATUS.NORMAL; hoverForm.Hide(); } else { hoverForm.Hide(); } }