public SaveResult InsertOrUpdate(ref CharacterRelationDTO characterRelation) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { long characterId = characterRelation.CharacterId; long relatedCharacterId = characterRelation.RelatedCharacterId; CharacterRelation entity = context.CharacterRelation.FirstOrDefault(c => c.CharacterId.Equals(characterId) && c.RelatedCharacterId.Equals(relatedCharacterId)); if (entity == null) { characterRelation = insert(characterRelation, context); return(SaveResult.Inserted); } characterRelation = update(entity, characterRelation, context); return(SaveResult.Updated); } } catch (Exception e) { Logger.Error(string.Format(Language.Instance.GetMessageFromKey("UPDATE_CHARACTERRELATION_ERROR"), characterRelation.CharacterRelationId, e.Message), e); return(SaveResult.Error); } }
public static CharacterRelation GetRelation(int campA, int campB) { CharacterRelation relation = CharacterRelation.RELATION_INVALID; if ((int)CampIdEnum.Unkown != campA && (int)CampIdEnum.Unkown != campB) { if (campA == campB) { relation = CharacterRelation.RELATION_FRIEND; } else if (campA == (int)CampIdEnum.Friendly || campB == (int)CampIdEnum.Friendly) { relation = CharacterRelation.RELATION_FRIEND; } else if (campA == (int)CampIdEnum.Hostile || campB == (int)CampIdEnum.Hostile) { relation = CharacterRelation.RELATION_ENEMY; } else { relation = CharacterRelation.RELATION_ENEMY; } } return(relation); }
private static bool IsWantedTargetForRandomTarget(CharacterInfo srcObj, CharacterRelation relation, AiTargetType type, ISpaceObject obj) { if (type == AiTargetType.USER && obj.GetObjType() != SpatialObjType.kUser) { return(false); } if (type == AiTargetType.NPC && obj.GetObjType() != SpatialObjType.kNPC) { return(false); } CharacterInfo target = GetSeeingLivingCharacterInfoHelper(srcObj, (int)obj.GetID()); if (null != target && !target.IsDead()) { if (target.IsControlMecha) { return(false); } NpcInfo npcTarget = target.CastNpcInfo(); if (null != npcTarget && npcTarget.NpcType == (int)NpcTypeEnum.Skill) { return(false); } if (relation == CharacterInfo.GetRelation(srcObj, target)) { if (CanSee(srcObj, target)) { return(true); } } } return(false); }
public static EntityInfo GetNearstAttackerHelper(EntityInfo srcObj, CharacterRelation relation, AiData_General aidata) { EntityInfo ret = null; float minDistSqr = 999999; Vector2 dir = srcObj.GetMovementStateInfo().GetFaceDir2D(); Vector2 pos = srcObj.GetMovementStateInfo().GetPosition2D(); if (relation == CharacterRelation.RELATION_ENEMY) { foreach (var pair in srcObj.AttackerInfos) { EntityInfo target = srcObj.SceneContext.GetEntityById(pair.Key); if (null != target) { float distSqr = Geometry.DistanceSquare(pos, target.GetMovementStateInfo().GetPosition2D()); if (distSqr <= (srcObj.ViewRange + target.GetRadius()) * (srcObj.ViewRange + target.GetRadius())) { if (distSqr <= minDistSqr) { ret = target; minDistSqr = distSqr; } } } } } return(ret); }
public static EntityInfo GetHearstTargetHelper(EntityInfo srcObj,float range,CharacterRelation relation, AiTargetType type) { EntityInfo nearstTarget = null; float minPowDist = 999999; srcObj.SceneContext.KdTree.Query(srcObj, range, (float distSqr, KdTreeObject kdTreeObj) => { StepCalcNearstTarget(srcObj, relation, type, distSqr, kdTreeObj.Object, ref minPowDist, ref nearstTarget); }); return nearstTarget; }
public static EntityInfo GetNearstTargetHelper(EntityInfo srcObj, float range, CharacterRelation relation, AiTargetType type) { EntityInfo nearstTarget = null; float minDistSqr = 999999; srcObj.SceneContext.KdTree.QueryWithAction(srcObj, range, (float distSqr, KdTreeObject kdTreeObj) => { StepCalcNearstTarget(srcObj, relation, type, distSqr, kdTreeObj.Object, ref minDistSqr, ref nearstTarget); }); return(nearstTarget); }
internal int GetBattleNpcCount(EntityInfo src, CharacterRelation relation) { int ct = 0; for (LinkedListNode<EntityInfo> linkNode = m_EntityMgr.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next) { EntityInfo info = linkNode.Value; if (null != info && !info.IsDead() && info.IsCombatNpc() && EntityInfo.GetRelation(src, info) == relation) { ++ct; } } return ct; }
internal int GetDyingBattleNpcCount(int campId, CharacterRelation relation) { int ct = 0; for (LinkedListNode<EntityInfo> linkNode = m_EntityMgr.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next) { EntityInfo info = linkNode.Value; if (null != info && info.IsDead() && info.DeadTime != 0 && info.IsCombatNpc() && EntityInfo.GetRelation(campId, info.GetCampId()) == relation) { ++ct; } } return ct; }
public static bool ToCharacterRelationDTO(CharacterRelation input, CharacterRelationDTO output) { if (input == null) { return(false); } output.CharacterId = input.CharacterId; output.CharacterRelationId = input.CharacterRelationId; output.RelatedCharacterId = input.RelatedCharacterId; output.RelationType = input.RelationType; return(true); }
internal int GetDyingBattleNpcCount(int campId, CharacterRelation relation) { int ct = 0; for (LinkedListNode <EntityInfo> linkNode = m_EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next) { EntityInfo info = linkNode.Value; if (null != info && info.IsDead() && info.DeadTime != 0 && info.IsCombatNpc() && EntityInfo.GetRelation(campId, info.GetCampId()) == relation) { ++ct; } } return(ct); }
private bool HaveNpcInRange(EntityInfo entity, CharacterRelation relation, float radius) { bool find = false; KdTree.QueryWithFunc(entity, radius, (float sqrDist, KdTreeObject obj) => { if (EntityInfo.GetRelation(entity, obj.Object) == relation) { find = true; return(false); } return(true); }); return(find); }
private static CharacterRelationDTO insert(CharacterRelationDTO relation, OpenNosContext context) { CharacterRelation entity = new CharacterRelation(); Mapper.Mappers.CharacterRelationMapper.ToCharacterRelation(relation, entity); context.CharacterRelation.Add(entity); context.SaveChanges(); if (Mapper.Mappers.CharacterRelationMapper.ToCharacterRelationDTO(entity, relation)) { return(relation); } return(null); }
internal int GetBattleNpcCount(EntityInfo src, CharacterRelation relation) { int ct = 0; for (LinkedListNode <EntityInfo> linkNode = m_EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next) { EntityInfo info = linkNode.Value; if (null != info && !info.IsDead() && info.IsCombatNpc() && EntityInfo.GetRelation(src, info) == relation) { ++ct; } } return(ct); }
private static void GetInterestestTarget(CharacterInfo srcObj, CharacterRelation relation, AiTargetType type, float powDist, ISpaceObject obj, ref float minPowDist, ref CharacterInfo interestestTarget) { if (type == AiTargetType.USER && obj.GetObjType() != SpatialObjType.kUser) { return; } if (type == AiTargetType.TOWER && obj.GetObjType() != SpatialObjType.kNPC) { return; } if (type == AiTargetType.SOLDIER && obj.GetObjType() != SpatialObjType.kNPC) { return; } CharacterInfo target = GetSeeingLivingCharacterInfoHelper(srcObj, (int)obj.GetID()); if (null != target && !target.IsDead()) { if (target.IsControlMecha) { return; } NpcInfo npcTarget = target.CastNpcInfo(); if (null != npcTarget && npcTarget.NpcType == (int)NpcTypeEnum.Skill) { return; } if (type == AiTargetType.SOLDIER && npcTarget.IsPvpTower) { return; } if (type == AiTargetType.TOWER && !npcTarget.IsPvpTower) { return; } if (relation == CharacterInfo.GetRelation(srcObj, target)) { if (powDist < minPowDist) { if (powDist > c_MaxViewRangeSqr || CanSee(srcObj, target)) { interestestTarget = target; minPowDist = powDist; } } } } }
private static CharacterRelationDTO update(CharacterRelation entity, CharacterRelationDTO relation, OpenNosContext context) { if (entity != null) { Mapper.Mappers.CharacterRelationMapper.ToCharacterRelation(relation, entity); context.SaveChanges(); } if (Mapper.Mappers.CharacterRelationMapper.ToCharacterRelationDTO(entity, relation)) { return(relation); } return(null); }
public static CharacterInfo GetInterestestTargetHelper(CharacterInfo srcObj, CharacterRelation relation, AiTargetType type) { CharacterInfo interestestTarget = null; DashFireSpatial.ISpatialSystem spatialSys = srcObj.SpatialSystem; if (null != spatialSys) { ScriptRuntime.Vector3 srcPos = srcObj.GetMovementStateInfo().GetPosition3D(); float minPowDist = 999999; spatialSys.VisitObjectInCircle(srcPos, srcObj.ViewRange, (float distSqr, ISpaceObject obj) => { GetInterestestTarget(srcObj, relation, type, distSqr, obj, ref minPowDist, ref interestestTarget); }); } return(interestestTarget); }
public static CharacterInfo GetRandomTargetHelper(CharacterInfo srcObj, CharacterRelation relation, AiTargetType type) { CharacterInfo target = null; DashFireSpatial.ISpatialSystem spatialSys = srcObj.SpatialSystem; if (null != spatialSys) { List <DashFireSpatial.ISpaceObject> objs = spatialSys.GetObjectInCircle(srcObj.GetMovementStateInfo().GetPosition3D(), srcObj.ViewRange, (distSqr, obj) => IsWantedTargetForRandomTarget(srcObj, relation, type, obj)); int index = Helper.Random.Next(objs.Count); if (index >= 0 && index < objs.Count) { target = objs[index].RealObject as CharacterInfo; } } return(target); }
public static bool IsEnemy(GameObject obj, GameObject other) { SharedGameObjectInfo obj_info = LogicSystem.GetSharedGameObjectInfo(obj); SharedGameObjectInfo other_info = LogicSystem.GetSharedGameObjectInfo(other); if (obj_info == null || other_info == null) { return(false); } CharacterRelation relation = ArkCrossEngine.CharacterInfo.GetRelation(obj_info.CampId, other_info.CampId); if (relation == CharacterRelation.RELATION_ENEMY) { return(true); } return(false); }
public CharacterInfo GetInterestestTargetHelper(CharacterInfo srcObj, CharacterRelation relation) { CharacterInfo interestTarget = null; List <AiTargetType> priorityList = new List <AiTargetType>(); priorityList.Add(AiTargetType.SOLDIER); priorityList.Add(AiTargetType.TOWER); priorityList.Add(AiTargetType.USER); for (int index = 0; index < priorityList.Count; ++index) { interestTarget = AiLogicUtility.GetInterestestTargetHelper(srcObj, relation, priorityList[index]); if (null != interestTarget) { break; } } return(interestTarget); }
//阵营可为Friendly、Hostile、Blue、Red //Friendly 全部友好 //Hostile 全部敌对(同阵营友好) //Blue 与Hostile与Red敌对 //Red 与Hostile与Blue敌对 public static CharacterRelation GetRelation(EntityInfo pObj_A, EntityInfo pObj_B) { if (pObj_A == null || pObj_B == null) { return(CharacterRelation.RELATION_INVALID); } if (pObj_A == pObj_B) { return(CharacterRelation.RELATION_FRIEND); } int campA = pObj_A.GetCampId(); int campB = pObj_B.GetCampId(); CharacterRelation relation = GetRelation(campA, campB); return(relation); }
private static void StepCalcNearstTarget(EntityInfo srcObj, CharacterRelation relation, AiTargetType type, float powDist, EntityInfo obj, ref float minPowDist, ref EntityInfo nearstTarget) { EntityInfo target = GetSeeingLivingCharacterInfoHelper(srcObj, obj.GetId()); if (null != target && !target.IsDead()) { if (!target.IsTargetNpc()) { return; } if (type == AiTargetType.HERO && target.EntityType != (int)EntityTypeEnum.Hero) { return; } if (type == AiTargetType.TOWER && target.EntityType != (int)EntityTypeEnum.Tower) { return; } if (type == AiTargetType.BOSS && target.EntityType != (int)EntityTypeEnum.Boss) { return; } if (type == AiTargetType.NPC && target.EntityType != (int)EntityTypeEnum.Normal) { return; } if (relation == EntityInfo.GetRelation(srcObj, target)) { if (powDist < minPowDist) { if (powDist > c_MaxViewRangeSqr || CanSee(srcObj, target)) { nearstTarget = target; minPowDist = powDist; } } } } }
private static CharacterRelationDTO update(CharacterRelation entity, CharacterRelationDTO relation, OpenNosContext context) { if (entity != null) { try { Mapper.Mappers.CharacterRelationMapper.ToCharacterRelation(relation, entity); context.SaveChanges(); } catch (InvalidOperationException ex) { Logger.Warn($"The Character Relation with ID:{relation.CharacterRelationId} is Wrong! Error:{ex.Message}"); } } if (Mapper.Mappers.CharacterRelationMapper.ToCharacterRelationDTO(entity, relation)) { return(relation); } return(null); }
private void IdleHandler(EntityInfo npc, long deltaTime) { AiData_Leader aiData = GetAiData(npc); SkillInfo skInfo = AiLogicUtility.NpcFindCanUseSkill(npc, aiData, aiData.IsAutoOperate); if (skInfo == null) { return; } CharacterRelation relation = (skInfo.TargetType == SkillTargetType.Friend || skInfo.TargetType == SkillTargetType.RandFriend) ? CharacterRelation.RELATION_FRIEND : CharacterRelation.RELATION_ENEMY; EntityInfo attackTarget = AiLogicUtility.GetNearstTargetHelper(npc, aiData.IsAutoOperate ? npc.ViewRange : skInfo.Distance, relation); if (attackTarget != null) { ChangeToState(npc, (int)AiStateId.Combat); } }
public static EntityInfo GetNearstAttackerHelper(EntityInfo srcObj, CharacterRelation relation, AiData_General aidata) { EntityInfo ret = null; float minDistSqr = 999999; Vector2 dir = srcObj.GetMovementStateInfo().GetFaceDir2D(); Vector2 pos = srcObj.GetMovementStateInfo().GetPosition2D(); if (relation == CharacterRelation.RELATION_ENEMY) { foreach (var pair in srcObj.AttackerInfos) { EntityInfo target = srcObj.SceneContext.GetEntityById(pair.Key); if (null != target) { float distSqr = Geometry.DistanceSquare(pos, target.GetMovementStateInfo().GetPosition2D()); if (distSqr <= (srcObj.ViewRange + target.GetRadius()) * (srcObj.ViewRange + target.GetRadius())) { if (distSqr <= minDistSqr) { ret = target; minDistSqr = distSqr; } } } } } return ret; }
public static CharacterRelation GetRelation(GameObject one, GameObject other, int signforskill) { SharedGameObjectInfo obj_info = LogicSystem.GetSharedGameObjectInfo(one); SharedGameObjectInfo other_info = LogicSystem.GetSharedGameObjectInfo(other); if (obj_info == null || other_info == null) { return(CharacterRelation.RELATION_INVALID); } if (obj_info.SummonOwnerActorId == other_info.m_ActorId) { return(CharacterRelation.RELATION_OWNER); } else if (CheckTwoIsOneProgeny(obj_info, other_info, signforskill)) { return(CharacterRelation.RELATION_FITSIGNSONS); } else { CharacterRelation relation = ArkCrossEngine.CharacterInfo.GetRelation(obj_info.CampId, other_info.CampId); return(relation); } }
public DeleteResult Delete(long characterRelationId) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { CharacterRelation relation = context.CharacterRelation.SingleOrDefault(c => c.CharacterRelationId.Equals(characterRelationId)); if (relation != null) { context.CharacterRelation.Remove(relation); context.SaveChanges(); } return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Error(string.Format(Language.Instance.GetMessageFromKey("DELETE_CHARACTER_ERROR"), characterRelationId, e.Message), e); return(DeleteResult.Error); } }
private static void StepCalcNearstTarget(EntityInfo srcObj, CharacterRelation relation, AiTargetType type, float distSqr, EntityInfo obj, ref float minDistSqr, ref EntityInfo nearstTarget) { EntityInfo target = GetSeeingLivingCharacterInfoHelper(srcObj, obj.GetId()); if (null != target && !target.IsDead()) { if (!target.IsTargetNpc()) { return; } if (type == AiTargetType.HERO && target.EntityType != (int)EntityTypeEnum.Hero) { return; } if (type == AiTargetType.BOSS && target.EntityType != (int)EntityTypeEnum.Boss) { return; } if (type == AiTargetType.NPC && target.EntityType != (int)EntityTypeEnum.Normal) { return; } if (relation == EntityInfo.GetRelation(srcObj, target)) { if (srcObj.EntityType == (int)EntityTypeEnum.Hero || !srcObj.IsPassive || srcObj.AttackerInfos.ContainsKey(target.GetId())) { if (distSqr < minDistSqr) { nearstTarget = target; minDistSqr = distSqr; } } } } }
private bool CombatHandler(EntityInfo npc, AiStateInfo info, long deltaTime) { if (npc.GetSkillStateInfo().IsSkillActivated()) { return(true); } EntityInfo leader = AiLogicUtility.GetLivingCharacterInfoHelper(npc, info.LeaderId); ScriptRuntime.Vector3 srcPos = npc.GetMovementStateInfo().GetPosition3D(); ScriptRuntime.Vector3 homePos = ScriptRuntime.Vector3.Zero; if (null != leader) { homePos = GetHomePos(npc.GetMovementStateInfo().FormationIndex, leader); } float distSqrToHome = Geometry.DistanceSquare(srcPos, homePos); if (distSqrToHome > npc.GohomeRange * npc.GohomeRange) { AiCommand.AiStopPursue(npc); info.ChangeToState((int)AiStateId.Gohome); return(true); } /// EntityInfo attackTarget = null; SkillStateInfo currSkInfo = npc.GetSkillStateInfo(); ///找到可以使用的技能 SkillInfo skInfo = AiLogicUtility.NpcFindCanUseSkill(npc); AiCommand.AiSelectSkill(npc, skInfo); if (skInfo == null) { //没有可以使用的技能就切换到Idle状态 info.ChangeToState((int)PredefinedAiStateId.Idle); return(false); } CharacterRelation relation = (skInfo.TargetType == SkillTargetType.Friend || skInfo.TargetType == SkillTargetType.RandFriend) ? CharacterRelation.RELATION_FRIEND : CharacterRelation.RELATION_ENEMY; attackTarget = AiLogicUtility.GetNearstTargetHelper( npc, skInfo.Distance, relation); if (attackTarget != null && null != skInfo) //攻击范围内找到可攻击目标 { info.Target = attackTarget.GetId(); AiCommand.AiStopPursue(npc); AiCommand.AiSkill(npc, skInfo.SkillId); //攻击目标 return(true); } attackTarget = AiLogicUtility.GetNearstTargetHelper( npc, npc.ViewRange, relation); if (attackTarget != null) //视野范围内找到可攻击目标 { AiCommand.AiPursue(npc, attackTarget.GetMovementStateInfo().GetPosition3D()); // 追赶目标 return(true); } currSkInfo.SetCurSkillInfo(0); AiCommand.AiStopPursue(npc); info.ChangeToState((int)AiStateId.Gohome); return(true); }
public static CharacterInfo GetRandomTargetHelper(CharacterInfo srcObj, CharacterRelation relation) { return(GetNearstTargetHelper(srcObj, relation, AiTargetType.ALL)); }
public static EntityInfo GetNearstTargetHelper(EntityInfo srcObj, CharacterRelation relation, AiTargetType type) { return(GetNearstTargetHelper(srcObj, srcObj.ViewRange, relation, type)); }
public static EntityInfo GetNearstTargetHelper(EntityInfo srcObj, float range, CharacterRelation relation) { return(GetNearstTargetHelper(srcObj, range, relation, AiTargetType.ALL)); }
private void CombatHandler(EntityInfo npc, long deltaTime) { if (npc.GetSkillStateInfo().IsSkillActivated()) { return; } AiStateInfo info = npc.GetAiStateInfo(); Vector3 targetPos = info.HomePos; ScriptRuntime.Vector3 srcPos = npc.GetMovementStateInfo().GetPosition3D(); float distSqrToHome = Geometry.DistanceSquare(srcPos, info.HomePos); if (distSqrToHome > npc.GohomeRange * npc.GohomeRange) { NotifyAiStopPursue(npc); ChangeToState(npc, (int)AiStateId.GoHome); return; } /// EntityInfo attackTarget = null; SkillStateInfo currSkInfo = npc.GetSkillStateInfo(); ///找到可以使用的技能 SkillInfo skInfo = AiLogicUtility.NpcFindCanUseSkill(npc, this.GetAiData(npc), true); NotifyAiSelectSkill(npc, skInfo); if (skInfo == null) { //没有可以使用的技能就切换到Idle状态 ChangeToState(npc, (int)AiStateId.Idle); return; } CharacterRelation relation = (skInfo.TargetType == SkillTargetType.Friend || skInfo.TargetType == SkillTargetType.RandFriend) ? CharacterRelation.RELATION_FRIEND : CharacterRelation.RELATION_ENEMY; attackTarget = AiLogicUtility.GetNearstTargetHelper( npc, skInfo.Distance, relation); if (attackTarget != null && null != skInfo) //攻击范围内找到可攻击目标 { info.Target = attackTarget.GetId(); NotifyAiStopPursue(npc); NotifyAiSkill(npc, skInfo.SkillId); //攻击目标 return; } attackTarget = AiLogicUtility.GetNearstTargetHelper( npc, npc.ViewRange, relation); if (attackTarget != null) //视野范围内找到可攻击目标 { NotifyAiPursue(npc, attackTarget.GetMovementStateInfo().GetPosition3D()); // 追赶目标 return; } currSkInfo.SetCurSkillInfo(0); NotifyAiStopPursue(npc); ChangeToState(npc, (int)AiStateId.GoHome); }
public static List <GameObject> FiltByRelation(GameObject source, List <GameObject> list, CharacterRelation relation, int signforskill) { List <GameObject> result = new List <GameObject>(); foreach (GameObject obj in list) { if (GetRelation(source, obj, signforskill) == relation) { result.Add(obj); } } return(result); }
public static EntityInfo GetNearstTargetHelper(EntityInfo srcObj, CharacterRelation relation, AiTargetType type) { return GetHearstTargetHelper(srcObj,srcObj.ViewRange,relation,type); }
public static EntityInfo GetNearstTargetHelper(EntityInfo srcObj, float range,CharacterRelation relation) { return GetHearstTargetHelper(srcObj, range, relation, AiTargetType.ALL); }
private bool CombatHandler(EntityInfo npc, AiStateInfo info, long deltaTime) { info.Time += deltaTime; if (info.Time > 100) { info.Time = 0; } else { return(true); } if (npc.GetSkillStateInfo().IsSkillActivated()) { return(true); } ScriptRuntime.Vector3 srcPos = npc.GetMovementStateInfo().GetPosition3D(); float distSqrToHome = Geometry.DistanceSquare(srcPos, info.HomePos); if (distSqrToHome > npc.GohomeRange * npc.GohomeRange) { AiCommand.AiStopPursue(npc); info.ChangeToState((int)AiStateId.Gohome); return(true); } /// EntityInfo attackTarget = null; SkillStateInfo currSkInfo = npc.GetSkillStateInfo(); ///找到可以使用的技能 SkillInfo skInfo = AiLogicUtility.NpcFindCanUseSkill(npc); AiCommand.AiSelectSkill(npc, skInfo); if (skInfo == null) { AiCommand.AiStopPursue(npc); info.ChangeToState((int)PredefinedAiStateId.Idle); return(false); } CharacterRelation relation = skInfo.ConfigData.targetType == (int)SkillTargetType.Friend ? CharacterRelation.RELATION_FRIEND : CharacterRelation.RELATION_ENEMY; attackTarget = AiLogicUtility.GetNearstTargetHelper( npc, skInfo.Distance, relation); if (attackTarget != null && null != skInfo) //攻击范围内找到可攻击目标 { info.Target = attackTarget.GetId(); ScriptRuntime.Vector3 targetPos = attackTarget.GetMovementStateInfo().GetPosition3D(); float dir = Geometry.GetYRadian(srcPos, targetPos); float curDir = npc.GetMovementStateInfo().GetFaceDir(); if (Mathf.Abs(dir - curDir) > 0.157f) { npc.GetMovementStateInfo().SetWantedFaceDir(dir); } else { AiCommand.AiStopPursue(npc); AiCommand.AiSkill(npc, skInfo.SkillId); //攻击目标 } return(true); } attackTarget = AiLogicUtility.GetNearstTargetHelper( npc, npc.ViewRange, relation); if (attackTarget != null) //视野范围内找到可攻击目标 { AiCommand.AiPursue(npc, attackTarget.GetMovementStateInfo().GetPosition3D()); // 追赶目标 return(true); } currSkInfo.SetCurSkillInfo(0); AiCommand.AiStopPursue(npc); return(true); }
private bool HaveNpcInRange(EntityInfo entity, CharacterRelation relation, float radius) { bool find = false; KdTree.Query(entity, radius, (float sqrDist, KdTreeObject obj) => { if (EntityInfo.GetRelation(entity, obj.Object) == relation) { find = true; return false; } return true; }); return find; }