SetFaceDir() public method

public SetFaceDir ( float rot ) : void
rot float
return void
 static public int SetFaceDir(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             GameFramework.MovementStateInfo self = (GameFramework.MovementStateInfo)checkSelf(l);
             System.Single a1;
             checkType(l, 2, out a1);
             self.SetFaceDir(a1);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 3)
         {
             GameFramework.MovementStateInfo self = (GameFramework.MovementStateInfo)checkSelf(l);
             System.Single a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             self.SetFaceDir(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 2
0
        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;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void SyncFaceDir()
 {
     if (null != m_Entity && null != Actor)
     {
         MovementStateInfo msi = m_Entity.GetMovementStateInfo();
         float             dir = Geometry.DegreeToRadian(Actor.transform.localEulerAngles.y);
         msi.SetFaceDir(dir);
     }
 }
        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);
        }
Exemplo n.º 5
0
 private void UpdateSpatial()
 {
     if (null != m_Entity && null != Actor)
     {
         MovementStateInfo msi = m_Entity.GetMovementStateInfo();
         if (Math.Abs(msi.GetWantedFaceDir() - msi.GetFaceDir()) > Geometry.c_FloatPrecision)
         {
             float      degree  = Geometry.RadianToDegree(msi.GetWantedFaceDir());
             Quaternion targetQ = Quaternion.Euler(0, degree, 0);
             Actor.transform.localRotation = Quaternion.RotateTowards(Actor.transform.localRotation,
                                                                      targetQ, c_TurnRoundSpeed * Time.deltaTime);
             float dir = Geometry.DegreeToRadian(Actor.transform.localEulerAngles.y);
             msi.SetFaceDir(dir, false);
         }
         else
         {
             SyncFaceDir();
         }
     }
     SyncPosition();
 }
        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);
                    }
                }
            }
        }