summaryrefslogtreecommitdiff
path: root/GameCode/ActivateSciptWhenCanSeeOtherPlayer.cs
blob: 5a527fc03f0dc61b0c7131bf4023a707caf3cf0a (plain)
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
using UnityEngine;

public class ActivateSciptWhenCanSeeOtherPlayer : MonoBehaviour
{
	public enum Target
	{
		OtherPlayer,
		Closest
	}

	public Target target;

	private SpawnedAttack spawned;

	public MonoBehaviour script;

	private void Start()
	{
		spawned = GetComponentInParent<SpawnedAttack>();
	}

	private void Update()
	{
		Player player = null;
		player = ((target != 0) ? PlayerManager.instance.GetClosestPlayer(base.transform.position, needVision: true) : PlayerManager.instance.GetOtherPlayer(spawned.spawner));
		if ((bool)player)
		{
			if (PlayerManager.instance.CanSeePlayer(base.transform.position, player).canSee)
			{
				script.enabled = true;
			}
			else
			{
				script.enabled = false;
			}
		}
		else
		{
			script.enabled = false;
		}
	}
}