MarisaMagicalStudy/Assets/Scripts/Abilities/Upgrades/EnemyCountRuntime.cs

26 lines
873 B
C#

using System;
using System.Collections.Generic;
using UnityEngine;
public class EnemyCountRuntime : MonoBehaviour
{
private List<Collider2D> enemiesInRange = new(); //was supposed to be entity list but trygetcomponent isn't needed because we aren't using the actual entity values
public EnemyCountPowerup baseSO;
public PlayerAbility thisAbility;
private void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag(tag))
{
enemiesInRange.Add(other);
}
thisAbility.powerMultiplier = 1 + baseSO.damageIncreasePercentage * enemiesInRange.Count; //does not stack with other multipliers and must be fixed
}
private void OnTriggerExit2D(Collider2D other)
{
if (!other.CompareTag(tag) && enemiesInRange.Contains(other))
{
enemiesInRange.Remove(other);
}
}
}