-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWave2.cs
More file actions
85 lines (77 loc) · 2.55 KB
/
Wave2.cs
File metadata and controls
85 lines (77 loc) · 2.55 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
public class Wave2 : MonoBehaviour
{
[SerializeField]
private GameObject _child;
[SerializeField]
private GameObject _child2;
[SerializeField]
private GameObject _player, _boss;
[SerializeField]
private PlayableDirector _nextTimeline;
[SerializeField]
private int _time;
[SerializeField]
private PlayableDirector _timeElapsedTimeline;
private Vector3 _enemyPos;
private bool _notDone = true;
private void Start()
{
InstantiateChildren();
RandomModelSelection();
_player.GetComponent<Player>().SetWaveNumber(2);
StartCoroutine(TimerRoutine());
GameObject.FindGameObjectWithTag("Canvas").transform.GetChild(5).gameObject.transform.GetChild(0).gameObject.GetComponent<PlayerWeaponControl>().SetDamageVal(1.1f);
}
private void Update()
{
if (transform.childCount == 0)
{
_nextTimeline.Play();
_player.transform.position = new Vector3(4.03f, 0, 45.3f);
_player.GetComponent<Player>().TopHealth();
_boss.transform.position = new Vector3(9.34f, 0, 130.0f);
this.gameObject.SetActive(false);
}
}
private void InstantiateChildren()
{
_enemyPos = _player.transform.position;
_enemyPos.z += 15;
_enemyPos.x = Random.Range(-15.0f, 1.0f);
GameObject _instChild1 = Instantiate(_child, _enemyPos, Quaternion.identity);
_enemyPos.x = Random.Range(5.0f, 22.0f);
GameObject _instChild2 = Instantiate(_child2, _enemyPos, Quaternion.identity);
_instChild1.transform.parent = this.gameObject.transform;
_instChild2.transform.parent = this.gameObject.transform;
}
private void RandomModelSelection()
{
for (int i = 0; i < transform.childCount; i++)
{
Transform child = transform.GetChild(i);
int randNum = Random.Range(0, 4);
child.GetChild(randNum).gameObject.SetActive(true);
}
}
IEnumerator TimerRoutine()
{
while (_notDone)
{
yield return new WaitForSeconds(1.0f);
if (_time > 0)
{
_time -= 1;
UIManager.Instance.DisplayTime(_time);
}
else
{
_notDone = false;
_timeElapsedTimeline.Play();
}
}
}
}