private void btn_addpos_Click(object sender, EventArgs e) { AddDefPosForm addDefPosForm = new AddDefPosForm(PrimalManager, Side); addDefPosForm.Show(); addDefPosForm.FormClosed += (senderr, ee) => { if (PrimalManager.tempDefPos != null) { SelectDefPos = PrimalManager.tempDefPos; l_position.Text = SelectDefPos.ToShortString(); l_leader.Text = SelectDefPos.getLeader(); PrimalManager.tempDefPos = null; } }; }
public UnitsForm(SimulatorManager SM, TypesEnums.UnitSide S, IUnit U) { InitializeComponent(); PrimalSimulator = SM; Side = S; Type = (TypesEnums.UnitType)U.UnitType; Init(); EditableUnit = U; SelectDefPos = U.MyDefPosition; if (SelectDefPos != null) { l_position.Text = SelectDefPos.ToShortString(); l_leader.Text = SelectDefPos.getLeader(); chbox_hold.Checked = true; } txt_name.Text = U.UnitName; PrimalSimulator.ConsoleBox.WriteLineToConsole("UnitForm READY! Mode: EDIT"); btn_ok.Text = "Edit unit"; }
private void btn_add_Click(object sender, EventArgs e) { if (SelectedUnit == null || num_amount.Value == 0) { return; } if (U == null) { U = PrimalManager.UnitManager.CreateUnit(Side, SelectedUnit.Type); } if (U.UnitType == (int)TypesEnums.UnitType.Infantry) { U.SetStats(SelectedUnit.ATACK, SelectedUnit.DEF, SelectedUnit.LIFE, SelectedUnit.MOV, SelectedUnit.INC, SelectedUnit.LEVEL); } if (U.UnitType == (int)TypesEnums.UnitType.Cavalerly) { U.SetStats(SelectedUnit.ATACK, SelectedUnit.DEF, SelectedUnit.LIFE, SelectedUnit.MOV, SelectedUnit.INC, SelectedUnit.LEVEL, SelectedUnit.DEF_HORSE, SelectedUnit.LIFE_HORSE, SelectedUnit.MOV_HORSE); } if (U.UnitType == (int)TypesEnums.UnitType.Archers) { U.SetStats(SelectedUnit.ATACK, SelectedUnit.DEF, SelectedUnit.LIFE, SelectedUnit.MOV, SelectedUnit.INC, SelectedUnit.LEVEL, SelectedUnit.RANGE); } U.UnitAmount = (int)num_amount.Value; U.UnitName = SelectedUnit.UnitName; if (SelectDefPos != null && chbox_hold.Checked) { if (!SelectDefPos.LoadUnit(U)) { MessageBox.Show("Position is out of capacity!"); return; } else { PrimalManager.ConsoleBox.WriteLineToConsole("Unit " + U.ToShortString() + " now hold position " + SelectDefPos.ToShortString()); } } this.Close(); }
private void btn_ok_Click(object sender, EventArgs e) { if (!CheckData()) { return; } IUnit U = EditableUnit; if (U == null) { U = PrimalSimulator.UnitManager.CreateUnit(Side, Type); } if (Type == TypesEnums.UnitType.Infantry) { U.SetStats((int)num_atc.Value, (int)num_def.Value, (int)num_life.Value, (int)num_move.Value, (int)num_inc.Value, (int)num_level.Value); } if (Type == TypesEnums.UnitType.Cavalerly) { U.SetStats((int)num_atc.Value, (int)num_def.Value, (int)num_life.Value, (int)num_move.Value, (int)num_inc.Value, (int)num_level.Value, (int)num_horsedef.Value, (int)num_horselife.Value, (int)num_horsemove.Value); } if (Type == TypesEnums.UnitType.Archers) { U.SetStats((int)num_atc.Value, (int)num_def.Value, (int)num_life.Value, (int)num_move.Value, (int)num_inc.Value, (int)num_level.Value, (int)num_range.Value); } U.UnitAmount = (int)num_amount.Value; U.UnitName = txt_name.Text; EditableUnit = U; if (SelectDefPos != null) { if (chbox_hold.Checked) { if (!SelectDefPos.LoadUnit(U)) { MessageBox.Show("Position is out of capacity!"); return; } else { PrimalSimulator.ConsoleBox.WriteLineToConsole("Unit " + U.ToShortString() + " now hold position " + SelectDefPos.ToShortString()); } } else { if (U.MyDefPosition != null) { U.MyDefPosition.UnloadUnit(U); } } } //MessageBox.Show("Object was create or edit!"); this.Close(); }