public static List <Ghosts.GhostFrame> LoadLocalGhostAttempt() { List <Ghosts.GhostFrame> frames = new List <Ghosts.GhostFrame>(); string str = PlayerPrefs.GetString("localGhostAttempt_" + SceneManager.GetActiveScene().name, null); //Debug.Log("GhostStr: " + str); if (str != null || str != "") { string[] chunks = str.Split(new char[] { ':' }, System.StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < chunks.Length; i++) { Ghosts.GhostFrame frame = new Ghosts.GhostFrame(); string[] bits = chunks[i].Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries); frame.timestamp = float.Parse(bits[0]); //Debug.Log("Time: " + frame.timestamp); frame.pos = new Vector2(0, 0); frame.pos.x = float.Parse(bits[1]); frame.pos.y = float.Parse(bits[2]); frame.ani = (LegController2Script.aniTypes) int.Parse(bits[3]); frame.ghostEvent = (Ghosts.GhostEvent) int.Parse(bits[4]); frame.dir = float.Parse(bits[5]); frames.Add(frame); } return(frames); } else { return(null); } }
public static List <Ghosts.GhostFrame> StringToFrames(string str) { List <Ghosts.GhostFrame> frames = new List <Ghosts.GhostFrame>(); string[] chunks = str.Split(new char[] { ':' }, System.StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < chunks.Length; i++) { Ghosts.GhostFrame frame = new Ghosts.GhostFrame(); string[] bits = chunks[i].Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries); frame.timestamp = float.Parse(bits[0]); //Debug.Log("Time: " + frame.timestamp); frame.pos = new Vector2(0, 0); frame.pos.x = float.Parse(bits[1]); frame.pos.y = float.Parse(bits[2]); frame.ani = (LegController2Script.aniTypes) int.Parse(bits[3]); frame.ghostEvent = (Ghosts.GhostEvent) int.Parse(bits[4]); frame.dir = float.Parse(bits[5]); frames.Add(frame); } return(frames); }