コード例 #1
0
    private void OnRPCRespondMove(IComponentEvent componentEvent)
    {
        G2C_HeroMove   g2C_HeroMove = componentEvent as G2C_HeroMove;
        HeroMoveParams respond      = g2C_HeroMove.Respond;

        m_GameplayProxy.SetCurrentAreaUid(respond.Areaid);
        Vector3 clientPosition = m_GameplayProxy.ServerAreaOffsetToClientPosition(respond.Position);

        Vector3 LineVelocity    = respond.LineVelocity;
        Vector3 AngularVelocity = respond.AngularVelocity;

        if (respond.HeroMoveUnit.SmoothMove == null && !m_Property.IsMain())
        {
            m_Rigidbody.position = clientPosition;
            m_Rigidbody.rotation = respond.Rotation;
            m_Rigidbody.rotation.Normalize();

            m_Rigidbody.velocity        = respond.LineVelocity;
            m_Rigidbody.angularVelocity = respond.AngularVelocity;
        }

        if (respond.HeroMoveUnit.MmoMove != null)
        {
            Vector3 EngineAxis = respond.HeroMoveUnit.MmoMove.EngineAxis;
            Vector3 RotateAxis = respond.HeroMoveUnit.MmoMove.RotateAxis;
            m_BehaviorController.WorldForceControlMove(EngineAxis, RotateAxis);
            m_EngineAxis   = EngineAxis;
            m_cameraRotate = RotateAxis;
        }
        else if (respond.HeroMoveUnit.Dof4Move != null)
        {
            Vector3 EngineAxis = respond.HeroMoveUnit.Dof4Move.EngineForce;
            Vector3 RotateAxis = respond.HeroMoveUnit.Dof4Move.Orientations;
            m_BehaviorController.DOF4ForwardMove(EngineAxis, RotateAxis);
            m_EngineAxis   = EngineAxis;
            m_cameraRotate = RotateAxis;
        }
        else if (respond.HeroMoveUnit.Dof6Move != null)
        {
            Vector3 EngineAxis = respond.HeroMoveUnit.Dof6Move.EngineForce;
            Vector3 RotateAxis = respond.HeroMoveUnit.Dof6Move.EngineTorque;
            m_BehaviorController.DOF6ForwardMove(EngineAxis, RotateAxis);
            m_EngineAxis   = EngineAxis;
            m_cameraRotate = RotateAxis;
        }
        else if (respond.HeroMoveUnit.SmoothMove != null)
        {
            if (respond.HeroMoveUnit.SmoothMove.Targets.Count > 0)
            {
                List <Vector3> tagets = new List <Vector3>();
                foreach (var point in respond.HeroMoveUnit.SmoothMove.Targets)
                {
                    tagets.Add(point);
                }

                m_BehaviorController.SmoothMoveTargets(tagets, PhysxMotionType.Spacecraft);
            }
        }
        else if (respond.HeroMoveUnit.BindMove != null)
        {
            m_BehaviorController.BindMove(respond.HeroMoveUnit.BindMove);
        }
        else if (respond.HeroMoveUnit.Leap != null)
        {
            /// 当前区域坐标系下 跃迁终点的坐标
            Vector3 currentAreaLeapEndPointOffsetPosition = respond.HeroMoveUnit.Leap.Target;
            if (m_Property.IsMain())
            {
                m_GameplayProxy.SetLeapEndAreaOffsetPosition(currentAreaLeapEndPointOffsetPosition);
                m_GameplayProxy.SetLeapTargetAreaUid((ulong)respond.HeroMoveUnit.Leap.ToAreaId);
                m_GameplayProxy.SetLeapStartAreaOffsetPosition(respond.Position);
                Map.MapManager.GetInstance().GetCurrentMapController().SetLimitChangeToAreaUid((ulong)respond.HeroMoveUnit.Leap.ToAreaId);

                Vector3 worldPosition;
                m_GameplayProxy.ServerAreaOffsetPositionToWorldPosition(out worldPosition, currentAreaLeapEndPointOffsetPosition);
                m_GameplayProxy.SetLeapTargetAreaOffset(m_GameplayProxy.WorldPositionToServerAreaOffsetPosition(worldPosition, (ulong)respond.HeroMoveUnit.Leap.ToAreaId));
            }

            m_BehaviorController.Leap(new List <Vector3>()
            {
                currentAreaLeapEndPointOffsetPosition
            });
            //Log("=========================");
            //m_GameplayProxy.LogTotalPositionOffset();
            //Log($"OnShipJumpResponse currentAreaOffsetPosition={currentAreaLeapEndPointOffsetPosition}");
            //Log($"OnShipJumpResponse LeapEndAreaOffsetPosition={m_GameplayProxy.GetLeapEndAreaOffsetPosition()}");
            //Log($"OnShipJumpResponse LeapTargetAreaOffse={m_GameplayProxy.GetLeapTargetAreaOffset()}");
            //Log($"OnShipJumpResponse area_id={respond.HeroMoveUnit.Leap.ToAreaId}");
        }
        else if (respond.HeroMoveUnit.LeapCancel != null)
        {
            m_BehaviorController.LeapBreak();
        }
        else
        {
            Vector3    position = respond.Position;
            Quaternion rotation = respond.Rotation;
            Log("ForecMove", $"Uid={m_Property.GetUId()} Position={position} rotation={rotation}");
        }
    }