internal static void Execute(object msg, NetConnection conn) { Msg_RC_NpcMove targetmsg = msg as Msg_RC_NpcMove; if (null == targetmsg) { return; } EntityInfo npc = PluginFramework.Instance.GetEntityById(targetmsg.npc_id); if (null == npc) { return; } if (targetmsg.velocity > 0) { float x, y; float tx, ty; ProtoHelper.DecodePosition2D(targetmsg.cur_pos, out x, out y); ProtoHelper.DecodePosition2D(targetmsg.target_pos, out tx, out ty); Vector2 curPos = new Vector2(x, y); Vector2 targetPos = new Vector2(tx, ty); MovementStateInfo msi = npc.GetMovementStateInfo(); float velocity = ProtoHelper.DecodeFloat(targetmsg.velocity); npc.ActualProperty.SetFloat(CharacterPropertyEnum.x2011_最终速度, velocity); if (Geometry.DistanceSquare(msi.GetPosition2D(), curPos) > c_MaxPosDeltaSqr) { msi.SetPosition2D(curPos); UnityEngine.GameObject actor = EntityController.Instance.GetGameObject(npc.GetId()); GameFramework.Skill.Trigers.TriggerUtil.MoveObjTo(actor, new UnityEngine.Vector3(x, actor.transform.position.y, y)); } EntityViewModel viewModel = EntityViewModelManager.Instance.GetEntityViewById(targetmsg.npc_id); if (null != viewModel) { viewModel.MoveTo(targetPos.X, 0, targetPos.Y); } } else { float x, y; ProtoHelper.DecodePosition2D(targetmsg.cur_pos, out x, out y); Vector2 curPos = new Vector2(x, y); MovementStateInfo msi = npc.GetMovementStateInfo(); if (Geometry.DistanceSquare(msi.GetPosition2D(), curPos) > c_MaxPosDeltaSqr) { msi.SetPosition2D(curPos); UnityEngine.GameObject actor = EntityController.Instance.GetGameObject(npc.GetId()); GameFramework.Skill.Trigers.TriggerUtil.MoveObjTo(actor, new UnityEngine.Vector3(x, actor.transform.position.y, y)); } else { EntityViewModel viewModel = EntityViewModelManager.Instance.GetEntityViewById(targetmsg.npc_id); if (null != viewModel) { viewModel.MoveTo(curPos.X, 0, curPos.Y); } } } }
public static void AiPursue(EntityInfo npc, ScriptRuntime.Vector3 target) { EntityViewModel npcView = EntityViewModelManager.Instance.GetEntityViewById(npc.GetId()); npcView.MoveTo(target.X, target.Y, target.Z); }