blob: 84a27a91c17ad67f4d8eec994bb8335f3fdad960 (
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
44
45
46
47
48
49
50
51
|
using System.Collections.Generic;
using UnityEngine;
public class SplashDamageArea : MonoBehaviour
{
public enum EShape
{
Sphere,
Box
}
public EShape shape;
public Vector3 boxSize;
public float sphereRadius;
public LayerMask layerMaskRecieveDamage;
private static Collider[] collidersTemp = new Collider[200];
private void OnDrawGizmosSelected()
{
if (shape == EShape.Box)
{
Gizmos.color = Color.red;
Gizmos.matrix = base.transform.localToWorldMatrix;
Gizmos.DrawWireCube(Vector3.zero, boxSize);
}
else
{
Gizmos.color = Color.red;
Gizmos.matrix = base.transform.localToWorldMatrix;
Gizmos.DrawWireSphere(Vector3.zero, sphereRadius);
}
}
public void AddReiveDamageHpScriptsInAreaToList(List<Hp> _listOfHpScripts)
{
int num = 0;
num = ((shape != EShape.Box) ? Physics.OverlapSphereNonAlloc(base.transform.position, sphereRadius, collidersTemp, layerMaskRecieveDamage) : Physics.OverlapBoxNonAlloc(base.transform.position, boxSize, collidersTemp, base.transform.rotation, layerMaskRecieveDamage));
for (int i = 0; i < num; i++)
{
Hp componentInParent = collidersTemp[i].GetComponentInParent<Hp>();
if (!(componentInParent == null) && !_listOfHpScripts.Contains(componentInParent))
{
_listOfHpScripts.Add(componentInParent);
}
}
}
}
|