Skip to content

Commit d862c5b

Browse files
committed
Added reset button
In the form of a fuck go back png
1 parent 61c0ce5 commit d862c5b

11 files changed

Lines changed: 835 additions & 11 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[Tt]emp/
55
[Oo]bj/
66
[Bb]uild
7-
/[Bb]uilds/
87
/[Ll]ibrary/
98
sysinfo.txt
109
*.stackdump

Assets/Draw.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.Threading;
45
using UnityEngine;
6+
using UnityEngine.Video;
57

68
public class Draw : MonoBehaviour
79
{
@@ -15,6 +17,9 @@ public class Draw : MonoBehaviour
1517
public AudioClip[] clips;
1618
private bool playedAudio = false;
1719
public float wait2;
20+
private bool waitingForVideo = false;
21+
22+
private List<GameObject> lines;
1823
//if there is a better way pls tell me. I can only think about reading this from a file.
1924
public Vector3[,] positions = { { new Vector3(2.17f, 1.3f, 0f), new Vector3(0.62f, 1.3f, 0f) } , //back
2025
{ new Vector3(-0.92f, 2.13f, 0f), new Vector3(0.51f, 1.37f, 0f) } , //front
@@ -26,11 +31,8 @@ public class Draw : MonoBehaviour
2631
{ new Vector3(0.47f, 1.24f, 0f), new Vector3(0.06f, -0.1f, 0f) } , //4th leg
2732
{ new Vector3(1.8f, 1.18f, 0f), new Vector3(1.88f, -0.23f, 0f)} }; //5th leg
2833
void Start() {
29-
//Set screen orientation
30-
Screen.orientation = ScreenOrientation.Landscape;
31-
Screen.orientation = ScreenOrientation.AutoRotation;
32-
Screen.autorotateToPortrait = false;
33-
Screen.autorotateToPortraitUpsideDown = false;
34+
lines = new List<GameObject>();
35+
video = GameObject.Find("Video Player");
3436
}
3537

3638
void Update()
@@ -50,7 +52,18 @@ void Update()
5052
//Align lines into place
5153
else if (finished == 9)
5254
{
53-
StartVideo();
55+
if (!waitingForVideo)
56+
{
57+
StartVideo();
58+
waitingForVideo = true;
59+
}
60+
else if(GameObject.Find("Video Player").GetComponent<VideoPlayer>().isPlaying){
61+
foreach (GameObject i in lines)
62+
{
63+
Destroy(i);
64+
}
65+
Destroy(gameObject);
66+
}
5467
}
5568
else if (!playedAudio && wait2 >= 0) {
5669
wait2 -= Time.deltaTime;
@@ -70,7 +83,8 @@ void Update()
7083
transform.position = touchpos;
7184

7285
if (touch.phase == TouchPhase.Began) {
73-
Instantiate(line, transform.position, transform.rotation);
86+
lines.Add(Instantiate(line, transform.position, transform.rotation));
87+
lines[lines.Count - 1].GetComponent<Line>().script = gameObject;
7488
}
7589
}
7690
}

