public void ApplyAction(GameAction action) { if (action == GameAction.Reset) { Map.SetFromState(MapHistory[0]); if (MapHistory.Count > 1) { MapHistory.RemoveRange(1, MapHistory.Count - 1); } } else if (action == GameAction.Undo) { if (MapHistory.Count > 1) { MapHistory.RemoveAt(MapHistory.Count - 1); Map.SetFromState(MapHistory[MapHistory.Count - 1]); } } else { Map.Trucks[0].DoAction(action); for (int i = 1; i < Map.Trucks.Length; i++) { ((AITruck)Map.Trucks[i]).DoAction(); } MapHistory.Add(Map.GetState()); } }
public Game(int level) { Map = Parser.Parse(level); MapHistory.Add(Map.GetState()); }