generated from PurdueSIGGD/SIGGD-Unity-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PulseScanner.cs
51 lines (42 loc) · 1.28 KB
/
PulseScanner.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class PulseScanner : Item
{
[SerializeField] public float scanDuration = 10f;
GameObject[] enemies = null;
static int active_count = 0;
public override void Use()
{
if (useSound != null)
{
Instantiate(useSound, transform.position, Quaternion.identity);
Debug.Log("SOUND FOUND");
}
Debug.Log("SCAN USING");
active_count++;
enemies = GameObject.FindGameObjectsWithTag("Enemy");
Debug.Log("SCAN ENEMIES FOUND: " + enemies.Length);
if (active_count == 1)
{
Debug.Log("SCAN: We're GOING FOR IT!!!!!");
foreach (GameObject enemy in enemies)
{
enemy.transform.GetChild(1).GetChild(1).gameObject.SetActive(true);
Debug.Log("ICON ON: " + enemy.transform.GetChild(1).GetChild(1).gameObject.name);
}
}
}
public override void End()
{
if (active_count == 1)
{
foreach (GameObject enemy in enemies)
{
enemy.transform.GetChild(1).GetChild(1).gameObject.SetActive(false);
}
}
active_count--;
}
}