-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTutorialThrowCheck.cs
More file actions
93 lines (85 loc) · 3.01 KB
/
TutorialThrowCheck.cs
File metadata and controls
93 lines (85 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TutorialThrowCheck : MonoBehaviour
{
[SerializeField] TutorialManager tutorialManager;
[SerializeField] private GameObject grabbableObject;
[SerializeField] private GameObject leftHandObject;
[SerializeField] private GameObject rightHandObject;
[SerializeField] private EffectAudioManager effectAudioManager;
private GrabLeft leftHand;
private GrabRight rightHand;
private bool throwCheck;
private bool once;
private OVRGrabbable left_grabbable;
private OVRGrabbable right_grabbable;
void Start()
{
leftHand = leftHandObject.GetComponent<GrabLeft>();
rightHand = rightHandObject.GetComponent<GrabRight>();
throwCheck = false;
once = false;
}
IEnumerator Loading()
{
yield return new WaitForSeconds(0.5f);
GestureRecongizedLeft gestureRecongizedLeft = GameObject.FindGameObjectWithTag("GR").GetComponent<GestureRecongizedLeft>();
GestureRecongizedRight gestureRecongizedRight = GameObject.FindGameObjectWithTag("GR").GetComponent<GestureRecongizedRight>();
if (leftHand.insideObject)
{
gestureRecongizedLeft.CanGrabbingTurnOff();
if (leftHand.isGrabbing)
{
GameObject grabbableObject = leftHand.grabbedObject.gameObject;
GameObject grabDetector = grabbableObject.transform.GetChild(0).gameObject;
left_grabbable = leftHand.grabbedObject;
grabDetector.SetActive(false);
}
}
if (rightHand.insideObject)
{
gestureRecongizedRight.CanGrabbingTurnOff();
if (rightHand.isGrabbing)
{
GameObject grabbableObject = rightHand.grabbedObject.gameObject;
GameObject grabDetector = grabbableObject.transform.GetChild(0).gameObject;
right_grabbable = rightHand.grabbedObject;
grabDetector.SetActive(false);
}
}
leftHand.GrabFinish();
rightHand.GrabFinish();
leftHand.InsideObjectTurnOff();
rightHand.InsideObjectTurnOff();
gestureRecongizedLeft.CanGrabbingTurnOn();
gestureRecongizedRight.CanGrabbingTurnOn();
grabbableObject.SetActive(false);
if (left_grabbable != null)
{
leftHand.RemoveCandidates(left_grabbable);
rightHand.RemoveCandidates(left_grabbable);
}
if (right_grabbable != null)
{
leftHand.RemoveCandidates(right_grabbable);
rightHand.RemoveCandidates(right_grabbable);
}
tutorialManager.EndStep4();
}
public void ThrowingTurnOn()
{
throwCheck = true;
}
void Update()
{
if (throwCheck) {
if (!once)
{
StartCoroutine(Loading());
effectAudioManager.ThrowEffect();
once = true;
}
}
}
}