コード例 #1
0
        public static void ExecObjFaceCommand(int objId, float dir)
        {
            CharacterInfo obj = WorldSystem.Instance.GetCharacterById(objId);

            if (null != obj)
            {
                MovementStateInfo msi = obj.GetMovementStateInfo();
                if (dir < 0)
                {
                    msi.SetFaceDir(msi.GetWantFaceDir());
                }
                else
                {
                    msi.SetFaceDir(dir);
                    msi.SetWantFaceDir(dir);
                }
            }
        }
コード例 #2
0
ファイル: NpcView.cs プロジェクト: myl2232/ArkCrossEngine
        protected void SimulateMove()
        {
            if (!m_Npc.IsSimulateMove)
            {
                return;
            }
            if (m_Npc.SummonOwnerId < 0)
            {
                return;
            }
            CharacterInfo owner = WorldSystem.Instance.GetCharacterById(m_Npc.SummonOwnerId);

            if (owner == null)
            {
                return;
            }
            CharacterView owner_view = EntityManager.Instance.GetCharacterViewById(m_Npc.SummonOwnerId);

            if (owner_view == null)
            {
                return;
            }
            MovementStateInfo msi     = m_Npc.GetMovementStateInfo();
            MovementStateInfo sim_msi = owner.GetMovementStateInfo();

            m_Npc.GetActualProperty().SetMoveSpeed(Operate_Type.OT_Absolute, owner.GetActualProperty().MoveSpeed);
            m_Npc.VelocityCoefficient = owner.VelocityCoefficient;
            if (owner_view.ObjectInfo.IsGfxMoveControl)
            {
                msi.IsMoving = false;
            }
            else
            {
                msi.IsMoving = sim_msi.IsMoving;
            }
            msi.SetFaceDir(sim_msi.GetFaceDir());
            msi.SetWantFaceDir(sim_msi.GetWantFaceDir());
            msi.SetMoveDir(sim_msi.GetMoveDir());
        }
コード例 #3
0
ファイル: NpcView.cs プロジェクト: myl2232/ArkCrossEngine
        private void UpdateSpatial()
        {
            if (null != m_Npc)
            {
                MovementStateInfo msi = m_Npc.GetMovementStateInfo();
                if (ObjectInfo.IsGfxMoveControl)
                {
                    if (ObjectInfo.DataChangedByGfx)
                    {
                        msi.PositionX = ObjectInfo.X;
                        msi.PositionY = ObjectInfo.Y;
                        msi.PositionZ = ObjectInfo.Z;
                        msi.SetFaceDir(ObjectInfo.FaceDir);
                        ObjectInfo.DataChangedByGfx = false;
                    }
                    if (ObjectInfo.WantDirChangedByGfx)
                    {
                        msi.SetWantFaceDir(ObjectInfo.WantFaceDir);
                        ObjectInfo.WantDirChangedByGfx = false;
                    }
                }
                else
                {
                    if (ObjectInfo.DataChangedByGfx)
                    {
                        msi.PositionX = ObjectInfo.X;
                        msi.PositionY = ObjectInfo.Y;
                        msi.PositionZ = ObjectInfo.Z;
                        //msi.SetFaceDir(ObjectInfo.FaceDir);

                        ObjectInfo.DataChangedByGfx = false;
                    }
                    SimulateMove();
                    UpdateMovement();
                }
                ObjectInfo.WantFaceDir = msi.GetWantFaceDir();
            }
        }
