예제 #1
0
    public bool MoveTo(float x, float y, float z)
    {
        this.SetTargetPos(x, y, z);
        Nr3DCharBase nr3DCharBase = this.m_pkChar.Get3DChar();

        if (nr3DCharBase == null)
        {
            return(false);
        }
        if (!nr3DCharBase.IsCreated() || !nr3DCharBase.Is3DCharActive())
        {
            return(false);
        }
        NrCharDefine.eMoveTargetReason eMoveTargetReason = this.IsMovableArea(x, z);
        if (eMoveTargetReason != NrCharDefine.eMoveTargetReason.MTR_SUCCESS)
        {
            Vector3 lhs = Vector3.zero;
            lhs = this.FindMovableDestination(this.m_vTargetPos, eMoveTargetReason);
            if (lhs == Vector3.zero)
            {
                this.SetTargetPos(0f, 0f, 0f);
                return(false);
            }
            this.SetTargetPos(lhs.x, lhs.y, lhs.z);
        }
        if (this.m_vCharPos.x == this.m_vTargetPos.x && this.m_vCharPos.z == this.m_vTargetPos.z)
        {
            return(true);
        }
        this.MoveStart();
        return(true);
    }
예제 #2
0
    public Vector3 FindMovableDestination(Vector3 vDest, NrCharDefine.eMoveTargetReason movereason)
    {
        Vector3 zero = Vector3.zero;

        if (movereason == NrCharDefine.eMoveTargetReason.MTR_WIDECOLL)
        {
            Vector2 vector = this.FindMovableNearWideColl(vDest, true, 0f, 0f);
            if (vector.x == 0f && vector.y == 0f)
            {
                return(zero);
            }
            zero.x = vector.x;
            zero.z = vector.y;
        }
        zero.y = NrCharMove.CalcHeight(zero);
        return(zero);
    }
예제 #3
0
 public bool MoveToFast(float x, float y, float z, float next_x, float next_y, float next_z)
 {
     this.SetTargetPos(x, y, z);
     NrCharDefine.eMoveTargetReason eMoveTargetReason = this.IsMovableArea(x, z);
     if (eMoveTargetReason != NrCharDefine.eMoveTargetReason.MTR_SUCCESS)
     {
         Vector3 lhs = Vector3.zero;
         lhs = this.FindMovableDestination(this.m_vTargetPos, eMoveTargetReason);
         if (lhs == Vector3.zero)
         {
             this.SetTargetPos(0f, 0f, 0f);
             return(false);
         }
         this.SetTargetPos(lhs.x, lhs.y, lhs.z);
     }
     if (this.m_vCharPos.x == this.m_vTargetPos.x && this.m_vCharPos.z == this.m_vTargetPos.z)
     {
         return(true);
     }
     this.m_vFastMoveNextTargetPos.x = next_x;
     this.m_vFastMoveNextTargetPos.y = next_y;
     this.m_vFastMoveNextTargetPos.z = next_z;
     NrCharDefine.eMoveTargetReason eMoveTargetReason2 = this.IsMovableArea(next_x, next_z);
     if (eMoveTargetReason2 != NrCharDefine.eMoveTargetReason.MTR_SUCCESS)
     {
         Vector3 lhs2 = Vector3.zero;
         lhs2 = this.FindMovableDestination(this.m_vFastMoveNextTargetPos, eMoveTargetReason2);
         if (lhs2 == Vector3.zero)
         {
             this.m_vFastMoveNextTargetPos.x = 0f;
             this.m_vFastMoveNextTargetPos.y = 0f;
             this.m_vFastMoveNextTargetPos.z = 0f;
             return(false);
         }
         this.m_vFastMoveNextTargetPos.x = lhs2.x;
         this.m_vFastMoveNextTargetPos.y = lhs2.y;
         this.m_vFastMoveNextTargetPos.z = lhs2.z;
     }
     this.m_pkChar.SetIncreaseSpeed(50f);
     this.m_bFastMove = true;
     this.MoveStart();
     return(true);
 }
예제 #4
0
 public bool StraightMoveTo(float x, float y, float z)
 {
     this.SetTargetPos(x, y, z);
     NrCharDefine.eMoveTargetReason eMoveTargetReason = this.IsMovableArea(x, z);
     if (eMoveTargetReason != NrCharDefine.eMoveTargetReason.MTR_SUCCESS)
     {
         Vector3 lhs = Vector3.zero;
         lhs = this.FindMovableDestination(this.m_vTargetPos, eMoveTargetReason);
         if (lhs == Vector3.zero)
         {
             this.SetTargetPos(0f, 0f, 0f);
             return(false);
         }
         this.SetTargetPos(lhs.x, lhs.y, lhs.z);
     }
     if (this.m_vCharPos.x == this.m_vTargetPos.x && this.m_vCharPos.z == this.m_vTargetPos.z)
     {
         return(true);
     }
     this.MoveStart();
     return(true);
 }
예제 #5
0
    public void MobileTabDragMoveToDirection(ref Vector3 vToDir)
    {
        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   a         = transform.TransformDirection(Vector3.forward);

        a.y = 0f;
        a   = a.normalized;
        Vector3 a2 = new Vector3(a.z, 0f, -a.x);

        vToDir = vToDir.normalized;
        float   y       = vToDir.y;
        float   x       = vToDir.x;
        Vector3 vector  = x * a2 + y * a;
        Vector3 vector2 = Vector3.zero;

        if (vector != Vector3.zero)
        {
            float num = 0.3f;
            vector2 = Vector3.RotateTowards(vector2, vector, num * 0.0174532924f * Time.deltaTime, 1f);
            NrCharDefine.eMoveTargetReason eMoveTargetReason = this.IsMovableArea(this.m_vCharPos.x + vector2.x, this.m_vCharPos.z + vector2.z);
            if (eMoveTargetReason != 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 = false;
        this.m_bMouseMove    = true;
    }