Pedro Gomes b16bbc3c73 Update Targeting system
- Targetting tags can now hold more than one tag, keeping IsValidTarget, AlliesContains and HasSameTag checks available.
- Added generic target tags for enemies and players
- Optional specific targetting tags if needed for future enhanced targetting
2024-07-25 22:04:25 +01:00

47 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class Taggable : MonoBehaviour
{
public List<TargetTag> targetTag = new List<TargetTag>();
public bool IsValidTarget(List<TargetTag> tags)
{
for (int i = 0; i < targetTag.Count; i++)
{
if (tags.Contains(targetTag[i])) return true;
}
return false;
}
public bool AlliedTagsContains(List<TargetTag> tags)
{
for (int i = 0; i < targetTag.Count; i++)
{
for (int j = 0; j < tags.Count; j++)
{
if (targetTag[i].AlliedTags.Contains(tags[j])) return true;
}
}
return false;
}
public bool HasSameTag(List<TargetTag> tags)
{
for (int i = 0; i < targetTag.Count; i++)
{
if (tags.Contains(targetTag[i])) return true;
}
return false;
}
//private IEnumerable<TargettingTag> commonItems;
//public bool IsValidTarget(List<TargettingTag> tags)
//{
// commonItems = this.tags.Intersect(tags);
//
// return commonItems.Any();
//}
}