public static string ToTurretString(TurretCommand.Commands value) { switch (value) { case TurretCommand.Commands.Rotate45CW: return(Properties.Resources.TurretCommandRotate45CW); case TurretCommand.Commands.Rotate45CCW: return(Properties.Resources.TurretCommandRotate45CCW); case TurretCommand.Commands.Rotate90CW: return(Properties.Resources.TurretCommandRotate90CW); case TurretCommand.Commands.Rotate90CCW: return(Properties.Resources.TurretCommandRotate90CCW); case TurretCommand.Commands.Up: return(Properties.Resources.TurretCommandUp); case TurretCommand.Commands.Down: return(Properties.Resources.TurretCommandDown); case TurretCommand.Commands.Shoot: return(Properties.Resources.TurretCommandShoot); case TurretCommand.Commands.None: return(Properties.Resources.TurretCommandNone); } throw new Exception($"Строкового представления {value} в перечислении TurretCommand.Commands не существует."); }
public Action(MoveCommand.Commands moveCommand = MoveCommand.Commands.None, ChargeCommand.Commands chargeCommand = ChargeCommand.Commands.None, TurretCommand.Commands turretCommand = TurretCommand.Commands.None) { commands = new Command[(int)Types.Count]; commands[(int)Types.Move] = new MoveCommand(moveCommand); commands[(int)Types.Charge] = new ChargeCommand(chargeCommand); commands[(int)Types.Turret] = new TurretCommand(turretCommand); }
private static void DgvAlgorithm_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { DataGridViewRow row = ((DataGridView)sender).Rows[e.RowIndex]; // Собираем команды с добавленного DataGridViewRow MoveCommand.Commands moveCommand = Utilities.ToMoveCommand(row.Cells[1].Value.ToString()); ChargeCommand.Commands chargeCommand = Utilities.ToChargeCommand(row.Cells[2].Value.ToString()); TurretCommand.Commands turretCommand = Utilities.ToTurretCommand(row.Cells[3].Value.ToString()); // Добавляем Action в соответствующий алгоритм танка Action action = new Action(moveCommand, chargeCommand, turretCommand); ParallelAlgorithm.GetInstance().InsertAction((int)((DataGridView)sender).Tag, action, e.RowIndex); }
public void TurretCommand(TurretCommand.Commands command) { switch (command) { case FireSafety.TurretCommand.Commands.Rotate45CW: turret.RotateBy(45); break; case FireSafety.TurretCommand.Commands.Rotate45CCW: turret.RotateBy(-45); break; case FireSafety.TurretCommand.Commands.Rotate90CW: turret.RotateBy(90); break; case FireSafety.TurretCommand.Commands.Rotate90CCW: turret.RotateBy(-90); break; case FireSafety.TurretCommand.Commands.Up: turret.UpDown(true); break; case FireSafety.TurretCommand.Commands.Down: turret.UpDown(false); break; case FireSafety.TurretCommand.Commands.Shoot: turret.Shoot(); break; default: break; } }