Esempio n. 1
0
    public void KeyboardMove()
    {
        if (!NrTSingleton <NkClientLogic> .Instance.IsMovable())
        {
            return;
        }
        if (!this.m_pkChar.IsMovingAnimation())
        {
            return;
        }
        NrCharUser nrCharUser = this.m_pkChar as NrCharUser;

        if (nrCharUser == null || !nrCharUser.IsReady3DModel())
        {
            return;
        }
        Nr3DCharActor nr3DCharActor = nrCharUser.Get3DChar() as Nr3DCharActor;

        if (nr3DCharActor == null)
        {
            return;
        }
        Transform transform = Camera.main.transform;
        Vector3   a         = transform.TransformDirection(Vector3.forward);

        a.y = 0f;
        a   = a.normalized;
        Vector3 a2       = new Vector3(a.z, 0f, -a.x);
        float   axisRaw  = NkInputManager.GetAxisRaw("Vertical");
        float   axisRaw2 = NkInputManager.GetAxisRaw("Horizontal");
        Vector3 vector   = axisRaw2 * a2 + axisRaw * a;
        Vector3 vector2  = Vector3.zero;

        if (vector != Vector3.zero)
        {
            float num = 0.3f;
            vector2 = Vector3.RotateTowards(vector2, vector, num * 0.0174532924f * Time.deltaTime, 1f);
            if (this.IsMovableArea(this.m_vCharPos.x + vector2.x, this.m_vCharPos.z + vector2.z) != NrCharDefine.eMoveTargetReason.MTR_SUCCESS && !this.FindMovableAreaByKey(ref vector2))
            {
                return;
            }
            vector2 = vector2.normalized;
        }
        if (vector2 == Vector3.zero)
        {
            return;
        }
        this.ProcessIncreaseMove();
        nr3DCharActor.KeyboardMove(vector2, true);
        this.SetCharPos(nr3DCharActor.GetRootGameObject());
        this.SendCharMovePacketForKeyBoardMove(false);
        this.m_bArrived      = false;
        this.m_bKeyboardMove = true;
        this.m_bMouseMove    = false;
    }
Esempio n. 2
0
    public void MobileTabDragMove()
    {
        if (this.m_bKeyboardMove)
        {
            return;
        }
        if (!NrTSingleton <NkClientLogic> .Instance.IsMovable())
        {
            return;
        }
        if (!this.m_pkChar.IsMovingAnimation())
        {
            return;
        }
        NrCharUser nrCharUser = this.m_pkChar as NrCharUser;

        if (nrCharUser == null || !nrCharUser.IsReady3DModel())
        {
            return;
        }
        Nr3DCharActor nr3DCharActor = nrCharUser.Get3DChar() as Nr3DCharActor;

        if (nr3DCharActor == null)
        {
            return;
        }
        GameObject rootGameObject = nr3DCharActor.GetRootGameObject();

        if (rootGameObject == null)
        {
            return;
        }
        Transform transform = Camera.main.transform;
        Vector3   vector    = transform.TransformDirection(Vector3.forward);

        vector.y = 0f;
        vector   = vector.normalized;
        Vector3 vector2 = vector;
        Vector3 vector3 = Vector3.zero;

        if (vector2 != Vector3.zero)
        {
            float num = 0.3f;
            vector3 = Vector3.RotateTowards(vector3, vector2, num * 0.0174532924f * Time.deltaTime, 1f);
            if (this.IsMovableArea(this.m_vCharPos.x + vector3.x, this.m_vCharPos.z + vector3.z) != NrCharDefine.eMoveTargetReason.MTR_SUCCESS && !this.FindMovableAreaByKey(ref vector3))
            {
                return;
            }
            vector3 = vector3.normalized;
        }
        if (vector3 == Vector3.zero)
        {
            return;
        }
        this.ProcessIncreaseMove();
        nr3DCharActor.KeyboardMove(vector3, true);
        this.SetCharPos(nr3DCharActor.GetRootGameObject());
        this.SendCharMovePacketForKeyBoardMove(false);
        this.m_bArrived      = false;
        this.m_bKeyboardMove = false;
        this.m_bMouseMove    = true;
    }