-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUltimateLaser.cs
More file actions
69 lines (55 loc) · 2.18 KB
/
UltimateLaser.cs
File metadata and controls
69 lines (55 loc) · 2.18 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class UltimateLaser : MonoBehaviour
{
[Tooltip("The state of the support spaceship abillity to shield the ally")] bool ultReady;
[Tooltip("The number of seconds that the shield remains active")] [SerializeField] float duration;
[SerializeField] CircleAnim UltLaserTimer;
[SerializeField] InputAction activateAbility = new InputAction(type: InputActionType.Button);
private void Start() {
this.ultReady = true;
}
void OnEnable() {
activateAbility.Enable();
}
void OnDisable() {
activateAbility.Disable();
}
private void LaserUlt() {
if (ultReady) {
Debug.Log("Shield triggered by player");
var LaserShoot = gameObject.GetComponent<LaserShooter>();
// var shieldAnimation = other.GetComponent<SpawnShield>();
// shieldAnimation.SetActive(false);
if (LaserShoot) {
LaserShoot.StartCoroutine(EnableUltLaser(LaserShoot)); // co-routines
ultReady = false;
}
}
}
private IEnumerator EnableUltLaser(LaserShooter laserShoot) { // co-routines
// private async void ShieldTemporarily(DestroyOnTrigger2D destroyComponent) { // async-await
laserShoot.SetAbility(true);
UltLaserTimer.resetCircle();
for (float i = duration; i > 0; i--) {
Debug.Log("LaserUlt: " + i + " seconds remaining!");
yield return new WaitForSeconds(1); // co-routines
// await Task.Delay(1000); // async-await
}
laserShoot.SetAbility(false);
for (float i = 10; i > 0; i--) {
Debug.Log("Shield abbility: " + i + " seconds remaining!");
yield return new WaitForSeconds(1); // co-routines
// await Task.Delay(1000); // async-await
}
UltLaserTimer.SetCircleColor(true);
this.ultReady = true;
}
private void Update() {
if(activateAbility.WasPressedThisFrame()) {
LaserUlt();
}
}
}