コード例 #4
0
        internal void Tick()
        {
            long now = TimeUtility.GetServerMilliseconds();

            m_LastTickIntervalMs = now - m_LastTickTime;

            m_LastTickTime = now;

            if (WorldSystem.Instance.IsObserver && !WorldSystem.Instance.IsFollowObserver)
            {
                bool  keyPressed = false;
                float x = 0.5f, y = 0.5f;
                if (GfxSystem.IsKeyPressed(Keyboard.Code.A))
                {
                    x          = 0.1f;
                    keyPressed = true;
                }
                else if (GfxSystem.IsKeyPressed(Keyboard.Code.D))
                {
                    x          = 0.9f;
                    keyPressed = true;
                }
                if (GfxSystem.IsKeyPressed(Keyboard.Code.W))
                {
                    y          = 0.1f;
                    keyPressed = true;
                }
                else if (GfxSystem.IsKeyPressed(Keyboard.Code.S))
                {
                    y          = 0.9f;
                    keyPressed = true;
                }
                if (keyPressed)
                {
                    WorldSystem.Instance.UpdateObserverCamera(x, y);
                }
                return;
            }


            UserInfo playerself = WorldSystem.Instance.GetPlayerSelf();

            if (null == playerself)
            {
                return;
            }
            // if move input is disable
            // MotionStatus is MoveStop, and MotionChanged is reflect the change accordingly

            if (EnableMoveInput)
            {
                if (!IsKeyboardControl())
                {
                    CheckJoystickControl();
                }
            }

            if (!m_IsJoystickControl)
            {
                pm_.Update(EnableMoveInput);
            }
            MovementStateInfo msi = playerself.GetMovementStateInfo();
            Vector3           pos = msi.GetPosition3D();

            //LogSystem.Debug("Pos : {0}, Dir : {1}", pos.ToString(), playerself.GetMovementStateInfo().GetFaceDir());
            bool reface = false;

            if (m_LastTickIsSkillMoving && !msi.IsSkillMoving)
            {
                reface = true;
            }

            //操作同步机制改为发给服务器同时本地就开始执行(服务器转发给其它客户端,校验失败则同时发回原客户端进行位置调整)
            Vector3 mouse_pos = new Vector3(GfxSystem.GetMouseX(), GfxSystem.GetMouseY(), GfxSystem.GetMouseZ());

            if (pm_.MotionStatus == PlayerMovement.Motion.Moving || pm_.JoyStickMotionStatus == PlayerMovement.Motion.Moving)
            {
                if (pm_.MotionChanged || pm_.JoyStickMotionChanged || !m_LastTickIsMoving)
                {
                    StopAiMove();

                    playerself.SkillController.AddBreakSkillTask();
                    float moveDir = RoundMoveDir(pm_.MoveDir);

                    //GfxSystem.GfxLog("PlayerControl.Tick MoveDir:{0} RoundMoveDir:{1}", pm_.MoveDir, moveDir);

                    if (!m_LastTickIsMoving || !Geometry.IsSameFloat(moveDir, m_lastMoveDir))
                    {
                        msi.SetMoveDir(moveDir);
                        //ControlSystemOperation.AdjustCharacterMoveDir(playerself.GetId(), moveDir);
                        msi.IsMoving       = true;
                        msi.TargetPosition = Vector3.Zero;

                        if (WorldSystem.Instance.IsPvpScene() || WorldSystem.Instance.IsMultiPveScene())
                        {
                            NetworkSystem.Instance.SyncPlayerMoveStart(moveDir);
                        }
                    }
                    if (EnableRotateInput)
                    {
                        if (reface || !m_LastTickIsMoving || !Geometry.IsSameFloat(pm_.MoveDir, m_lastDir))
                        {
                            msi.SetFaceDir(pm_.MoveDir);
                            //ControlSystemOperation.AdjustCharacterFaceDir(playerself.GetId(), pm_.MoveDir);
                            msi.SetWantFaceDir(pm_.MoveDir);

                            if (WorldSystem.Instance.IsPvpScene() || WorldSystem.Instance.IsMultiPveScene())
                            {
                                NetworkSystem.Instance.SyncFaceDirection(pm_.MoveDir);
                            }
                        }
                    }
                    m_lastDir     = pm_.MoveDir;
                    m_lastMoveDir = moveDir;
                }
                m_LastTickIsMoving = true;
            }
            else
            {
                if (m_LastTickIsMoving)
                {
                    playerself.SkillController.CancelBreakSkillTask();
                    playerself.GetMovementStateInfo().IsMoving = false;
                    if (WorldSystem.Instance.IsPvpScene() || WorldSystem.Instance.IsMultiPveScene())
                    {
                        NetworkSystem.Instance.SyncPlayerMoveStop();
                    }
                    if (EnableRotateInput)
                    {
                        if (reface)
                        {
                            msi.SetFaceDir(m_lastDir);
                            //ControlSystemOperation.AdjustCharacterFaceDir(playerself.GetId(), m_lastDir);
                            msi.SetWantFaceDir(m_lastDir);

                            if (WorldSystem.Instance.IsPvpScene() || WorldSystem.Instance.IsMultiPveScene())
                            {
                                NetworkSystem.Instance.SyncFaceDirection(m_lastDir);
                            }
                        }
                    }
                }
                m_LastTickIsMoving = false;
            }
            m_LastTickIsSkillMoving = msi.IsSkillMoving;

            old_mouse_pos_ = mouse_pos_;
            mouse_pos_.X   = GfxSystem.GetMouseX();
            mouse_pos_.Y   = GfxSystem.GetMouseY();

            UserAiStateInfo aiInfo = playerself.GetAiStateInfo();

            if (null != aiInfo && (int)AiStateId.Idle == aiInfo.CurState)
            {
                m_lastSelectObjId = -1;
            }
        }