-
Notifications
You must be signed in to change notification settings - Fork 0
/
CapsuleCollision.cs
62 lines (55 loc) · 1.77 KB
/
CapsuleCollision.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CapsuleCollision : MonoBehaviour {
private PlayerAudioManager playerAudioManager;
private MusicManager musicManager;
private GroundSpawn groundSpawn;
private Transform ufo;
private Rigidbody rbd;
private ParticleSystem explosionSystem;
private ParticleSystem smokeSystem;
private Animator explosionAnimator;
private AbductorCollision abductorCollision;
private PlayerMovement playerMovement;
private Game game;
void Awake() {
game = FindObjectOfType<Game> ();
groundSpawn = FindObjectOfType<GroundSpawn> ();
abductorCollision = FindObjectOfType<AbductorCollision> ();
ufo = transform;
rbd = ufo.gameObject.GetComponent<Rigidbody>() as Rigidbody;
playerMovement = ufo.gameObject.GetComponent <PlayerMovement>() as PlayerMovement;
playerAudioManager = ufo.gameObject.GetComponent<PlayerAudioManager> () as PlayerAudioManager;
explosionSystem = ufo.Find("UFOExplosionSystem").GetComponent<ParticleSystem>();
smokeSystem = ufo.Find ("UFOSmokeSystem").GetComponent <ParticleSystem> ();
explosionAnimator = ufo.GetComponent<Animator> ();
}
void Start() {
musicManager = FindObjectOfType<MusicManager> ();
}
void Explode() {
explosionAnimator.SetBool ("isExploding", true);
musicManager.Stop ();
playerAudioManager.Explode ();
explosionSystem.Play ();
Invoke ("Smoke", 0.2f);
playerMovement.canMove = false;
rbd.isKinematic = true;
game.GameOver ();
}
void Smoke() {
smokeSystem.Play ();
}
void OnTriggerEnter(Collider other) {
if (other.gameObject.tag == "SpawnCollider") {
groundSpawn.Spawn ();
}
if (other.gameObject.layer == 10) {
Explode ();
}
if (other.gameObject.layer == 9) {
abductorCollision.Abducted (other.gameObject);
}
}
}