当前位置: 首页>>代码示例>>C#>>正文


C# BitStream类代码示例

本文整理汇总了C#中BitStream的典型用法代码示例。如果您正苦于以下问题:C# BitStream类的具体用法?C# BitStream怎么用?C# BitStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BitStream类属于命名空间,在下文中一共展示了BitStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        BoardLocation newLocation= new BoardLocation(new IntVector2(0,0), new IntVector2(0,0));
        int maxSpeed = 0;
        IntVector2 direction = new IntVector2(0,0);
        BoardLocation lastBoardLocation = new BoardLocation(new IntVector2( 0, 0), new IntVector2(0,0));

        if (stream.isWriting)
        {
            newLocation = this.boardLocation;
            maxSpeed = this.maxSpeed;
            direction = this.direction;
            lastBoardLocation = this.lastBoardLocation;

            newLocation.Serialize( stream );
            stream.Serialize( ref maxSpeed );
            direction.Serialize( stream );
            lastBoardLocation.Serialize( stream );
        }
        else
        {
            newLocation.DeSerialize( stream );
            stream.Serialize( ref maxSpeed );
            direction.DeSerialize( stream );
            lastBoardLocation.DeSerialize( stream );

            this.boardLocation = newLocation;
            this.maxSpeed = maxSpeed;
            this.direction = direction;
            this.lastBoardLocation = lastBoardLocation;
        }
    }
开发者ID:pmlamotte,项目名称:2Pac,代码行数:32,代码来源:BoardObject.cs

示例2: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        if(stream.isWriting) {
            //Position Synchronization
            Vector3 position = transform.position; stream.Serialize(ref position);

            //Rotation Synchronization
            Quaternion rotation = transform.rotation; stream.Serialize(ref rotation);

            //Current Movement
            Vector3 directionVector = motor.inputMoveDirection;
            stream.Serialize(ref directionVector);
        }
        else {
            //Position Synchronization
            Vector3 position = Vector3.zero; stream.Serialize(ref position);
            transform.position = position;

            //Rotation synchronization
            Quaternion rotation = Quaternion.identity; stream.Serialize(ref rotation);
            transform.rotation = rotation;

            //Current Movement
            Vector3 directionVector = Vector3.zero;
            stream.Serialize(ref directionVector);
            motor.inputMoveDirection = directionVector;
        }
    }
开发者ID:rameshvarun,项目名称:FTMoba,代码行数:28,代码来源:CreepScript.cs

示例3: OnSerializeNetworkView2D

    public void OnSerializeNetworkView2D(BitStream stream, NetworkMessageInfo info,
        UnitActionCommand pUnitActionCommand, bool pIsAlive)
    {
        Transform lTransform = characterController.transform;
        Vector3 lData = Vector3.zero;
        //---------------------------------------------------
        if (stream.isWriting)
        {
            lData = lTransform.position;
            lData.z = yVelocity;
        }
        //---------------------------------------------------
        stream.Serialize(ref lData);
        //---------------------------------------------------
        if (stream.isReading)
        {
            yVelocity = lData.z;
            lData.z = 0f;
            lTransform.position = lData;

            var lDeltaTime = (float)(Network.time - info.timestamp);
            if (lDeltaTime > 0.02f)
                update2D(pUnitActionCommand, UnitFace.getValue(pUnitActionCommand.face),
                    pIsAlive, lDeltaTime * Time.timeScale);
            lastUpdateTime = Time.time;

        }
    }
开发者ID:Seraphli,项目名称:TheInsectersWar,代码行数:28,代码来源:Character2D.cs

示例4: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 syncDest = Vector3.zero;
        Vector3 syncPos = Vector3.zero;
        if (stream.isWriting && Network.isServer)
        {
            syncDest = destination;
            syncPos = this.gameObject.transform.position;
            stream.Serialize(ref syncDest);
            stream.Serialize(ref syncPos);
        }
        else if (stream.isReading)
        {
            stream.Serialize(ref syncDest);
            stream.Serialize(ref syncPos);

            destination = syncDest;
            if (agent != null)
                agent.SetDestination (destination);

            /*
            Vector3 diffPos = this.gameObject.transform.position - syncPos;
            if (diffPos.sqrMagnitude >= 1){
                this.gameObject.transform.position = syncPos;
            }
            */
        }
    }
开发者ID:vmohan7,项目名称:Assassins,代码行数:28,代码来源:AIPath.cs

