Skip to content

Commit 61eb3f7

Browse files
committed
Lines get in place after all the lines have been placed, and starts the video
1 parent 2eb72e3 commit 61eb3f7

4 files changed

Lines changed: 35 additions & 15 deletions

File tree

Assets/Draw.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class Draw : MonoBehaviour
99
public GameObject line;
1010
private Touch touch;
1111
public int order;
12-
public float[] lengths;
12+
public int finished = 0;
1313
//if there is a better way pls tell me. I can only think about reading this from a file.
1414
public Vector2[,] positions = { { new Vector2(2.17f, 1.3f), new Vector2(0.62f, 1.3f) } , //back
1515
{ new Vector2(-0.92f, 2.13f), new Vector2(0.51f, 1.37f) } , //front
@@ -32,7 +32,9 @@ void Update()
3232
{
3333
if (order >= 9) {
3434
//Align lines into place
35-
StartVideo();
35+
if (finished == 9) {
36+
StartVideo();
37+
}
3638
}
3739
else if (Input.touchCount > 0) {
3840
touch = Input.GetTouch(0);

Assets/Line.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public class Line : MonoBehaviour
1414
private int order;
1515

1616
private Touch touch;
17+
public float stepSpeed;
18+
private Vector3[] cur;
19+
private bool reported = false;
1720

1821
void Start()
1922
{
@@ -22,17 +25,30 @@ void Start()
2225
script = GameObject.Find("DrawAgent");
2326
Draw comp = script.GetComponent<Draw>();
2427
order = comp.order;
28+
Debug.Log("Order: " + order);
2529
length = Math.Abs(Vector2.Distance(comp.positions[order,0], comp.positions[order,1]));
26-
Debug.Log(length);
2730
done = false;
2831
}
2932

3033
void Update()
3134
{
32-
if (script.GetComponent<Draw>().order == 9)
35+
if (script.GetComponent<Draw>().order >= 9)
3336
{
3437
//Align into position
38+
float step = stepSpeed * Time.deltaTime;
39+
for (int i = 0; i < 2; i++)
40+
{
41+
Vector3 target = new Vector3(script.GetComponent<Draw>().positions[order, i].x, script.GetComponent<Draw>().positions[order, i].y, 0);
42+
cur[i] = Vector3.MoveTowards(cur[i], target, step);
43+
}
44+
l.SetPositions(cur);
45+
3546
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) {
48+
script.GetComponent<Draw>().finished++;
49+
reported = true;
50+
}
51+
//TODO: prettier
3652
}
3753
else if (touch.phase == TouchPhase.Ended && !done)
3854
{
@@ -43,8 +59,9 @@ void Update()
4359
Vector3 current = touch.position;
4460
current = Camera.main.ScreenToWorldPoint(current);
4561
current.z = 0;
46-
47-
Vector3[] pos = {StartPos, current};
62+
Vector3[] pos = {current, StartPos };
63+
cur = pos;
64+
4865
Color c = new Color(252, 253, 189);
4966

5067
l.startWidth = height;

Assets/Line.prefab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,4 @@ MonoBehaviour:
143143
m_Name:
144144
m_EditorClassIdentifier:
145145
height: 0.1
146+
stepSpeed: 2

Assets/Scenes/SampleScene.unity

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,15 @@ MonoBehaviour:
239239
line: {fileID: 1945975318650849093, guid: 9dc3f683d960c3d429039267e8ed9fc3, type: 3}
240240
order: 0
241241
lengths:
242-
- 50
243-
- 50
244-
- 50
245-
- 50
246-
- 50
247-
- 50
248-
- 50
249-
- 50
250-
- 50
242+
- 5
243+
- 5
244+
- 5
245+
- 5
246+
- 5
247+
- 5
248+
- 5
249+
- 5
250+
- 5
251251
--- !u!4 &786270579
252252
Transform:
253253
m_ObjectHideFlags: 0

0 commit comments

Comments
 (0)