123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace FL.Battle
- {
- /// <summary>
- /// 目标查找方式
- /// </summary>
- public enum ETargetFindType
- {
- /// <summary>
- /// 找最近的
- /// 过滤移动和受保护的
- /// </summary>
- Nearest = 0,
- /// <summary>
- /// 找最近的
- /// 只过滤死亡,其他状态都可选
- /// </summary>
- NearestAlive,
- /// <summary>
- /// 找范围内的
- /// 过滤移动和受保护的
- /// </summary>
- InRange,
- /// <summary>
- /// 找范围内的
- /// 只过滤死亡,其他状态都可选
- /// </summary>
- InRangeAlive,
- }
- public struct FinderInfo
- {
- public long uid;
- /// <summary>
- /// 世界坐标
- /// </summary>
- public Vector3 position;
- /// <summary>
- /// 半径
- /// </summary>
- public float radius;
- }
- /// <summary>
- /// 目标选择器
- /// </summary>
- public interface ITargetSelector
- {
- ITarget GetTarget(long entityId);
- ITarget GetPlayer();
- /// <summary>
- /// 同步查找目标
- /// </summary>
- /// <param name="finder"></param>
- /// <param name="targetType"></param>
- /// <param name="findType"></param>
- /// <param name="customFilter">自定义过滤器,不能选择时返回true</param>
- /// <returns></returns>
- ITarget FindSync(ITarget finder, EEntityType targetType, ETargetFindType findType = ETargetFindType.Nearest, Func<ITarget, bool> customFilter = null);
- /// <summary>
- /// 同步查找目标
- /// </summary>
- /// <param name="finder"></param>
- /// <param name="targetType"></param>
- /// <param name="findType"></param>
- /// <param name="customFilter">自定义过滤器,不能选择时返回true</param>
- /// <returns></returns>
- ITarget FindSync(FinderInfo finder, EEntityType targetType, ETargetFindType findType = ETargetFindType.Nearest, Func<ITarget, bool> customFilter = null);
- /// <summary>
- /// 查找范围内所有目标
- /// ETargetFindType.Nearest和NearestAlive无效
- /// </summary>
- /// <param name="finder"></param>
- /// <param name="targetType"></param>
- /// <param name="findType"></param>
- /// <param name="customFilter"></param>
- /// <param name="targets"></param>
- /// <returns></returns>
- bool FindTargets(FinderInfo finder, EEntityType targetType, ETargetFindType findType, Func<ITarget, bool> customFilter, ref List<ITarget> targets);
- /// <summary>
- /// 查找范围内所有目标
- /// ETargetFindType.Nearest和NearestAlive无效
- /// </summary>
- /// <param name="rect"></param>
- /// <param name="targetType"></param>
- /// <param name="findType"></param>
- /// <param name="customFilter"></param>
- /// <param name="targets"></param>
- /// <returns></returns>
- bool FindTargets(Rect rect, EEntityType targetType, ETargetFindType findType, Func<ITarget, bool> customFilter, ref List<ITarget> targets);
- /// <summary>
- /// 异步查找目标
- /// </summary>
- /// <param name="finder"></param>
- /// <param name="targetType"></param>
- /// <param name="findType"></param>
- /// <param name="onSelected"></param>
- void FindAsync(ITarget finder, EEntityType targetType, ETargetFindType findType, Action<ITarget> onSelected);
- /// <summary>
- /// 随机一个目标类型的坐标
- /// </summary>
- /// <param name="targetType"></param>
- /// <param name="isCloseToTarget">是否要靠近目标类型</param>
- /// <param name="customFilter">自定义过滤器,不能选择时返回true</param>
- /// <returns></returns>
- Vector3 RandomPosition(EEntityType targetType, bool isCloseToTarget, Func<ITarget, bool> customFilter = null);
- }
- }
|