示例#1
0
        public void Update(bool move_enable)
        {
            UserInfo playerself = WorldSystem.Instance.GetPlayerSelf();

            if (playerself == null || playerself.IsDead())
            {
                return;
            }
            KeyHit kh = KeyHit.None;

            if (move_enable)
            {
                if (DashFireSpatial.SpatialObjType.kNPC == playerself.GetRealControlledObject().SpaceObject.GetObjType())
                {
                    NpcInfo npcInfo = playerself.GetRealControlledObject().CastNpcInfo();
                    if (null != npcInfo)
                    {
                        if (!npcInfo.CanMove)
                        {
                            return;
                        }
                    }
                }
                if (GfxSystem.IsKeyPressed(GetKeyCode(KeyIndex.W)))
                {
                    kh |= KeyHit.Up;
                }
                if (GfxSystem.IsKeyPressed(GetKeyCode(KeyIndex.A)))
                {
                    kh |= KeyHit.Left;
                }
                if (GfxSystem.IsKeyPressed(GetKeyCode(KeyIndex.S)))
                {
                    kh |= KeyHit.Down;
                }
                if (GfxSystem.IsKeyPressed(GetKeyCode(KeyIndex.D)))
                {
                    kh |= KeyHit.Right;
                }
            }

            Motion m = kh == KeyHit.None ? Motion.Stop : Motion.Moving;

            MotionChanged = MotionStatus != m || last_key_hit_ != kh;

            if (MotionChanged)
            {
                //LogSystem.Debug("MotionChanged:{0}!={1} || {2}!={3}", MotionStatus, m, last_key_hit_, kh);
            }

            last_key_hit_ = kh;
            MotionStatus  = m;
            MoveDir       = CalcMoveDir(kh);
            if (MoveDir < 0)
            {
                MotionStatus = Motion.Stop;
            }
            if (MotionChanged)
            {
                //GfxSystem.GfxLog(string.Format("InputMoveDir:{0} Pos:{1}", MoveDir, playerself.GetMovementStateInfo().GetPosition3D().ToString()));
            }
        }