diff options
| author | chai <215380520@qq.com> | 2024-05-20 22:36:58 +0800 |
|---|---|---|
| committer | chai <215380520@qq.com> | 2024-05-20 22:36:58 +0800 |
| commit | a22c505984697881f5f911a165ee022087b69e09 (patch) | |
| tree | d3c030aef1ae9b8a01c889dd2902bb1e3324e72b /Thronefall_1_0/Decompile/AutoAttack.cs | |
| parent | 4a4cc82d069b26bc4d4532e73860f86b211ca239 (diff) | |
Diffstat (limited to 'Thronefall_1_0/Decompile/AutoAttack.cs')
| -rw-r--r-- | Thronefall_1_0/Decompile/AutoAttack.cs | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/Thronefall_1_0/Decompile/AutoAttack.cs b/Thronefall_1_0/Decompile/AutoAttack.cs deleted file mode 100644 index 71d1aec..0000000 --- a/Thronefall_1_0/Decompile/AutoAttack.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.Events; - -public class AutoAttack : MonoBehaviour -{ - public float cooldownDuration = 1f; - - public float cooldownAfterSpawn = -1f; - - [Range(0f, 1f)] - public float cooldownRandomization; - - [Tooltip("How often this script checks if an attack is possible once the cooldown is down")] - public float recheckTargetInterval = 0.5f; - - public List<TargetPriority> targetPriorities = new List<TargetPriority>(); - - public Weapon weapon; - - public float spawnAttackHeight = 0.5f; - - private TaggedObject taggedObject; - - private float cooldown = -1f; - - private bool onCooldown; - - [Tooltip("While the getDisabledBy auto attack script is on cooldown, this auto attack script here can't attack.")] - public AutoAttack getsDisaledBy; - - private float damageMultiplyer = 1f; - - [HideInInspector] - public UnityEvent onAttackTriggered = new UnityEvent(); - - private Vector3 lastTargetPosition; - - public float DamageMultiplyer - { - get - { - return damageMultiplyer; - } - set - { - damageMultiplyer = value; - } - } - - public Vector3 LastTargetPosition => lastTargetPosition; - - public void ReduceCooldownBy(float _reduceBy) - { - cooldown -= _reduceBy; - } - - private void Start() - { - cooldown = cooldownAfterSpawn; - taggedObject = GetComponent<TaggedObject>(); - } - - private void Update() - { - bool flag = true; - if (getsDisaledBy != null && getsDisaledBy.onCooldown) - { - flag = false; - cooldown += Time.deltaTime; - } - cooldown -= Time.deltaTime; - if (cooldown <= 0f && flag) - { - TaggedObject taggedObject = FindAutoAttackTarget(); - if (taggedObject == null) - { - cooldown += recheckTargetInterval; - onCooldown = false; - return; - } - cooldown += cooldownDuration * (1f + (1f - 2f * Random.value) * cooldownRandomization); - weapon.Attack(base.transform.position + spawnAttackHeight * Vector3.up, taggedObject.Hp, Vector3.zero, this.taggedObject, damageMultiplyer); - lastTargetPosition = taggedObject.transform.position; - onAttackTriggered.Invoke(); - onCooldown = true; - } - } - - public virtual TaggedObject FindAutoAttackTarget() - { - for (int i = 0; i < targetPriorities.Count; i++) - { - TaggedObject taggedObject = targetPriorities[i].FindClosestTaggedObject(base.transform.position); - if (taggedObject != null) - { - return taggedObject; - } - } - return null; - } -} |
