protected override IEnumerator InnerDoAttack(int id, CombatSystem ownerCombatSystem, Transform target) { if (target == null) { yield break; } while (!AnimationStates[id]) { yield return(null); } GameObject projectile = PoolersManager.Instance.TryGetPooler(data.ProjectilePrefab).GetPooledObject(data.DestroyTime); projectile.transform.position = ownerCombatSystem.ProjectileAnchor.position; projectile.transform.rotation = ownerCombatSystem.ProjectileAnchor.rotation; AttackCollider projectileAttackCollider = projectile.GetComponentInChildren <AttackCollider>(); projectileAttackCollider.Initialize(id, data.ColliderRadius, this, ownerCombatSystem.transform.root, ownerCombatSystem); projectileAttackCollider.SetRadius(data.ColliderRadius); ProjectileMovement projectileMovement = projectile.GetComponent <ProjectileMovement>(); projectileMovement.Launch(target, ownerCombatSystem.ProjectileAnchor, data.MinDistance, data.MaxDistance, data.ProjectileSpeed); float timer = 0.0f; while (timer <= data.DestroyTime) { if (HasHit[id]) { projectileMovement.Stop(); if (!data.SplashDamage) { yield break; } projectileAttackCollider.SetRadius(data.SplashDamageRadius); yield return(new WaitForSeconds(data.SplashDamageTime)); yield break; } timer += Time.deltaTime; yield return(null); } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Enemy") { EnemyHealth _eh = other.gameObject.GetComponent <EnemyHealth> (); _eh.DealDamage(Damage); if (DiesOnTouch) { AllowToMove = false; if (_anim != null) { mov.Stop(); } mov.Kill(); } } }