////////////////////////////////////////////////////////////////////////// void Start() { if (devMode == false) { listener = new UdpClient(3500); groupEP = new IPEndPoint(IPAddress.Any, 3500); } else { listener = new UdpClient(2300); groupEP = new IPEndPoint(IPAddress.Any, 2300); } listener.Client.ReceiveBufferSize = 0; listener.Client.ReceiveTimeout = 15; textX.text = "X: 0"; textY.text = "Y: 0"; UDPsendFirst("VC|controllerStartUpAcknowledgment"); cData = new controllerData(); gData = new gameData(); }
private void getData() { string message = listenForData(); try { controllerData data = JsonConvert.DeserializeObject <controllerData>(message); x0pos = data.X0pos; y0pos = data.Y0pos; z0pos = data.Z0pos; fx = data.Fx; fy = data.Fy; fz = data.Fz; encoder1 = data.Encoder1; encoder2 = data.Encoder2; pot1 = data.Pot1; pot2 = data.Pot2; theta0 = data.Theta0; theta1 = data.Theta1; x1pos = data.X1pos; y1pos = data.Y1pos; z1pos = data.Z1pos; x2pos = data.X2pos; y2pos = data.Y2pos; z2pos = data.Z2pos; errorOccurred = data.ErrorOccurred; } catch { } }
public void load() { restViewer(); choosesnSession = sName.text.Split('|')[0]; choosesnGame = gName.text.Split('|')[1]; choosesnGameSession = gName.text.Split('|')[0]; connect.Open(); command.CommandText = "SELECT Controller_Data, Controller_Data_Time, Game_Data, Game_Data_Time FROM Gameplay_Data WHERE Username = '******' AND Session_ID = '" + choosesnSession + "'AND Game_Name = '" + choosesnGame + "'AND Play_Count = '" + choosesnGameSession + "'"; bool first = true; using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) { if (first) { preConTime = Convert.ToDateTime(reader["Controller_Data_Time"]); preGameTime = Convert.ToDateTime(reader["Game_Data_Time"]); } else { controllerData cData = JsonConvert.DeserializeObject <controllerData>(reader["Controller_Data"].ToString()); currentConTime = Convert.ToDateTime(reader["Controller_Data_Time"]); TimeSpan cElapsed = currentConTime - preConTime; preConTime = currentConTime; string addC = cData.X2pos.ToString() + "|" + cData.Y2pos.ToString() + "|" + cData.Z2pos.ToString() + "|" + cElapsed.TotalMilliseconds; controllerDataList.Add(addC); gameData gData = JsonConvert.DeserializeObject <gameData>(reader["Game_Data"].ToString()); currentGameTime = Convert.ToDateTime(reader["Game_Data_Time"]); TimeSpan gElapsed = currentGameTime - preGameTime; preGameTime = currentGameTime; string addG = gData.Xtarget.ToString() + "|" + gData.Ytarget.ToString() + "|" + gData.Ztarget.ToString() + "|" + gElapsed.TotalMilliseconds; gameDataList.Add(addG); } first = false; } }; connect.Close(); string[] currentCData = controllerDataList[0].Split('|'); prePlayerPos = (new Vector3(float.Parse(currentCData[0]), float.Parse(currentCData[1]), float.Parse(currentCData[2]))) / 30 + new Vector3(3.565f, 1.315f, 0); string[] currentGData = gameDataList[0].Split('|'); preTargetPos = (new Vector3(float.Parse(currentGData[0]), float.Parse(currentGData[1]), float.Parse(currentGData[2]))) / 30 + new Vector3(3.565f, 1.315f, 0); gameplayPostion.maxValue = controllerDataList.Count - 1; gameSet = true; /* * for (int i = 0; i < controllerDataList.Count; i++) * { * currentCData = controllerDataList[i].Split('|'); * Vector3 playerTarilPos = (new Vector3(float.Parse(currentCData[0]), float.Parse(currentCData[1]), float.Parse(currentCData[2]))) / 30 + new Vector3(3.565f, 1.315f, 0); * var newName = Instantiate(Trail, playerTarilPos, Quaternion.identity); * newName.name = i.ToString(); * } */ }