Ejemplo n.º 1
0
    protected virtual IEnumerator SyncMove()
    {
        _pos = transform.position;
        rot  = transform.rotation;

        while (hasOwnerAuth)
        {
            if (null != _viewTrans)
            {
                _pos = transform.position = _viewTrans.position;
                rot  = transform.rotation = _viewTrans.rotation;
            }

            if (Mathf.Abs(_syncAttr.Pos.x - _pos.x) > PlayerSynAttribute.SyncMovePrecision ||
                Mathf.Abs(_syncAttr.Pos.y - _pos.y) > PlayerSynAttribute.SyncMovePrecision ||
                Mathf.Abs(_syncAttr.Pos.z - _pos.z) > PlayerSynAttribute.SyncMovePrecision)
            {
                _syncAttr.Pos = _pos;
                URPCServer(EPacketType.PT_AI_Move, _pos);

                if (null != _move && null != _entity)
                {
                    if (_entity.Race == ERace.Mankind && _entity.proto == EEntityProto.Monster)
                    {
                        _move.AddNetTransInfo(_pos, rot.eulerAngles, _move.speed, GameTime.Timer.Second);
                    }
                    else
                    {
                        _move.NetMoveTo(_pos, Vector3.zero);
                    }
                }
            }

            if (null != _entity && !(_entity.proto == EEntityProto.Monster && _entity.Race == ERace.Mankind))
            {
                if (Mathf.Abs(_syncAttr.EulerY - rot.eulerAngles.y) > PlayerSynAttribute.SyncMovePrecision)
                {
                    _syncAttr.EulerY = rot.eulerAngles.y;
                    int rotEuler = VCUtils.CompressEulerAngle(rot.eulerAngles);
                    URPCServer(EPacketType.PT_AI_RotY, rotEuler);
                }
            }

            yield return(new WaitForSeconds(1 / uLink.Network.sendRate));
        }
    }