From 8b1fc7063b387542803c6bc214ccf8acb32870bd Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Sun, 19 May 2024 16:46:27 +0800 Subject: * rename --- Thronefall_1_0/Decompile/PowerTowerPerk.cs | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Thronefall_1_0/Decompile/PowerTowerPerk.cs (limited to 'Thronefall_1_0/Decompile/PowerTowerPerk.cs') diff --git a/Thronefall_1_0/Decompile/PowerTowerPerk.cs b/Thronefall_1_0/Decompile/PowerTowerPerk.cs new file mode 100644 index 0000000..09466d4 --- /dev/null +++ b/Thronefall_1_0/Decompile/PowerTowerPerk.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using UnityEngine; + +public class PowerTowerPerk : MonoBehaviour +{ + [SerializeField] + private Equippable powerTowerPerk; + + [SerializeField] + private List mustHaveTags = new List(); + + [SerializeField] + private List mayNotHaveTags = new List(); + + private TagManager tagManager; + + private float attackSpeedBonus; + + private float nextRefreshIn = 0.2f; + + private TaggedObject closestTower; + + private void Start() + { + if (!PerkManager.IsEquipped(powerTowerPerk)) + { + Object.Destroy(this); + return; + } + tagManager = TagManager.instance; + attackSpeedBonus = PerkManager.instance.powerTower_attackSpeedBonus; + } + + private void Update() + { + nextRefreshIn -= Time.deltaTime; + if (nextRefreshIn <= 0f) + { + closestTower = tagManager.FindClosestTaggedObjectWithTags(base.transform.position, mustHaveTags, mayNotHaveTags); + nextRefreshIn = 0.2f; + } + if (closestTower != null) + { + AutoAttack[] componentsInChildren = closestTower.GetComponentsInChildren(); + for (int i = 0; i < componentsInChildren.Length; i++) + { + componentsInChildren[i].ReduceCooldownBy(attackSpeedBonus * Time.deltaTime); + } + HotOilTower[] componentsInChildren2 = closestTower.GetComponentsInChildren(); + for (int i = 0; i < componentsInChildren2.Length; i++) + { + componentsInChildren2[i].ReduceCooldownBy(attackSpeedBonus * Time.deltaTime); + } + } + } +} -- cgit v1.1-26-g67d0