using System; using System.Collections; using System.Collections.Generic; using Cysharp.Threading.Tasks; using DG.Tweening; using UnityEngine; public class BattleBlobArcher: BattleBlobJob { public GameObject ArrowPrefab; private void Awake() { GetComponent().AttackDistance = 60f; ArrowPrefab = Resources.Load("Arrow"); var animator = GetComponent(); animator.runtimeAnimatorController = Resources.Load("ArchAnimator"); } public async override UniTaskVoid Attack(BattleBlob battleBlob, GameObject target) { // print("attack!"); var go = Instantiate(ArrowPrefab); go.transform.position = battleBlob.transform.position; var arrow = go.GetComponent(); if (arrow) { // Vector3 targetPosition = target.gameObject.transform.position - // (Vector3.left * // (arrow.transform.position - target.gameObject.transform.position) // .sqrMagnitude / arrow.speed) ; var targetPosition = target.gameObject.transform.position; arrow.target = targetPosition; } var trigger = go.GetComponent(); if (trigger) { trigger.onTriggerEnter += collider => { var enemy = collider.GetComponent(); if (!enemy) return; if (enemy.isDead) return; enemy.Health -= (int)battleBlob.AttackDamage; Destroy(go.gameObject); }; } } }