summaryrefslogtreecommitdiff
path: root/ROUNDS/PlayerImmunity.cs
blob: 791fadf30e337dfaa796d635aecf36b525ef5546 (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
43
using System.Collections.Generic;
using UnityEngine;

public class PlayerImmunity : MonoBehaviour
{
	private List<Immunities> immunities = new List<Immunities>();

	private void Start()
	{
	}

	private void Update()
	{
		for (int num = immunities.Count - 1; num >= 0; num--)
		{
			immunities[num].time -= TimeHandler.deltaTime;
			if (immunities[num].time <= 0f)
			{
				immunities.RemoveAt(num);
			}
		}
	}

	public bool IsImune(float time, float dmg, string name)
	{
		for (int i = 0; i < immunities.Count; i++)
		{
			if (immunities[i].name == name)
			{
				if (dmg > immunities[i].dmg)
				{
					immunities[i].dmg = dmg;
					immunities[i].name = name;
					immunities[i].time = time;
					return false;
				}
				return true;
			}
		}
		immunities.Add(new Immunities(time, dmg, name));
		return false;
	}
}