-
Notifications
You must be signed in to change notification settings - Fork 0
/
SafeZone.cs
95 lines (70 loc) · 2.05 KB
/
SafeZone.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//when the player reaches the safe zone with the hostage, the mission is complete
public class SafeZone : MonoBehaviour {
[SerializeField] private GameObject missiontext;
[SerializeField] private GameObject resett;
[SerializeField] private GameObject exitt;
[SerializeField] private GameObject player;
[SerializeField] private GameObject hostage;
[SerializeField] private GameObject cameraCutScene;
[SerializeField] private GameObject heli;
private bool safe;
// Use this for initialization
void Start () {
safe = false;
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other) {
PlayerCharacter player = other.GetComponent<PlayerCharacter>();
if(safe){
missiontext.SetActive(true);
resett.SetActive (true);
exitt.SetActive (true);
FPSInput f = FindObjectOfType<FPSInput> ();
if (f != null) {
f.SetAlive (false);
}
WeaponPickup wp = FindObjectOfType<WeaponPickup> ();
if(wp != null){
wp.SetAlive(false);
}
SwitchWeapon sw = GameObject.Find ("Camera").GetComponent<SwitchWeapon> ();
if(sw != null){
sw.SetAlive(false);
}
GameObject[] e = GameObject.FindGameObjectsWithTag ("Enemy");
Shooting[] s = new Shooting[e.Length];
for (int i = 0; i < e.Length; i++) {
s[i] = e [i].GetComponent<Shooting> ();
if (s [i] != null) {
s[i].SetAlive(false);
}
}
CrateShooting[] cs = new CrateShooting[e.Length];
for (int i = 0; i < e.Length; i++) {
cs[i] = e [i].GetComponent<CrateShooting> ();
if (cs [i] != null) {
cs[i].SetAlive(false);
}
}
StartCoroutine (startCutScene());
}
}
public void SetActive(bool safez){
safe = safez;
}
private IEnumerator startCutScene() {
player.SetActive (false);
hostage.SetActive (false);
heli.SetActive (true);
cameraCutScene.SetActive (true);
yield return new WaitForSeconds (4.9f);
heli.SetActive (false);
var animator = cameraCutScene.GetComponent<Animator>();
animator.speed = 0;
}
}