public bool IsInSkillRange(int skillId, uint targetId) { var spellData = SkillAction.dataMap[SkillData.dataMap[skillId].skillAction[0]]; // 目标类型 0 敌人, 1 自己 2 队友 3 友方 //int targetType = spellData.targetType; // 攻击范围类型。 0 扇形范围 1 圆形范围, 2, 单体。 3 直线范围 4 前方范围 int targetRangeType = spellData.targetRangeType; // 攻击范围参数。 针对不同类型,有不同意义。 浮点数列表 List <float> targetRangeParam = spellData.targetRangeParam; // 最大攻击人数 //int maxTargetCount = spellData.maxTargetCount; // 触发伤害特效帧数 //int damageTriggerFrame = spellData.damageTriggerFrame; List <List <uint> > entities = new List <List <uint> >(); TargetRangeType rangeType = (TargetRangeType)targetRangeType; switch (rangeType) { case TargetRangeType.CircleRange: if (targetRangeParam.Count >= 1) { float radius = targetRangeParam[0] * 0.01f; entities = MogoUtils.GetEntitiesInRange(theOwner.Transform, radius); } break; case TargetRangeType.SectorRange: if (targetRangeParam.Count >= 2) { float radius = targetRangeParam[0] * 0.01f; float angle = targetRangeParam[1]; entities = MogoUtils.GetEntitiesInSector(theOwner.Transform, radius, angle); } break; case TargetRangeType.SingeTarget: if (targetRangeParam.Count >= 1) { float radius = targetRangeParam[0] * 0.01f; float angle = 150; entities = MogoUtils.GetEntitiesInSector(theOwner.Transform, radius, angle); } break; case TargetRangeType.WorldRange: if (targetRangeParam.Count >= 4) { float x1 = targetRangeParam[0] * 0.01f; float y1 = targetRangeParam[1] * 0.01f; float x2 = targetRangeParam[2] * 0.01f; float y2 = targetRangeParam[3] * 0.01f; float minX = Math.Min(x1, x2); float maxX = Math.Max(x1, x2); float minY = Math.Min(y1, y2); float maxY = Math.Max(y1, y2); float radiusX = minX + (maxX - minX) * 0.5f; float radiusY = minY + (maxY - minY) * 0.5f; float radius = Vector2.Distance(new Vector2(x1, y1), new Vector2(x2, y2)) * 0.5f; entities = MogoUtils.GetEntitiesInRange(new Vector3(radiusX, 0, radiusY), radius); } break; case TargetRangeType.LineRange: default: if (targetRangeParam.Count >= 2) { float length = targetRangeParam[0] * 0.01f; float width = targetRangeParam[1] * 0.01f; entities = MogoUtils.GetEntitiesFrontLine(theOwner.Transform, length, theOwner.Transform.forward, width); } break; } if (entities.Count < 3) { return(false); } if (entities[0].Count > 0 && entities[0].Contains(targetId)) { return(true); } if (entities[1].Count > 0 && entities[1].Contains(targetId)) { return(true); } if (entities[2].Count > 0 && entities[2].Contains(targetId)) { return(true); } return(false); }