Assets/DrawAgent.prefab

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!1 &559527376717875176
4+
GameObject:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
serializedVersion: 6
10+
m_Component:
11+
- component: {fileID: 559527376717875178}
12+
- component: {fileID: 559527376717875179}
13+
- component: {fileID: 559527376717875181}
14+
m_Layer: 0
15+
m_Name: DrawAgent
16+
m_TagString: Untagged
17+
m_Icon: {fileID: 0}
18+
m_NavMeshLayer: 0
19+
m_StaticEditorFlags: 0
20+
m_IsActive: 1
21+
--- !u!4 &559527376717875178
22+
Transform:
23+
m_ObjectHideFlags: 0
24+
m_CorrespondingSourceObject: {fileID: 0}
25+
m_PrefabInstance: {fileID: 0}
26+
m_PrefabAsset: {fileID: 0}
27+
m_GameObject: {fileID: 559527376717875176}
28+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
29+
m_LocalPosition: {x: 0, y: 0, z: 0}
30+
m_LocalScale: {x: 1, y: 1, z: 1}
31+
m_Children: []
32+
m_Father: {fileID: 0}
33+
m_RootOrder: 0
34+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35+
--- !u!114 &559527376717875179
36+
MonoBehaviour:
37+
m_ObjectHideFlags: 0
38+
m_CorrespondingSourceObject: {fileID: 0}
39+
m_PrefabInstance: {fileID: 0}
40+
m_PrefabAsset: {fileID: 0}
41+
m_GameObject: {fileID: 559527376717875176}
42+
m_Enabled: 1
43+
m_EditorHideFlags: 0
44+
m_Script: {fileID: 11500000, guid: 4561b219c200a0b4d88c5027749c5153, type: 3}
45+
m_Name:
46+
m_EditorClassIdentifier:
47+
video: {fileID: 0}
48+
line: {fileID: 1945975318650849093, guid: 9dc3f683d960c3d429039267e8ed9fc3, type: 3}
49+
order: 0
50+
finished: 0
51+
wait: 1
52+
clips:
53+
- {fileID: 8300000, guid: 3befc7219b3f069439ad9e8a7dea59a9, type: 3}
54+
- {fileID: 8300000, guid: 9520e764f553b8048a067b946f422194, type: 3}
55+
wait2: 1
56+
--- !u!82 &559527376717875181
57+
AudioSource:
58+
m_ObjectHideFlags: 0
59+
m_CorrespondingSourceObject: {fileID: 0}
60+
m_PrefabInstance: {fileID: 0}
61+
m_PrefabAsset: {fileID: 0}
62+
m_GameObject: {fileID: 559527376717875176}
63+
m_Enabled: 1
64+
serializedVersion: 4
65+
OutputAudioMixerGroup: {fileID: 0}
66+
m_audioClip: {fileID: 0}
67+
m_PlayOnAwake: 1
68+
m_Volume: 1
69+
m_Pitch: 1
70+
Loop: 0
71+
Mute: 0
72+
Spatialize: 0
73+
SpatializePostEffects: 0
74+
Priority: 128
75+
DopplerLevel: 1
76+
MinDistance: 1
77+
MaxDistance: 500
78+
Pan2D: 0
79+
rolloffMode: 0
80+
BypassEffects: 0
81+
BypassListenerEffects: 0
82+
BypassReverbZones: 0
83+
rolloffCustomCurve:
84+
serializedVersion: 2
85+
m_Curve:
86+
- serializedVersion: 3
87+
time: 0
88+
value: 1
89+
inSlope: 0
90+
outSlope: 0
91+
tangentMode: 0
92+
weightedMode: 0
93+
inWeight: 0.33333334
94+
outWeight: 0.33333334
95+
- serializedVersion: 3
96+
time: 1
97+
value: 0
98+
inSlope: 0
99+
outSlope: 0
100+
tangentMode: 0
101+
weightedMode: 0
102+
inWeight: 0.33333334
103+
outWeight: 0.33333334
104+
m_PreInfinity: 2
105+
m_PostInfinity: 2
106+
m_RotationOrder: 4
107+
panLevelCustomCurve:
108+
serializedVersion: 2
109+
m_Curve:
110+
- serializedVersion: 3
111+
time: 0
112+
value: 0
113+
inSlope: 0
114+
outSlope: 0
115+
tangentMode: 0
116+
weightedMode: 0
117+
inWeight: 0.33333334
118+
outWeight: 0.33333334
119+
m_PreInfinity: 2
120+
m_PostInfinity: 2
121+
m_RotationOrder: 4
122+
spreadCustomCurve:
123+
serializedVersion: 2
124+
m_Curve:
125+
- serializedVersion: 3
126+
time: 0
127+
value: 0
128+
inSlope: 0
129+
outSlope: 0
130+
tangentMode: 0
131+
weightedMode: 0
132+
inWeight: 0.33333334
133+
outWeight: 0.33333334
134+
m_PreInfinity: 2
135+
m_PostInfinity: 2
136+
m_RotationOrder: 4
137+
reverbZoneMixCustomCurve:
138+
serializedVersion: 2
139+
m_Curve:
140+
- serializedVersion: 3
141+
time: 0
142+
value: 1
143+
inSlope: 0
144+
outSlope: 0
145+
tangentMode: 0
146+
weightedMode: 0
147+
inWeight: 0.33333334
148+
outWeight: 0.33333334
149+
m_PreInfinity: 2
150+
m_PostInfinity: 2
151+
m_RotationOrder: 4

