public Vector2 ConvertToBlueCord(CordPoint cord) { float xCord = (-(cord.x / realWidth) * blueAreaSize.x) + (blueAreaSize.x / 2); float yCord = ((cord.y / realHeight) * blueAreaSize.y) - (blueAreaSize.y / 2); return(new Vector2(xCord, yCord)); }
public Vector2 ConvertToRedCord(CordPoint cord) { float xCord = ((cord.x / realWidth) * redAreaSize.x) - (redAreaSize.x / 2); float yCord = ((cord.y / realHeight) * redAreaSize.y) - (redAreaSize.y / 2); return(new Vector2(xCord, yCord)); }
public void ComparePreviousCord(CordPoint newCord) { float xDifference = Mathf.Abs(tempCordList[lastRecordedTime].x - newCord.x); float yDifference = Mathf.Abs(tempCordList[lastRecordedTime].y - newCord.y); if (xDifference >= thresholdDifference || yDifference >= thresholdDifference) { if ((xDifference >= thresholdDifference && yDifference >= thresholdDifference) || generatedNewCord == true) { lastRecordedTime = stopwatch.GetTimer(); tempCordList.Add(lastRecordedTime, newCord); generatedNewCord = !generatedNewCord; Debug.Log("New cord drawn"); } else { tempCordList.Remove(lastRecordedTime); lastRecordedTime = stopwatch.GetTimer(); tempCordList.Add(lastRecordedTime, newCord); Debug.LogWarning("Edited the coordinate"); } draw.GenerateDot(lastRecordedTime, tempCordList[lastRecordedTime]); //create a delegate that call LastDotUIUpdate } //if there is no significant changes, then it will be discarded. }
public void testFunction() { try { while (comm.uartData.IsOpen) { something = JsonReader.ConvertToCordPoint(comm.ReadData()); } } catch (TimeoutException e) { Debug.LogError("The comm didnt send any message, please retry again"); }; // insert warningUI }
public void ReceiveCord(CordPoint cordPoint) //call this function when received a vaild data { if (newList) { tempCordList.Clear(); stopwatch.StartTimer(); lastRecordedTime = stopwatch.GetTimer(); tempCordList.Add(lastRecordedTime, cordPoint); newList = false; draw.GenerateDot(lastRecordedTime, cordPoint); } else { ComparePreviousCord(cordPoint); } }
public void GenerateDot(float time, CordPoint cordPoint)//add dual function in the future { switch (cordPoint.type) { case 0: //Red Side coordinate RectTransform redVar = Instantiate(sampleDotGenerate, RedGroup).GetComponent <RectTransform>(); redVar.anchoredPosition = calCord.ConvertToRedCord(cordPoint); dotList.Add(time, redVar); break; case 1: //Blue Side coordinate RectTransform blueVar = Instantiate(sampleDotGenerate, BlueGroup).GetComponent <RectTransform>(); blueVar.anchoredPosition = calCord.ConvertToBlueCord(cordPoint); dotList.Add(time, blueVar); break; } }
public void ChangeEndDot(CordPoint cordPoint) { dotList[dotList.Count].anchoredPosition = cordPoint.type == 0 ? calCord.ConvertToRedCord(cordPoint) : calCord.ConvertToRedCord(cordPoint); Debug.Log("DOT ALTERED"); }
private void Awake() { coordinate = new CordPoint(0, 0, 0, 0); }
public void SetData(CordPoint newCord) { coordinate.x = newCord.x; coordinate.y = newCord.y; Debug.Log("New Coordinate initialzied"); }