From b45e22c164fa364263b00ce82842999f8e5976b2 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Sun, 26 Nov 2023 23:54:38 +0800 Subject: *move --- Assembly_CSharp/Tower/Lookout.cs | 97 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 Assembly_CSharp/Tower/Lookout.cs (limited to 'Assembly_CSharp/Tower/Lookout.cs') diff --git a/Assembly_CSharp/Tower/Lookout.cs b/Assembly_CSharp/Tower/Lookout.cs new file mode 100644 index 0000000..3abd55b --- /dev/null +++ b/Assembly_CSharp/Tower/Lookout.cs @@ -0,0 +1,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().mark = null; + } + currentMark = currentTarget; + currentMark.GetComponent().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(); + if (!(component.mark != this) || !(component.mark != null)) + { + if (CheckPriority(Priority.Progress)) + { + num2 /= Mathf.Max(0.001f, possibleTargets[i].GetComponent().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().speed); + } + if (CheckPriority(Priority.Slowest)) + { + num2 /= Mathf.Max(0.001f, possibleTargets[i].GetComponent().speed); + } + if (num2 > num) + { + result = component.gameObject; + num = num2; + } + } + } + return result; + } +} -- cgit v1.1-26-g67d0