Skip to content

Commit 2eb72e3

Browse files
committed
Added the line positions
I don't know if there is a better way, but I didn't enjoy this...
1 parent dd0cb4e commit 2eb72e3

2 files changed

Lines changed: 30 additions & 9 deletions

File tree

Assets/Draw.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4-
//using System.Numerics;
54
using UnityEngine;
65

76
public class Draw : MonoBehaviour
@@ -11,6 +10,16 @@ public class Draw : MonoBehaviour
1110
private Touch touch;
1211
public int order;
1312
public float[] lengths;
13+
//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
1423
void Start() {
1524
//Set screen orientation
1625
Screen.orientation = ScreenOrientation.Landscape;
@@ -21,7 +30,11 @@ void Start() {
2130

2231
void Update()
2332
{
24-
if (Input.touchCount > 0) {
33+
if (order >= 9) {
34+
//Align lines into place
35+
StartVideo();
36+
}
37+
else if (Input.touchCount > 0) {
2538
touch = Input.GetTouch(0);
2639
Vector3 touchpos = Camera.main.ScreenToWorldPoint(touch.position);
2740
touchpos.z = 0;

Assets/Line.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,34 @@ public class Line : MonoBehaviour
1111
private float length;
1212
private bool done;
1313
private GameObject script;
14+
private int order;
1415

1516
private Touch touch;
17+
1618
void Start()
1719
{
1820
StartPos = transform.position;
1921
l = GetComponent<LineRenderer>();
2022
script = GameObject.Find("DrawAgent");
2123
Draw comp = script.GetComponent<Draw>();
22-
length = comp.lengths[comp.order];
24+
order = comp.order;
25+
length = Math.Abs(Vector2.Distance(comp.positions[order,0], comp.positions[order,1]));
26+
Debug.Log(length);
2327
done = false;
2428
}
2529

2630
void Update()
2731
{
28-
if (!done && Input.touchCount > 0) {
32+
if (script.GetComponent<Draw>().order == 9)
33+
{
34+
//Align into position
35+
Debug.Log("I should go into my place now");
36+
}
37+
else if (touch.phase == TouchPhase.Ended && !done)
38+
{
39+
Destroy(gameObject);
40+
}
41+
else if (!done && Input.touchCount > 0) {
2942
touch = Input.GetTouch(0);
3043
Vector3 current = touch.position;
3144
current = Camera.main.ScreenToWorldPoint(current);
@@ -47,10 +60,5 @@ void Update()
4760
script.GetComponent<Draw>().order++;
4861
}
4962
}
50-
if (touch.phase == TouchPhase.Ended && !done)
51-
{
52-
Debug.Log("I should destroy now");
53-
Destroy(gameObject);
54-
}
5563
}
5664
}

0 commit comments

Comments
 (0)