Spelunx Cavern SDK
 
Loading...
Searching...
No Matches
CreatureBehavior.cs
Go to the documentation of this file.
1using UnityEngine;
2using System.Collections;
3
4public class CreatureBehavior : MonoBehaviour
5{
6 [SerializeField, Tooltip("Vive Tracker")] private GameObject player;
7 [SerializeField, Tooltip("Cavern mirror")] private Spelunx.CavernRenderer cavernSetup;
8 [SerializeField, Tooltip("Audio Manager")] private AudioManager audioManager;
9 [SerializeField, Tooltip("Big Creature Animator")] private Animator bigCreaAnim;
10 [SerializeField, Tooltip("Hugging Particle")] private GameObject huggingParticle;
11
12 private bool nearBigCreature = false;
13 private Animator creatureAnimator;
14
15 private void Start()
16 {
17 creatureAnimator = GetComponent<Animator>();
18 }
19
20 public GameObject GetViveTrackerObject()
21 {
22 return player;
23 }
24
26 {
27 return cavernSetup;
28 }
29
30
32 {
33 StartCoroutine(PlayingIntroScene(fsm));
34 }
35
36 private IEnumerator PlayingIntroScene(FiniteStateMachine fsm)
37 {
38 yield return new WaitForSeconds(10f);
39 audioManager.PlayCreatureFlyingSound();
40
41 creatureAnimator.SetTrigger("Intro");
42 yield return new WaitForSeconds(41f);
43
44 yield return new WaitForSeconds(3f);
45 fsm.ChangeState("OnGround");
46 }
47
48 public void PlayWhining()
49 {
50 creatureAnimator.SetTrigger("Default");
51 audioManager.PlayCreatureWhiningSound();
52 }
53
54 public void PlayCorrect()
55 {
56 audioManager.PlayCorrectSound();
57 }
58
59 public void PlayMirroring()
60 {
61 creatureAnimator.applyRootMotion = true;
62 audioManager.PlayCreatureFlyingSound();
63 }
64
66 {
67 StartCoroutine(PlayingLastScene(fsm));
68 }
69
70 private IEnumerator PlayingLastScene(FiniteStateMachine fsm)
71 {
72 creatureAnimator.applyRootMotion = false;
73
74 yield return new WaitForSeconds(1f);
75 creatureAnimator.SetTrigger("ToHug");
76
77 yield return new WaitForSeconds(2f);
78 audioManager.PlayCreatureHuggingSound();
79
80 yield return new WaitForSeconds(2f);
81 huggingParticle.SetActive(true);
82
83 yield return new WaitForSeconds(1f);
84 audioManager.PlayBigCreatureHuggingSound();
85 bigCreaAnim.SetTrigger("Hug");
86
87 yield return new WaitForSeconds(5f);
88 creatureAnimator.SetTrigger("BackToTree");
89
90 yield return new WaitForSeconds(1f);
91 huggingParticle.SetActive(false);
92
93 yield return new WaitForSeconds(2f);
94 bigCreaAnim.SetTrigger("Default");
95
96 yield return new WaitForSeconds(4f);
97 fsm.ChangeState("Start");
98 }
99
100 public bool NearBigCreature()
101 {
102 return nearBigCreature;
103 }
104
105 private void OnTriggerEnter(Collider other)
106 {
107 if (other.CompareTag("MeetingArea"))
108 {
109 //Debug.Log("big creature enter");
110 nearBigCreature = true;
111 }
112 }
113
114 private void OnTriggerExit(Collider other)
115 {
116 if (other.CompareTag("MeetingArea"))
117 {
118 //Debug.Log("big creature exit");
119 nearBigCreature = false;
120 }
121 }
122}
Spelunx.CavernRenderer GetCavernSetup()
void PlayStartScene(FiniteStateMachine fsm)
void PlayHugToTree(FiniteStateMachine fsm)
GameObject GetViveTrackerObject()
void ChangeState(string nextState)