示例5: OnSerializeNetworkView

    void OnSerializeNetworkView( BitStream stream, NetworkMessageInfo info )
    {
        Vector3 syncPosition = Vector3.zero; // для синхронизации позиции
        Vector3 syncVelocity = Vector3.zero; // для синхронизации действующей силы
        Quaternion syncRotation = Quaternion.identity; // для синхронизации поворота

        if ( stream.isWriting ) { // если отправляем в сеть то считываем данные обьекта и отправляем
            syncPosition = rigidbody.position;
            stream.Serialize( ref syncPosition );

            syncPosition = rigidbody.velocity;
            stream.Serialize( ref syncVelocity );

            syncRotation = rigidbody.rotation;
            stream.Serialize( ref syncRotation );
        } else { // иначе считываем из сети
            stream.Serialize( ref syncPosition );
            stream.Serialize( ref syncVelocity );
            stream.Serialize( ref syncRotation );

            syncTime = 0f; // сбрасываем время синхронизации
            syncDelay = Time.time - lastSynchronizationTime; // получаем дельту придыдущей синхронизации
            lastSynchronizationTime = Time.time; // записываем новое время последней синхронизации

            syncEndPosition = syncPosition + syncVelocity * syncDelay; // конечная точка в которую двигаеться обьект
            syncStartPosition = rigidbody.position; // начальная точка равна текущей позиции

            syncEndRotation = syncRotation; // конечный поворот
            syncStartRotation = rigidbody.rotation; // начальный поворот
        }
    }
开发者ID:NextGenIntelligence,项目名称:HabrahabrUnityMultiplayer,代码行数:31,代码来源:PlayerControls.cs

示例6: OnSerializeNetworkView

 protected virtual void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     if (selected == _PlayerOwn || stream.isReading)
     {
         if (stream.isWriting)
         {
             syncPos = pos;
             syncRot = rot;
             //syncVel = controller.velocity;
         }
         stream.Serialize(ref syncPos);
         stream.Serialize(ref syncRot);
         //stream.Serialize(ref syncVel);
         if (stream.isReading)
         {
             if (syncPos == Vector3.zero)
             { }
             else
             {
                 pos = syncPos;
                 rot = syncRot;
             }
             //vel = syncVel;
         }
     }
 }
开发者ID:ConnectDeveloper01,项目名称:dorumon,代码行数:26,代码来源:Zombie.cs

示例7: OnSerializeNetworkView

    // Update is called once per frame
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        {
            Vector3 position = rigidbody.position;
            Vector3 forward = transform.forward;
            Vector3 velocity = rigidbody.velocity;
            Vector3 angularVelocity = rigidbody.angularVelocity;

            if(stream.isWriting)
            {
                stream.Serialize(ref position);
                stream.Serialize(ref forward);
                stream.Serialize(ref velocity);
                stream.Serialize(ref angularVelocity);
            }
            else
            {
                stream.Serialize(ref position);
                targetPosition = position;

                stream.Serialize(ref forward);
                targetForward = forward;

                stream.Serialize(ref velocity);
                speed = velocity;

                stream.Serialize(ref angularVelocity);
                angularSpeed = angularVelocity;
            }
        }
    }
开发者ID:etiens,项目名称:VikingQuest,代码行数:32,代码来源:ResyncPosition.cs

示例8: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Quaternion 	_syncDirection 	= Quaternion.identity;
        Vector3 	_syncPosition	= Vector3.zero;
        Vector3 	_syncVelocity 	= Vector3.zero;

        if (stream.isWriting)
        {

            _syncDirection = this.transform.rotation;
            _syncPosition = this.transform.position;
            _syncVelocity = this.rigidbody.velocity;

            stream.Serialize(ref _syncDirection);
            stream.Serialize(ref _syncPosition);
            stream.Serialize(ref _syncVelocity);
        }
        else
        {
            stream.Serialize(ref _syncDirection);
            stream.Serialize(ref _syncPosition);
            stream.Serialize(ref _syncVelocity);
            if(Quaternion.Angle(this.transform.rotation,_syncDirection) > 10   ){
                this.gameObject.transform.rotation = Quaternion.Lerp(this.transform.rotation, _syncDirection,5 );
            }
            if( Vector3.Distance(this.transform.position,_syncPosition) > 10 ){
                this.gameObject.transform.position = Vector3.Lerp(this.transform.position, _syncPosition,5);
            }
            if(Vector3.Distance(this.rigidbody.velocity,_syncVelocity)> 10){
                this.rigidbody.velocity = Vector3.Lerp(this.rigidbody.velocity, _syncVelocity , 5);
            }

        }
    }
开发者ID:hellsmith,项目名称:AnUn,代码行数:34,代码来源:PositionSyncScript.cs

示例9: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        var sync_pos = new Vector3();
        var sync_rot = new Quaternion();
        var sync_hp = 0.0f;

        if (stream.isReading)
        {
            stream.Serialize(ref sync_pos);
            stream.Serialize(ref sync_rot);
            stream.Serialize(ref sync_hp);

            transform.position = sync_pos;
            transform.rotation = sync_rot;
            m_CurrentHP = sync_hp;
        }
        else
        {
            sync_pos = transform.position;
            sync_rot = transform.rotation;
            sync_hp = m_CurrentHP;

            stream.Serialize(ref sync_pos);
            stream.Serialize(ref sync_rot);
            stream.Serialize(ref sync_hp);
        }
    }
开发者ID:EternalWind,项目名称:Fighters,代码行数:27,代码来源:PlayerController.cs

