/// <summary> /// Creates a response object containg the data from the server /// </summary> /// <param name="dataStream">The input stream</param> public static NetworkResponse Parse(MemoryStream dataStream) { ResponseClashEntry response = new ResponseClashEntry(); response.isNew = DataReader.ReadBool(dataStream); if (!response.isNew) { //read in data on own defense setup response.terrain = DataReader.ReadString(dataStream); response.config = new Dictionary <int, List <Vector2> >(); int count = DataReader.ReadInt(dataStream); // Debug.Log(count); for (int i = 0; i < count; i++) { int id = DataReader.ReadInt(dataStream); int instanceCount = DataReader.ReadInt(dataStream); List <Vector2> positions = new List <Vector2>(); for (int j = 0; j < instanceCount; j++) { float x = DataReader.ReadFloat(dataStream); float y = DataReader.ReadFloat(dataStream); positions.Add(new Vector2(x, y)); } response.config.Add(id, positions); } } return(response); }
/// <summary> /// Creates a response object containg the data from the server /// </summary> /// <param name="dataStream">The input stream</param> public static NetworkResponse Parse(MemoryStream dataStream) { ResponseClashEntry response = new ResponseClashEntry(); response.isNew = DataReader.ReadBool(dataStream); if (!response.isNew) { //read in data on own defense setup response.terrain = DataReader.ReadString(dataStream); response.config = new Dictionary<int, List<Vector2>>(); int count = DataReader.ReadInt(dataStream); // Debug.Log(count); for (int i = 0; i < count; i++) { int id = DataReader.ReadInt(dataStream); int instanceCount = DataReader.ReadInt(dataStream); List<Vector2> positions = new List<Vector2>(); for(int j = 0; j < instanceCount; j++){ float x = DataReader.ReadFloat(dataStream); float y = DataReader.ReadFloat(dataStream); positions.Add(new Vector2(x, y)); } response.config.Add(id, positions); } } return response; }