Пример #1
0
    //public void SetArrowBehaviour(ArrowBehaviour arrowBehaviour)
    //{
    //    this.m_ArrowBehaviour = arrowBehaviour;
    //}

    public void EntityMove(SMsgActionMove_SCS sMsgActionMove)
    {
        monsterMoveNodes.Add(new Vector3(sMsgActionMove.floatX / 10.0f, 0.1f, sMsgActionMove.floatY / -10.0f));

        if (m_FSMSystem.CurrentStateID == StateID.MonsterBeHitFly ||
            m_FSMSystem.CurrentStateID == StateID.MonsterStand ||
            m_FSMSystem.CurrentStateID == StateID.MonsterBeAttacked ||
            m_FSMSystem.CurrentStateID == StateID.MonsterAttack)

        {
            TraceUtil.Log(SystemModel.Common, TraceLevel.Error, "wrong node");
            return;
        }

        if (this.RoleDataModel.SMsg_Header.uidEntity == sMsgActionMove.uidEntity && MonsterBehaviour.UsePathSmooth)
        {
            m_currentNode = sMsgActionMove;
            Vector2 lastPos    = new Vector2(m_lastNode.floatX, m_lastNode.floatY);
            Vector2 currentPos = new Vector2(ThisTransform.position.x * 10.0f, ThisTransform.position.z * (-10.0f));
            if (m_currentNode.fSpeed > 0.1f)           //Vector2.Distance( currentPos , lastPos) > 0.1f && lastPos != Vector2.zero)
            {
                if (m_FSMSystem.CurrentStateID == StateID.MonsterIdle)
                {
                    m_smooth.Init(ThisTransform.position,
                                  ThisTransform.TransformDirection(Vector3.forward) * WalkSpeed,
                                  new Vector3(sMsgActionMove.floatX / 10.0f, 0, -sMsgActionMove.floatY / 10.0f),
                                  new Vector3(sMsgActionMove.fDirectX, 0, -sMsgActionMove.fDirectY) * sMsgActionMove.fSpeed / 10.0f,
                                  ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    nodes.Clear();
                    for (int i = 0; i <= 10; i++)
                    {
                        Vector3 nodepos = m_smooth.GetCurrentPos(0.1f * i);
                        nodes.Add(new Vector3(nodepos.x, 1, nodepos.z));
                    }


                    m_FSMSystem.PerformTransition(Transition.MonsterToMove);
                    MonsterMoveState state = (MonsterMoveState)m_FSMSystem.CurrentState;
                    state.ResetSmooth(ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                }
                else if (m_FSMSystem.CurrentStateID == StateID.MonsterMove)
                {
                    MonsterMoveState state = (MonsterMoveState)m_FSMSystem.CurrentState;
                    state.ResetSmooth(ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    m_smooth.Init(ThisTransform.position,
                                  ThisTransform.TransformDirection(Vector3.forward) * WalkSpeed,
                                  new Vector3(sMsgActionMove.floatX / 10.0f, 0, -sMsgActionMove.floatY / 10.0f),
                                  new Vector3(sMsgActionMove.fDirectX, 0, -sMsgActionMove.fDirectY) * sMsgActionMove.fSpeed / 10.0f,
                                  ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    nodes.Clear();
                    for (int i = 0; i <= 10; i++)
                    {
                        Vector3 nodepos = m_smooth.GetCurrentPos(0.1f * i);
                        nodes.Add(new Vector3(nodepos.x, 1, nodepos.z));
                    }
                }

                m_clientEndPos = null;
                ClientMove     = true;
            }
            else
            {
                m_clientEndPos = new Vector3(CurrentNode.floatX / 10.0f, 0, CurrentNode.floatY / -10.0f);
                ClientMove     = false;
            }
            m_lastNode = m_currentNode;
        }

        WalkToPosition = ThisTransform.position;
        WalkToPosition = WalkToPosition.Value.GetFromServer(sMsgActionMove.floatX, 0.1f, sMsgActionMove.floatY, -0.1f);
    }
Пример #2
0
    /// <summary>
    /// ÊÕµœœÇÉ«Òƶ¯Ð­Òé°ü
    /// </summary>
    /// <param name="notifyArgs"></param>
    public void EntityMove(SMsgActionMove_SCS sMsgActionMove_SC)
    {
        if (this.RoleDataModel.SMsg_Header.uidEntity == sMsgActionMove_SC.uidEntity)
        {
            //正常情况下这个实体移动消息不会发给主角,如果是主角说明服务器需要进行位置同步
            if (this.IsHero)
            {
                transform.position = new Vector3(0, 0.1f, 0);
                transform.position = transform.position.GetFromServer(sMsgActionMove_SC.floatX, sMsgActionMove_SC.floatY);

                return;
            }
            if (this.FSMSystem.CurrentStateID != StateID.PlayerIdle &&
                this.FSMSystem.CurrentStateID != StateID.PlayerRun)
            {
                return;
            }

            if (this.IsDie)
            {
                return;
            }

            if (sMsgActionMove_SC.fSpeed > 0.1f)
            {
                if (m_FSMSystem.CurrentStateID == StateID.PlayerIdle)
                {
                    m_smooth.Init(ThisTransform.position,
                                  ThisTransform.TransformDirection(Vector3.forward) * sMsgActionMove_SC.fSpeed / 10.0f,
                                  new Vector3(sMsgActionMove_SC.floatX / 10.0f, 0, -sMsgActionMove_SC.floatY / 10.0f),
                                  new Vector3(sMsgActionMove_SC.fDirectX, 0, -sMsgActionMove_SC.fDirectY) * sMsgActionMove_SC.fSpeed / 10.0f,
                                  ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    for (int i = 0; i <= 10; i++)
                    {
                        Vector3 nodepos = m_smooth.GetCurrentPos(0.1f * i);
                        nodes.Add(new Vector3(nodepos.x, 1, nodepos.z));
                    }

                    m_FSMSystem.PerformTransition(Transition.PlayerToTarget);
                    PlayerRunState state = (PlayerRunState)m_FSMSystem.CurrentState;
                    state.MoveMode = GetMoveModeBySpeed(sMsgActionMove_SC.fSpeed / 10.0f);
                    state.ResetSmooth(ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                }
                else if (m_FSMSystem.CurrentStateID == StateID.PlayerRun)
                {
                    PlayerRunState state = (PlayerRunState)m_FSMSystem.CurrentState;
                    state.MoveMode = GetMoveModeBySpeed(sMsgActionMove_SC.fSpeed / 10.0f);
                    state.ResetSmooth(ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    m_smooth.Init(ThisTransform.position,
                                  ThisTransform.TransformDirection(Vector3.forward) * sMsgActionMove_SC.fSpeed / 10.0f,
                                  new Vector3(sMsgActionMove_SC.floatX / 10.0f, 0, -sMsgActionMove_SC.floatY / 10.0f),
                                  new Vector3(sMsgActionMove_SC.fDirectX, 0, -sMsgActionMove_SC.fDirectY) * sMsgActionMove_SC.fSpeed / 10.0f,
                                  ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    for (int i = 0; i <= 10; i++)
                    {
                        Vector3 nodepos = m_smooth.GetCurrentPos(0.1f * i);
                        nodes.Add(new Vector3(nodepos.x, 1, nodepos.z));
                    }
                }
                m_clientEndPos = null;
                ClientMove     = true;
            }
            else
            {
                m_clientEndPos = new Vector3(sMsgActionMove_SC.floatX / 10.0f, 0, sMsgActionMove_SC.floatY / -10.0f);
                ClientMove     = false;
            }
        }
    }