public Unit[] FindUnitsInRange(Vector2 myPosition, float distance, ConflicSide mySide)
    {
        List <Unit> units = mySide == ConflicSide.Player ? EnemyUnits : PlayerUnits;

        Unit[] unitsInRange = units.Select(u => u).Where(u => Vector2.Distance(u.Center, myPosition) <= distance).ToArray( );

        return(unitsInRange);
    }
 public void RemoveUnit(Unit unit, ConflicSide side)
 {
     if (side == ConflicSide.Player)
     {
         PlayerUnits.Remove(unit);
     }
     else
     {
         EnemyUnits.Remove(unit);
     }
 }
 public void AddUnit(Unit unit, ConflicSide side)
 {
     if (side == ConflicSide.Player)
     {
         PlayerUnits.Add(unit);
     }
     else
     {
         EnemyUnits.Add(unit);
     }
 }
    public Unit FindFriendly(ConflicSide mySide, Vector2 myPosition, float distance, Unit caller)
    {
        Unit  friendly         = null;
        float opponentDistance = int.MaxValue;

        List <Unit> friendlies = mySide == ConflicSide.Player ? PlayerUnits : EnemyUnits;

        foreach (var fr in friendlies)
        {
            float opDistance = Vector2.Distance(fr.Center, myPosition);
            if (opDistance <= distance && fr != caller && !fr.NonMovable)
            {
                if (opDistance < opponentDistance)
                {
                    opponentDistance = opDistance;
                    friendly         = fr;
                }
            }
        }

        return(friendly);
    }
    public Unit FindOpponent(ConflicSide mySide, Vector2 myPosition, float distance)
    {
        Unit  opponent         = null;
        float opponentDistance = int.MaxValue;

        List <Unit> opponents = mySide == ConflicSide.Player ? EnemyUnits : PlayerUnits;

        foreach (var op in opponents)
        {
            float opDistance = Vector2.Distance(op.Center, myPosition);
            if (opDistance <= distance)
            {
                if (opDistance < opponentDistance)
                {
                    opponentDistance = opDistance;
                    opponent         = op;
                }
            }
        }

        return(opponent);
    }