public void SyncSpatial() { if (null != m_Entity && null != Actor) { MovementStateInfo msi = m_Entity.GetMovementStateInfo(); UnityEngine.Vector3 v3 = Actor.transform.position; msi.SetPosition(v3.x, v3.y, v3.z); float dir = Utility.DegreeToRadian(Actor.transform.localEulerAngles.y); msi.SetFaceDir(dir); msi.SetMoveDir(dir); if (msi.IsMoving) { Vector3 tpos = new Vector3(msi.TargetPosition.X, msi.TargetPosition.Y, msi.TargetPosition.Z); if ((tpos - v3).sqrMagnitude < c_StopDistSqr) { msi.IsMoving = false; if (null != Animator) { //Animator.CrossFade(c_StandAnim, c_CrossFadeTime); Animator.Play(c_StandAnim); msi.IsMoving = false; } } } } }
private static void AiPursue(EntityInfo npc, ScriptRuntime.Vector3 target) { MovementStateInfo msi = npc.GetMovementStateInfo(); msi.IsMoving = true; msi.TargetPosition = target; float dir = Geometry.GetYRadian(msi.GetPosition3D(), target); msi.SetFaceDir(dir); msi.SetMoveDir(dir); }
static public int SetMoveDir(IntPtr l) { try { GameFramework.MovementStateInfo self = (GameFramework.MovementStateInfo)checkSelf(l); System.Single a1; checkType(l, 2, out a1); self.SetMoveDir(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
internal static void Execute(object msg, User user) { Msg_CR_UserMoveToPos move_msg = msg as Msg_CR_UserMoveToPos; if (move_msg == null) { return; } EntityInfo charactor = user.Info; if (charactor == null) { LogSys.Log(LOG_TYPE.DEBUG, "charactor {0}({1},{2},{3}) not exist", user.RoleId, user.GetKey(), user.Guid, user.Name); return; } /// if (charactor.GetAIEnable()) { float tx, tz; ProtoHelper.DecodePosition2D(move_msg.target_pos, out tx, out tz); ScriptRuntime.Vector3 pos = new ScriptRuntime.Vector3(tx, 0, tz); MovementStateInfo msi = charactor.GetMovementStateInfo(); msi.IsMoving = true; msi.TargetPosition = pos; float dir = Geometry.GetYRadian(msi.GetPosition3D(), pos); msi.SetFaceDir(dir); msi.SetMoveDir(dir); Msg_RC_NpcMove npcMoveBuilder = DataSyncUtility.BuildNpcMoveMessage(charactor); if (null != npcMoveBuilder) { Scene scene = user.OwnRoom.ActiveScene; if (null != scene) { scene.NotifyAllUser(RoomMessageDefine.Msg_RC_NpcMove, npcMoveBuilder); } } } }