private void ParseGameLogs(string s) { var lines = s.Split('\n'); var totalMs = int.Parse(lines[0]); var pseudo = lines[1].Split(' '); Logs.Init(pseudo, ColorMaker.DivideColors((uint)pseudo.Length)); for (var i = 2; i < lines.Length - 1; i++) { Logs.AddLog(Logs.Decode(lines[i]), float.Parse(lines[i].Split(' ')[0]) / totalMs); } readyLogs = true; }
private void ParseGameSave(string s) { var lines = s.Split('\n'); var playersName = lines[0].Split(' ').ToList(); nbPlayers = playersName.Count; var colors = ColorMaker.DivideColors((uint)nbPlayers); var sortPlayers = new List <ColorPlayer>(); for (var i = 0; i < nbPlayers; i++) { sortPlayers.Add(new ColorPlayer(playersName[i], colors[i], i)); } sortPlayers.Sort(); playersName.Clear(); var sortedColors = new Color[nbPlayers]; for (var i = 0; i < nbPlayers; i++) { playersName.Add(sortPlayers[i].Name); sortedColors[i] = sortPlayers[i].Color; } sizeMap = int.Parse(lines[1]); TimeTurn = int.Parse(lines[2]); Unit = WIDTH / (float)sizeMap; players = new Player[nbPlayers]; Scoreboard.SetPlayers(playersName.ToArray(), sortedColors); for (var i = 0; i < nbPlayers; i++) { var pos = lines[i + 3].Split(' '); players[i] = new Player(colors[i], int.Parse(pos[0]), int.Parse(pos[1]), Instantiate(head, transform.parent), sortPlayers.FindIndex(c => c.Index == i)); } nbTours = lines.Length - (nbPlayers + 3); if (lines[lines.Length - 1].Split(' ').Length != nbPlayers) { nbTours--; } TotalDuration = nbTours * TimeTurn; for (var i = 0; i < nbTours; i++) { var moves = lines[nbPlayers + 3 + i].Split(' '); for (var p = 0; p < nbPlayers; p++) { players[p].AddTrail(int.Parse(moves[p]), (float)i / nbTours, (float)(i + 1) / nbTours); } } foreach (var player in players) { player.EndInit(); } readySave = true; }