// void savePattern(string word) { Point[] mypoints = new Point[setPattern.Count]; mypoints = setPattern.ToArray(); PointPattern pa = new PointPattern(); pa.Name = word; pa.Points = mypoints; setPattern.Clear(); PointManager.AddInput(path, pa); Debug.Log("shoooo"); }
// Update is called once per frame void Update() { float step = 2.0f * Time.deltaTime; // mycoroutine = move(p); //move(p); // move2(p); // transform.position = Vector3.MoveTowards(transform.position, p, step); //transform.position = Vector3.MoveTowards(transform.position, t, step); // string mystring = currentWord; mycoroutine = move2(); //char[] chars = mystring.ToCharArray(); // int l = chars.Length; // transform.position = h; if (!start) { getWord(); //target = p; start = true; count = 0; findTarget(count); // yield return new WaitForSeconds(5); // StopAllCoroutines(); // StartCoroutine(mycoroutine); transform.position = target; } // Debug.Log("Current word is " + currentWord[count]+ target); transform.position = Vector3.MoveTowards(transform.position, target, step); Debug.Log(transform.position + " and " + target); Debug.Log(Vector3.Distance(transform.position, target)); //set points point.X = transform.position.x; //xpos;// mycursor.transform.position.x; point.Y = transform.position.y; // setPattern.Add(point); if ((Vector3.Distance(transform.position, target) < 0.2f)) { // Swap the position of the cylinder. //x.transform.position *= -1.0f; // yield return new WaitForSeconds(5); Debug.Log("h"); //switch (mystring[count]) //{ // case 'h': // target = h; // // transform.position = Vector3.MoveTowards(transform.position, h, step); // Debug.Log("h"); // break; // case 'i': // target = i; // Debug.Log("i"); // break; // case 'e': // target = e; // Debug.Log("e"); // break; // default: // break; //} if (count > currentWord.Length - 1) { start = false; Point[] mypoints = new Point[setPattern.Count]; mypoints = setPattern.ToArray(); PointPattern pa = new PointPattern(); pa.Name = mycurrentWord; pa.Points = mypoints; setPattern.Clear(); PointManager.AddInput(path, pa); } if (start) { findTarget(count); } count++; } //if (count >= currentWord.Length) //{ // start = false; //} // mycoroutine = move(chars, count, l); //StartCoroutine(mycoroutine); // //foreach (char c in mystring) //{ // switch (c) { // case 'h': // target = h; // // transform.position = Vector3.MoveTowards(transform.position, h, step); // Debug.Log("h"); // break; // case 'i': // target = i; // Debug.Log("i"); // break; // case 'e': // target = e; // Debug.Log("e"); // break; // default: // break; // } // move(target); //} }
// Update is called once per frame void Update() { /*check force*/ string cmd = CheckForRecievedData(); try { print(cmd); // print("tafe"); if (cmd.StartsWith("F")) //Got a force { // print("hey"); force = ParseFSRData(cmd); print(force); if (force > 300 && force < 490) //positoon soft touch { positioning = true; gettingPoints = false; } else if (force > 500) { positioning = false; gettingPoints = true; //while start //while (typing) //{ //p.X = mycursor.transform.position.x; //p.Y = mycursor.transform.position.y; // }//end while } else { gettingPoints = false; positioning = false; } } // else { force = 0; typing = false; positioning = false; } } catch (System.Exception) { Debug.Log("hie"); } /*position*/ if (positioning) { this.GetComponent <Renderer>().material.SetColor("_Color", Color.red); this.GetComponent <TrailRenderer>().widthMultiplier = 0.0f; this.GetComponent <TrailRenderer>().time = 0.01f; xpos = Input.GetAxis("Mouse X"); ypos = Input.GetAxis("Mouse Y"); displac.x = xpos * 0.3f; displac.y = ypos * 0.3f; displac.z = 0f; //float minX = -5.5f; //float maxX = 5.5f; //float minY = -2.4f; //float maxY = 2.4f; // displac.x = Mathf.Clamp(displac.x, minX, maxX); //displac.y = Mathf.Clamp(displac.y, minY, maxY); Vector3 position = this.transform.position; if (this.transform.position.x + displac.x < -5.5) { position.x = -5.5f; } else if (this.transform.position.x + displac.x > 5.5) { position.x = 5.5f; } else { position.x += displac.x; } if (this.transform.position.y + displac.y < -2.4) { position.y = -2.4f; } else if (this.transform.position.y + displac.y > 2.4) { position.y = 2.4f; } else { position.y += displac.y; } // position.y += displac.y; position.z += displac.z; try { this.transform.position = position; } catch (System.Exception) { } } /*get points */ if (gettingPoints) { this.GetComponent <Renderer>().material.SetColor("_Color", Color.green); this.GetComponent <TrailRenderer>().widthMultiplier = 0.1f; this.GetComponent <TrailRenderer>().time = 2f; xpos = Input.GetAxis("Mouse X"); ypos = Input.GetAxis("Mouse Y"); displac.x = xpos * 0.3f; displac.y = ypos * 0.3f; displac.z = 0f; Vector3 position = this.transform.position; if (this.transform.position.x + displac.x < -5.5) { position.x = -5.5f; } else if (this.transform.position.x + displac.x > 5.5) { position.x = 5.5f; } else { position.x += displac.x; } if (this.transform.position.y + displac.y < -2.4) { position.y = -2.4f; } else if (this.transform.position.y + displac.y > 2.4) { position.y = 2.4f; } else { position.y += displac.y; } // position.y += displac.y; position.z += displac.z; try { this.transform.position = position; } catch (System.Exception) { } p.X = this.transform.position.x; //xpos;// mycursor.transform.position.x; p.Y = this.transform.position.y; // ypos;// mycursor.transform.position.y; setPattern.Add(p); // drawingPattern[i] = p; i = i + 1; Debug.Log(i); } /*write word to json file*/ if (!gettingPoints && setPattern.Count > 0) { //change list to array Point[] mypoints = new Point[setPattern.Count]; mypoints = setPattern.ToArray(); PointPattern pa = new PointPattern(); pa.Name = "myword"; pa.Points = mypoints; setPattern.Clear(); PointManager.AddInput(path, pa); Debug.Log("shoooo"); } // Create a Point Pattern object // This is dependent on your inputs // Im using a default constructor in this case, Debug.Log("yes yebo"); //var pattern = new PointPattern(); //pattern.Name = "Falesto"; //pattern.Points = new Point[] { new Point { X = 100, Y = 300 }, new Point { X = 400, Y = 300 } }; //PointManager.AddInput(path, pattern); // Point Mannager is a static class with static methods. //PointManager.AddInput(path, pattern); // PointManager.ReadFile(path); }