public void Clear() { this.fs = null; this.f = null; this.ga = null; this.r = null; }
public void Init() { r = new Mock <Robot>(); f = new Mock <IField>(); ga = new IGameObject[10, 10]; f.Object.SetFieldArr(ga); f.Object.SetRobot(r.Object); fs = new FieldSnapshot(ga, r.Object, f.Object); }
static void Run() { MoveUpC = new MoveUpCommand(field.GetRobot()); MoveLeftC = new MoveLeftCommand(field.GetRobot()); MoveRightC = new MoveRightCommand(field.GetRobot()); MoveDownC = new MoveDownCommand(field.GetRobot()); Console.WriteLine(shower.GetString(field)); inputP.ClearDict(); inputP.AddMap("w", MoveUpC); inputP.AddMap("a", MoveLeftC); inputP.AddMap("d", MoveRightC); inputP.AddMap("s", MoveDownC); string comm = Console.ReadLine(); if (comm == "undo") { try { history.Undo(); field = app.UpdateField(field); } catch (NoHistoryException e) { Console.WriteLine(exc + e); Console.ReadLine(); } } else { try { RobotCommand robotCommand = inputP.GetCommandByInput(comm); IFieldSnapshot snapshot = robotCommand.AddBackup(field.CreateSnapshot()); RobotCommand command = inputP.ExecuteByInput(comm); history.Push((RobotCommand)command.Clone()); field = app.UpdateField(field); } catch (RobotCommandException e) { Console.WriteLine(exc + e); Console.ReadLine(); } } //Console.Clear(); Run(); }
public IFieldSnapshot AddBackup(IFieldSnapshot snap) { this.backUp = snap; return(snap); }