From a22c505984697881f5f911a165ee022087b69e09 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Mon, 20 May 2024 22:36:58 +0800 Subject: *rename --- .../Decompile/Mill_ImprovementWindSpirits.cs | 104 +++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 Thronefall_v1.0/Decompile/Mill_ImprovementWindSpirits.cs (limited to 'Thronefall_v1.0/Decompile/Mill_ImprovementWindSpirits.cs') diff --git a/Thronefall_v1.0/Decompile/Mill_ImprovementWindSpirits.cs b/Thronefall_v1.0/Decompile/Mill_ImprovementWindSpirits.cs new file mode 100644 index 0000000..824352e --- /dev/null +++ b/Thronefall_v1.0/Decompile/Mill_ImprovementWindSpirits.cs @@ -0,0 +1,104 @@ +using System.Collections.Generic; +using UnityEngine; + +public class Mill_ImprovementWindSpirits : MonoBehaviour, DayNightCycle.IDaytimeSensitive +{ + [SerializeField] + private BuildSlot buildSlot; + + [SerializeField] + private float blockIntervalLvl1 = 1f; + + [SerializeField] + private float blockIntervalLvl2 = 0.5f; + + [SerializeField] + private float blockIntervalLvl3 = 0.25f; + + public Mesh lvl2Mesh; + + public Mesh lvl3Mesh; + + private float blockInterval = 1f; + + [SerializeField] + private float range = 30f; + + [SerializeField] + private GameObject fxBlockArrow; + + private float cooldown; + + private TagManager tagManager; + + private List mustHaveTags = new List(); + + private List mayNotHaveTags = new List(); + + private void Start() + { + tagManager = TagManager.instance; + cooldown = Random.value * blockInterval; + mustHaveTags.Add(TagManager.ETag.BlockableEnemyProjectile); + DayNightCycle.Instance.RegisterDaytimeSensitiveObject(this); + } + + private void Update() + { + cooldown -= Time.deltaTime; + while (cooldown <= 0f) + { + BlockAnArrow(); + cooldown += blockInterval; + } + } + + private void BlockAnArrow() + { + TaggedObject taggedObject = tagManager.FindClosestTaggedObjectWithTags(base.transform.position, mustHaveTags, mayNotHaveTags); + if (!(taggedObject == null) && (taggedObject.transform.position - base.transform.position).magnitude < range) + { + if ((bool)fxBlockArrow) + { + Object.Instantiate(fxBlockArrow, taggedObject.transform.position, Quaternion.identity); + } + Object.Destroy(taggedObject.gameObject); + } + } + + private void OnEnable() + { + buildSlot.upgrades[1].upgradeBranches[0].replacementMesh = lvl2Mesh; + buildSlot.upgrades[2].upgradeBranches[0].replacementMesh = lvl3Mesh; + SetCorrectWeapon(); + } + + public void OnDusk() + { + SetCorrectWeapon(); + } + + public void OnDawn_AfterSunrise() + { + } + + public void OnDawn_BeforeSunrise() + { + } + + private void SetCorrectWeapon() + { + if (buildSlot.Level == 1) + { + blockInterval = blockIntervalLvl1; + } + else if (buildSlot.Level == 2) + { + blockInterval = blockIntervalLvl2; + } + else if (buildSlot.Level == 3) + { + blockInterval = blockIntervalLvl3; + } + } +} -- cgit v1.1-26-g67d0