Skip to content

Commit c64eb75

Browse files
committed
Cleared up the final check code
The part where it checks if the line is in place, and sends confirmation
1 parent 61eb3f7 commit c64eb75

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

Assets/Draw.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ public class Draw : MonoBehaviour
1111
public int order;
1212
public int finished = 0;
1313
//if there is a better way pls tell me. I can only think about reading this from a file.
14-
public Vector2[,] positions = { { new Vector2(2.17f, 1.3f), new Vector2(0.62f, 1.3f) } , //back
15-
{ new Vector2(-0.92f, 2.13f), new Vector2(0.51f, 1.37f) } , //front
16-
{ new Vector2(-0.5f, 1.83f), new Vector2(-1.74f, 1.22f)} , //back leg top
17-
{ new Vector2(-1.74f, 1.22f), new Vector2(-2.6f, 0.2f) } , //back leg bottom
18-
{ new Vector2(-0.54f, 1.77f), new Vector2(-1.26f, 0.09f) } , //2nd leg (from the left)
19-
{ new Vector2(0.14f, 1.52f), new Vector2(-0.53f, 0.84f)} , //3rd leg top
20-
{ new Vector2(-0.53f, 0.84f), new Vector2(-0.74f, 0.06f) } , //3rd leg bottom
21-
{ new Vector2(0.47f, 1.24f), new Vector2(0.06f, -0.1f) } , //4th leg
22-
{ new Vector2(1.8f, 1.18f), new Vector2(1.88f, -0.23f)} }; //5th leg
14+
public Vector3[,] positions = { { new Vector3(2.17f, 1.3f, 0f), new Vector3(0.62f, 1.3f, 0f) } , //back
15+
{ new Vector3(-0.92f, 2.13f, 0f), new Vector3(0.51f, 1.37f, 0f) } , //front
16+
{ new Vector3(-0.5f, 1.83f, 0f), new Vector3(-1.74f, 1.22f, 0f)} , //back leg top
17+
{ new Vector3(-1.74f, 1.22f, 0f), new Vector3(-2.6f, 0.2f, 0f) } , //back leg bottom
18+
{ new Vector3(-0.54f, 1.77f, 0f), new Vector3(-1.26f, 0.09f, 0f) } , //2nd leg (from the left)
19+
{ new Vector3(0.14f, 1.52f, 0f), new Vector3(-0.53f, 0.84f, 0f)} , //3rd leg top
20+
{ new Vector3(-0.53f, 0.84f, 0f), new Vector3(-0.74f, 0.06f, 0f) } , //3rd leg bottom
21+
{ new Vector3(0.47f, 1.24f, 0f), new Vector3(0.06f, -0.1f, 0f) } , //4th leg
22+
{ new Vector3(1.8f, 1.18f, 0f), new Vector3(1.88f, -0.23f, 0f)} }; //5th leg
2323
void Start() {
2424
//Set screen orientation
2525
Screen.orientation = ScreenOrientation.Landscape;

Assets/Line.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class Line : MonoBehaviour
1616
private Touch touch;
1717
public float stepSpeed;
1818
private Vector3[] cur;
19+
private Vector3[,] final;
1920
private bool reported = false;
2021

2122
void Start()
@@ -25,8 +26,9 @@ void Start()
2526
script = GameObject.Find("DrawAgent");
2627
Draw comp = script.GetComponent<Draw>();
2728
order = comp.order;
29+
final = comp.positions;
2830
Debug.Log("Order: " + order);
29-
length = Math.Abs(Vector2.Distance(comp.positions[order,0], comp.positions[order,1]));
31+
length = Math.Abs(Vector3.Distance(comp.positions[order,0], comp.positions[order,1]));
3032
done = false;
3133
}
3234

@@ -38,13 +40,14 @@ void Update()
3840
float step = stepSpeed * Time.deltaTime;
3941
for (int i = 0; i < 2; i++)
4042
{
41-
Vector3 target = new Vector3(script.GetComponent<Draw>().positions[order, i].x, script.GetComponent<Draw>().positions[order, i].y, 0);
43+
Vector3 target = script.GetComponent<Draw>().positions[order, i];
4244
cur[i] = Vector3.MoveTowards(cur[i], target, step);
4345
}
4446
l.SetPositions(cur);
4547

4648
Debug.Log("I should go into my place now");
47-
if (new Vector3(script.GetComponent<Draw>().positions[order, 0].x, script.GetComponent<Draw>().positions[order, 0].y, 0) == cur[0] && new Vector3(script.GetComponent<Draw>().positions[order, 1].x, script.GetComponent<Draw>().positions[order, 1].y, 0) == cur[1] && !reported) {
49+
//new Vector3(script.GetComponent<Draw>().positions[order, 0].x, script.GetComponent<Draw>().positions[order, 0].y, 0) == cur[0] && new Vector3(script.GetComponent<Draw>().positions[order, 1].x, script.GetComponent<Draw>().positions[order, 1].y, 0) == cur[1] && !reported
50+
if (!reported && final[order, 0] == cur[0] && final[order,1] == cur[1]) {
4851
script.GetComponent<Draw>().finished++;
4952
reported = true;
5053
}

0 commit comments

Comments
 (0)