示例10: OnSerialNetworkView

    public void OnSerialNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        float punch = punchSpeed;
        float direction = directionMultiplyerX;
        float health = HP;
        if (stream.isWriting)
        {

            punch = punchSpeed;
            stream.Serialize(ref punch);

            direction = directionMultiplyerX;
            stream.Serialize(ref direction);

            health = HP;
            stream.Serialize(ref health);
        }
        else
        {
            stream.Serialize(ref punch);
            punchSpeed = punch;

            stream.Serialize(ref direction);
            directionMultiplyerX = direction;

            stream.Serialize(ref health);
            HP = health;

        }
    }
开发者ID:kyle1235,项目名称:Project_Flat,代码行数:30,代码来源:PlayerCombat.cs

示例11: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        float net_currentAmmo = 0;
        float net_maxAmmo = 0;
        float net_ammoRegenRate = 0;

        if (stream.isWriting)
        {
            net_currentAmmo = currentAmmo;
            net_maxAmmo = maxAmmo;
            net_ammoRegenRate = ammoRegenRate;

            stream.Serialize(ref net_currentAmmo);
            stream.Serialize(ref net_maxAmmo);
            stream.Serialize(ref net_ammoRegenRate);
        }
        else if (stream.isReading)
        {
            stream.Serialize(ref net_currentAmmo);
            stream.Serialize(ref net_maxAmmo);
            stream.Serialize(ref net_ammoRegenRate);

            currentAmmo = net_currentAmmo;
            maxAmmo = net_maxAmmo;
            ammoRegenRate = net_ammoRegenRate;
        }
    }
开发者ID:datnewb,项目名称:Kartus,代码行数:27,代码来源:CharacterAmmo.cs

示例12: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 pos = observedRigidbody.position;
        Quaternion rot = observedRigidbody.rotation;
        float vel = observedRigidbody.velocity.magnitude;

        if(stream.isWriting)
        {
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
            stream.Serialize(ref vel);
        }
        else
        {
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
            stream.Serialize(ref vel);
            receiver.serverPosition = pos;
            receiver.serverRotation = rot;
            receiver.serverVelocity = vel;

            receiver.lerpToTarget();

            for(int i = serverStateBuffer.Length - 1; i >= 1; i--)
            {
                serverStateBuffer[i] = serverStateBuffer[i-1];
            }

            serverStateBuffer[0] = new NetState(info.timestamp, pos, rot);
        }
    }
开发者ID:rdemaeye,项目名称:mergePractice,代码行数:31,代码来源:Predictor.cs

示例13: OnSerializeNetworkView

    private void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 syncPosition = Vector3.zero;
        Vector3 syncVelocity = Vector3.zero;
        if (stream.isWriting)
        {
            syncPosition = transform.position;
            stream.Serialize(ref syncPosition);

            syncVelocity = _controller.velocity;
            stream.Serialize(ref syncVelocity);
        }
        else
        {
            stream.Serialize(ref syncPosition);
            stream.Serialize(ref syncVelocity);

            _syncTime = 0f;
            _syncDelay = Time.time - _lastSynchroTime;
            _lastSynchroTime = Time.time;

            _syncEndPosition = syncPosition + syncVelocity * _syncDelay;
            _syncStartPosition = transform.position;
        }
    }
开发者ID:BluBambu,项目名称:SkyArena,代码行数:25,代码来源:PlayerMovement.cs

示例14: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 syncPosition = Vector3.zero;
        Quaternion syncRotation = Quaternion.identity;
        Vector3 syncVelocity = Vector3.zero;
        if (stream.isWriting)
        {
            syncPosition = transform.position;
            stream.Serialize(ref syncPosition);

            syncRotation = transform.rotation;
            stream.Serialize(ref syncRotation);

            syncVelocity = controller.velocity;
            stream.Serialize(ref syncVelocity);
        }
        else
        {
            stream.Serialize(ref syncPosition);
            stream.Serialize(ref syncRotation);
            stream.Serialize(ref syncVelocity);

            syncTime = 0f;
            syncDelay = Time.time - lastSynchronizationTime;
            lastSynchronizationTime = Time.time;

            syncEndPosition = syncPosition + syncVelocity * syncDelay;
            syncStartPosition = transform.position;

            syncEndRotation = syncRotation;
            syncStartRotation = transform.rotation;
        }
    }
开发者ID:ZachHoefler,项目名称:pokeMMOn,代码行数:33,代码来源:Player.cs

示例15: OnSerializeNetworkView

    public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 pos = observedTransform.position;
        Quaternion rot = observedTransform.rotation;

        if (stream.isWriting) {
            //Debug.Log("Server is writing");
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
        }
        else {
            //This code takes care of the local client!
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
            receiver.serverPosition = pos;
            receiver.serverRotation = rot;
            //Smoothly correct clients position
            //receiver.lerpToTarget();

            //Take care of data for interpolating remote objects movements
            // Shift up the buffer
            for ( int i = serverStateBuffer.Length - 1; i >= 1; i-- ) {
                serverStateBuffer[i] = serverStateBuffer[i-1];
            }
            //Override the first element with the latest server info
            serverStateBuffer[0] = new NetworkState((float)info.timestamp, pos, rot);
        }
    }
开发者ID:Final-Parsec,项目名称:TheVenomEvent,代码行数:28,代码来源:Predictor.cs


注:本文中的BitStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。