-
Notifications
You must be signed in to change notification settings - Fork 0
/
Herminette.cs
120 lines (78 loc) · 2.47 KB
/
Herminette.cs
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VRTK;
public class Herminette : VRTK_InteractableObject
{
public bool HasbeenGrabbed = false;
public GameObject Player;
public GameObject ariane;
public LastRoomEvents Generique;
private bool end = false;
public VRTK_ControllerActions controllerActions;
public VRTK_HeadsetFade fading;
private float impactMagnifier = 120f;
private float collisionForce = 0f;
private float maxCollisionForce = 4000f;
// Use this for initialization
void Start()
{
AkSoundEngine.PostEvent("drop_herminette", this.gameObject);
}
// Update is called once per frame
void Update()
{
}
protected override void Awake()
{
base.Awake();
interactableRigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous;
}
public override void Grabbed(GameObject currentGrabbingObject)
{
base.Grabbed(currentGrabbingObject);
if (!HasbeenGrabbed)
{
AkSoundEngine.PostEvent("soundscape_2_end", Player);
HasbeenGrabbed = true;
}
controllerActions = currentGrabbingObject.GetComponent<VRTK_ControllerActions>();
}
private void OnTriggerEnter(Collider other)
{
Debug.Log(" FORCE start " + collisionForce);
if (other.tag == "Ariana")
{
if (controllerActions && IsGrabbed())
{
collisionForce = VRTK_DeviceFinder.GetControllerVelocity(controllerActions.gameObject).magnitude * impactMagnifier;
if (collisionForce > 235 && !end)
{
end = true;
StartCoroutine(endgame());
}
}
}
}
public IEnumerator endgame()
{
StartCoroutine(vibrations());
fading.Fade(Color.black, 0.1f);
AkSoundEngine.StopAll();
AkSoundEngine.PostEvent("stab", ariane);
StartCoroutine(Generique.Generique());
Generique.IsEnding = true;
yield return new WaitForSeconds(2);
while (this.enabled == true)
{
yield return new WaitForSeconds(0.5f);
fading.Fade(Color.black, 0.1f);
}
}
public IEnumerator vibrations()
{
yield return new WaitForSeconds(0.1f);
controllerActions.TriggerHapticPulse(2f,0.4f,0.01f);
yield return new WaitForSeconds(1f);
}
}