public ReplayPlayer(SerializationRoot serializationRoot) { _serializationRoot = serializationRoot; RootBody = new Body(); DT = _serializationRoot.DT; _objectLoaders = new List<ObjectLoader>( _serializationRoot.LoggingObjects .Select(x => new ObjectLoader(x, RootBody))); _scoreLoader = new ScoreLoader(_serializationRoot.Scores, _serializationRoot.Penalties, _serializationRoot.RobotCountForScores); }
public static string Convert(SerializationRoot input) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); var replayPlayer = new ReplayPlayer(input); Body rootBody = replayPlayer.RootBody; existing = new Dictionary<int, List<object>>(); result = new List<object>(); result.Add(replayPlayer.DT); rootBody.ChildAdded += BodyAdded; while (!replayPlayer.IsAtEnd) { iter = new List<string>(); replayPlayer.Update(); result.Add(iter); } var res = (new JavaScriptSerializer()).Serialize(result); //replace id of root body to 0 res = res.Replace(","+rootBody.Id+",", ",0,"); return res; }