blob: 3abd55b5842f19e79e8f6a87a16170d7e9f0cc1d (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
using UnityEngine;
public class Lookout : Tower
{
[SerializeField]
private GameObject markIcon;
private GameObject currentMark;
protected override void Update()
{
if (currentTarget != null)
{
markIcon.SetActive(value: true);
UpdateMark();
GainXP();
}
else
{
markIcon.SetActive(value: false);
}
}
private void UpdateMark()
{
if (currentTarget != currentMark)
{
if (currentMark != null)
{
currentMark.GetComponent<Enemy>().mark = null;
}
currentMark = currentTarget;
currentMark.GetComponent<Enemy>().mark = this;
}
markIcon.transform.position = currentMark.transform.position;
}
protected override GameObject SelectEnemy(Collider[] possibleTargets)
{
GameObject result = null;
float num = -1f;
for (int i = 0; i < possibleTargets.Length; i++)
{
float num2 = 1f;
Enemy component = possibleTargets[i].GetComponent<Enemy>();
if (!(component.mark != this) || !(component.mark != null))
{
if (CheckPriority(Priority.Progress))
{
num2 /= Mathf.Max(0.001f, possibleTargets[i].GetComponent<Pathfinder>().distanceFromEnd);
}
if (CheckPriority(Priority.NearDeath))
{
num2 /= Mathf.Max(0.001f, component.CurrentHealth());
}
if (CheckPriority(Priority.MostHealth))
{
num2 *= (float)Mathf.Max(1, component.health);
}
if (CheckPriority(Priority.MostArmor))
{
num2 *= (float)Mathf.Max(1, component.armor);
}
if (CheckPriority(Priority.MostShield))
{
num2 *= (float)Mathf.Max(1, component.shield);
}
if (CheckPriority(Priority.LeastHealth))
{
num2 /= (float)Mathf.Max(1, component.health);
}
if (CheckPriority(Priority.LeastArmor))
{
num2 /= (float)Mathf.Max(1, component.armor);
}
if (CheckPriority(Priority.LeastShield))
{
num2 /= (float)Mathf.Max(1, component.shield);
}
if (CheckPriority(Priority.Fastest))
{
num2 *= Mathf.Max(0.001f, possibleTargets[i].GetComponent<Pathfinder>().speed);
}
if (CheckPriority(Priority.Slowest))
{
num2 /= Mathf.Max(0.001f, possibleTargets[i].GetComponent<Pathfinder>().speed);
}
if (num2 > num)
{
result = component.gameObject;
num = num2;
}
}
}
return result;
}
}
|