GetFaceDir() 공개 메소드

public GetFaceDir ( ) : float
리턴 float
 static public int GetFaceDir(IntPtr l)
 {
     try {
         GameFramework.MovementStateInfo self = (GameFramework.MovementStateInfo)checkSelf(l);
         var ret = self.GetFaceDir();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        public static Msg_RC_NpcSkill BuildNpcSkillMessage(EntityInfo obj, int skillId)
        {
            MovementStateInfo msi = obj.GetMovementStateInfo();

            ScriptRuntime.Vector3 pos = msi.GetPosition3D();

            Msg_RC_NpcSkill msg = new Msg_RC_NpcSkill();

            msg.npc_id         = obj.GetId();
            msg.skill_id       = skillId;
            msg.stand_pos      = ToPosition(pos.X, pos.Z);
            msg.face_direction = msi.GetFaceDir();
            msg.target_id      = obj.GetAiStateInfo().Target;

            return(msg);
        }
예제 #3
0
        public bool CalcPosAndDir(int targetId, out ScriptRuntime.Vector3 pos, out float dir)
        {
            EntityViewModel view = GetEntityViewById(targetId);

            if (null != view)
            {
                MovementStateInfo msi = view.Entity.GetMovementStateInfo();
                pos = msi.GetPosition3D();
                dir = msi.GetFaceDir();
                return(true);
            }
            else
            {
                pos = ScriptRuntime.Vector3.Zero;
                dir = 0;
                return(false);
            }
        }
예제 #4
0
 public void Create(EntityInfo entity)
 {
     if (null != entity)
     {
         m_Entity = entity;
         MovementStateInfo     msi = m_Entity.GetMovementStateInfo();
         ScriptRuntime.Vector3 pos = msi.GetPosition3D();
         float dir = msi.GetFaceDir();
         CreateActor(m_Entity.GetId(), m_Entity.GetModel(), pos.X, pos.Y, pos.Z, dir, m_Entity.Scale, m_Entity.GetRadius(), entity.ActualProperty.GetFloat(CharacterPropertyEnum.x2011_最终速度));
         if (null != Actor)
         {
             m_Agent = Actor.GetComponent <NavMeshAgent>();
             if (m_Agent == null)
             {
                 m_Agent = Actor.AddComponent <NavMeshAgent>();
                 m_Agent.angularSpeed          = c_AngularSpeed;
                 m_Agent.acceleration          = c_Acceleration;
                 m_Agent.radius                = entity.GetRadius();
                 m_Agent.speed                 = entity.ActualProperty.GetFloat(CharacterPropertyEnum.x2011_最终速度);
                 m_Agent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance;
             }
             m_Animator = Actor.GetComponentInChildren <Animator>();
             EntityDrawGizmos gizmos = Actor.GetComponent <EntityDrawGizmos>();
             if (null == gizmos)
             {
                 gizmos         = Actor.AddComponent <EntityDrawGizmos>();
                 gizmos.npcInfo = m_Entity;
             }
             else
             {
                 gizmos.npcInfo = m_Entity;
             }
             SetMoveAgentEnable(true);
             try{
                 if (null != m_Agent)
                 {
                     m_Agent.ResetPath();
                 }
             } catch {
                 m_Agent.enabled = true;
             }
         }
     }
 }
예제 #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();
 }
예제 #6
0
        public void Tick()
        {
            try {
                if (this.CurrentState != RoomState.Active && this.CurrentState != RoomState.Finish)
                {
                    return;
                }

                long curTime = TimeUtility.GetLocalMilliseconds();
                if (m_LastLogTime + 60000 < curTime)
                {
                    m_LastLogTime = curTime;

                    LogSys.Log(LOG_TYPE.INFO, "Room.Tick {0}", RoomId);
                }

                if (this.CurrentState == RoomState.Active)
                {
                    Scene scene = ActiveScene;
                    if (null != scene)
                    {
                        scene.Tick();
                        OnTick();
                    }
                    m_DisconnectedUsers.Clear();
                    m_RequestDeleteUsers.Clear();
                    foreach (User user in m_RoomUserMgr.RoomUsers)
                    {
                        if (user != null)
                        {
                            user.Tick();
                            if (user.IsTimeout())
                            {
                                if (user.UserControlState == (int)UserControlState.User)
                                {
                                    m_DisconnectedUsers.Add(user);
                                }
                                else if (user.UserControlState == (int)UserControlState.Remove)
                                {
                                    m_RequestDeleteUsers.Add(user);
                                }
                                else if (user.UserControlState == (int)UserControlState.UserDropped)
                                {
                                    if (user.LastNotifyUserDropTime + c_NotifyUserDropInterval < curTime)
                                    {
                                        Msg_RL_UserDrop uaqBuilder = new Msg_RL_UserDrop();
                                        uaqBuilder.RoomId      = m_RoomId;
                                        uaqBuilder.UserGuid    = user.Guid;
                                        uaqBuilder.IsBattleEnd = false;
                                        m_Connector.SendMsgToLobby(uaqBuilder);

                                        user.LastNotifyUserDropTime = curTime;
                                    }
                                    //临时处理,踢掉断线的玩家
                                    user.UserControlState = (int)UserControlState.Remove;
                                }
                            }
                        }
                    }
                    foreach (User user in m_DisconnectedUsers)
                    {
                        m_RoomUserMgr.DropUser(user);
                    }
                    foreach (User user in m_RequestDeleteUsers)
                    {
                        m_RoomUserMgr.RemoveUser(user);
                    }
                    //todo:观察者掉线处理
                    for (int i = 0; i < m_RoomUserMgr.RoomObservers.Length; ++i)
                    {
                        Observer observer = m_RoomUserMgr.RoomObservers[i];
                        if (!observer.IsIdle)
                        {
                            observer.Tick();
                        }
                    }
                    if (!IsFieldRoom)
                    {
                        int userCount = GetActiveRoomUserCount();
                        if (userCount <= 0 && CanFinish)
                        {
                            if (GetMinimizeElapsedDroppedTime() > c_FinishTimeForNoUsers)
                            {
                                //若房间内玩家数目为0,结束战斗,关闭房间
                                Finish((int)CampIdEnum.Unkown);
                            }
                        }
                    }
                    //每个Tick结束,将空间属性同步给Peer,用于Peer转发消息
                    foreach (User user in m_RoomUserMgr.RoomUsers)
                    {
                        if (null != user && null != user.Info && null != user.Info.GetMovementStateInfo())
                        {
                            GameFramework.RoomPeer peer = user.GetPeer();
                            if (null != peer)
                            {
                                MovementStateInfo info = user.Info.GetMovementStateInfo();
                                peer.Position = info.GetPosition3D();
                                peer.FaceDir  = info.GetFaceDir();
                            }
                        }
                    }
                }
                else if (m_FinishTime + c_DeactiveWaitTime < curTime)
                {
                    Deactive();
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }