using System.Collections; using System.Collections.Generic; using UnityEngine; public class StraightProjectile : Projectile { [Header("Straight Projectile")] [SerializeField] private int _maxHitEntities = 1; private List _hitEntities = new List(); protected override void ApplyMovement() { transform.position += new Vector3(Speed * Time.deltaTime, 0.0f, 0.0f); } protected override void HandleCollision(Collider2D other) { if (other.CompareTag(Origin.tag)) return; if (other.TryGetComponent(out Entity target) && !HitEntities.Contains(target) && HitEntities.Count < MaxHitEntities) { ApplyEffects(target); target.Hit(Damage); HitEntities.Add(target); if (target.Hp <= 0) { target.Death(); } } if (HitEntities.Count >= MaxHitEntities) { Destroy(gameObject); } } public List HitEntities { get => _hitEntities; set => _hitEntities = value; } public int MaxHitEntities { get => _maxHitEntities; set => _maxHitEntities = value; } }