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(); }
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(); }