Assets/DrawAgent.prefab.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Line.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class Line : MonoBehaviour
1010
private LineRenderer l;
1111
private float length;
1212
private bool done;
13-
private GameObject script;
13+
public GameObject script;
1414
private int order;
1515

1616
private Touch touch;
@@ -21,16 +21,17 @@ public class Line : MonoBehaviour
2121
private float[] step;
2222

2323
public AudioClip[] clips;
24+
public float waitAfterInPlace;
25+
private float wait;
2426

2527
void Start()
2628
{
2729
StartPos = transform.position;
2830
l = GetComponent<LineRenderer>();
29-
script = GameObject.Find("DrawAgent");
31+
//script = GameObject.FindWithTag("DrawAgent");
3032
Draw comp = script.GetComponent<Draw>();
3133
order = comp.order;
3234
final = comp.positions;
33-
Debug.Log("Order: " + order);
3435
step = new float[2];
3536
length = Math.Abs(Vector3.Distance(comp.positions[order,0], comp.positions[order,1]));
3637
done = false;

Assets/Line.prefab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ MonoBehaviour:
155155
- {fileID: 8300000, guid: 7f72ec6443619ca44be348141f45dd54, type: 3}
156156
- {fileID: 8300000, guid: d2acf1ca7f458ab4996c8ad448dd73e0, type: 3}
157157
- {fileID: 8300000, guid: b203df85c0bf1434a89d1777026f85f2, type: 3}
158+
waitAfterInPlace: 1.5
158159
--- !u!82 &6938631207205492042
159160
AudioSource:
160161
m_ObjectHideFlags: 0

Assets/Restart.cs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEditor;
4+
using UnityEngine;
5+
using UnityEngine.Video;
6+
7+
public class Restart : MonoBehaviour
8+
{
9+
// Start is called before the first frame update
10+
private Draw comp;
11+
public float wait;
12+
private float time;
13+
public float speed;
14+
private bool restartSequence = false;
15+
SpriteRenderer renderer;
16+
public GameObject agent;
17+
private float transparency;
18+
19+
void Start()
20+
{
21+
//Set screen orientation
22+
Screen.orientation = ScreenOrientation.Landscape;
23+
Screen.orientation = ScreenOrientation.AutoRotation;
24+
Screen.autorotateToPortrait = false;
25+
Screen.autorotateToPortraitUpsideDown = false;
26+
27+
comp = GameObject.Find("DrawAgent").GetComponent<Draw>();
28+
renderer = gameObject.GetComponent<SpriteRenderer>();
29+
renderer.enabled = false;
30+
}
31+
32+
// Update is called once per frame
33+
void Update()
34+
{
35+
if (!restartSequence)
36+
{
37+
if (comp.order >= 10)
38+
{
39+
restartSequence = true;
40+
time = wait;
41+
}
42+
}
43+
else if (time >= 0)
44+
{
45+
time -= Time.deltaTime;
46+
}
47+
else {
48+
if (!renderer.enabled) {
49+
renderer.enabled = true;
50+
transparency = 0;
51+
}
52+
if (transparency <= 1) {
53+
transparency += Time.deltaTime * speed;
54+
renderer.color = new Color(1f, 1f, 1f, transparency);
55+
}
56+
if (Input.touchCount > 0) {
57+
Vector3 worldPoint = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
58+
Vector2 touchPos = new Vector2(worldPoint.x, worldPoint.y);
59+
if (GetComponent<BoxCollider2D>() == Physics2D.OverlapPoint(touchPos))
60+
{
61+
Debug.Log("A new round begins");
62+
restartSequence = false;
63+
comp = Instantiate(agent).GetComponent<Draw>();
64+
renderer.enabled = false;
65+
GameObject.Find("Main Camera").GetComponent<Camera>().backgroundColor = new Color(68/255f, 103/255f, 159/255f, 1);
66+
GameObject.Find("Video Player").GetComponent<VideoPlayer>().Stop(); //még szar lehet
67+
68+
}
69+
}
70+
}
71+
}
72+
}

Assets/Restart.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)