using System.Collections; using System.Collections.Generic; using UnityEngine; namespace DragonCrashers { public class UnitTargetsBehaviour : MonoBehaviour { [Header("Targets")] public List targetUnits; public void AddTargetUnits(List addedUnits) { targetUnits.Clear(); for(int i = 0; i < addedUnits.Count; i++) { targetUnits.Add(addedUnits[i]); } } public void RemoveTargetUnit(UnitController removedUnit) { targetUnits.Remove(removedUnit); } public List FilterTargetUnits(TargetType targetType) { List filteredUnits = new List(); if(targetUnits.Count <= 0) { return filteredUnits; } switch (targetType) { case TargetType.RandomTarget: int randomUnit = Random.Range(0, targetUnits.Count); filteredUnits.Add(targetUnits[randomUnit]); break; case TargetType.AllTargets: filteredUnits = targetUnits; break; } return filteredUnits; } public UnitController GetRandomTargetUnit() { int randomUnit = Random.Range(0, targetUnits.Count); return targetUnits[randomUnit]; } public List GetAllTargetUnits() { return targetUnits; } } }