コード例 #1
0
 public void OnSerializeNetworkView(UnityEngine.BitStream a, UnityEngine.NetworkMessageInfo b)
 {
     if (fn != null)
     {
         fn.invoke(gameObject, a, b);
     }
 }
コード例 #2
0
		public static bool Serialize (BitStream stream, bool boolean)
		// Serialize a bool to a BitStream
		{
			int integer = boolean ? 1 : 0;

			stream.Serialize (ref integer);

			return integer == 1;
		}
コード例 #3
0
ファイル: IntVector2.cs プロジェクト: pmlamotte/2Pac
 // assumes a reading stream
 public void DeSerialize( BitStream stream )
 {
     int x = 0;
     int y = 0;
     stream.Serialize( ref x );
     stream.Serialize( ref y );
     this.x = x;
     this.y = y;
 }
コード例 #4
0
ファイル: Statistics.cs プロジェクト: Geor23/Planets
        void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
        {
            float ping = 1.0F;

            if (stream.isWriting) {
                stream.Serialize(ref ping);
            } else {
                transitTime = (Network.time - info.timestamp)*1000;
                stream.Serialize(ref ping);
            }
        }
コード例 #5
0
		public static Vector3 Serialize (BitStream stream, Vector3 vector)
		// Serialize a Vector3 to a BitStream
		{
			float x = vector.x, y = vector.y, z = vector.z;

			stream.Serialize (ref x);
			stream.Serialize (ref y);
			stream.Serialize (ref z);

			return new Vector3 (x, y, z);
		}
コード例 #6
0
 public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     if(stream.isReading)
     {
         mRefreshRecSum++;
     }
     else
     {
         mRefreshSentSum++;
     }
     parent.SingleEndpoint_OnSerialize(stream, ConnectedUser);
 }
コード例 #7
0
		public static Quaternion Serialize (BitStream stream, Quaternion quaternion)
		// Serialize a Quaternion to a BitStream
		{
			float x = quaternion.x, y = quaternion.y, z = quaternion.z, w = quaternion.w;

			stream.Serialize (ref x);
			stream.Serialize (ref y);
			stream.Serialize (ref z);
			stream.Serialize (ref w);

			return new Quaternion (x, y, z, w);
		}
コード例 #8
0
        void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
        {
            int count = packets.Count;

            if (stream.isWriting)
            {
                stream.Serialize(ref count);

                while (packets.Count > 0)
                {
                    VoiceChatPacket packet = packets.Dequeue();
                    stream.WritePacket(packet);

                    // If this packet is the same size as the sample size, we can return it
                    if (packet.Data.Length == VoiceChatSettings.Instance.SampleSize)
                    {
                        VoiceChatBytePool.Instance.Return(packet.Data);
                    }
                }
            }
            else
            {
                if (Network.isServer)
                {
                    stream.Serialize(ref count);

                    for (int i = 0; i < count; ++i)
                    {
                        packets.Enqueue(stream.ReadPacket());

                        if (Network.connections.Length < 2)
                        {
                            packets.Dequeue();
                        }
                    }
                }
                else
                {
                    stream.Serialize(ref count);

                    for (int i = 0; i < count; ++i)
                    {
                        var packet = stream.ReadPacket();

                        if (player != null)
                        {
                            player.OnNewSample(packet);
                        }
                    }
                }
            }
        }
コード例 #9
0
    public override void SerializeNetwork(UnityEngine.BitStream stream)
    {
        float _attackingTimer = attackingTimer;

        if (stream.isWriting)
        {
            stream.Serialize(ref _attackingTimer);
        }
        else
        {
            stream.Serialize(ref _attackingTimer);
            attackingTimer = _attackingTimer;
        }
    }
コード例 #10
0
    public override void SerializeNetwork(UnityEngine.BitStream stream)
    {
        float _stunTime = StunTime;

        if (stream.isWriting)
        {
            stream.Serialize(ref _stunTime);
        }
        else
        {
            stream.Serialize(ref _stunTime);
            StunTime = _stunTime;
        }
    }
コード例 #11
0
 protected void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo msg)
 {
     var time = 0;
     //mID = (int) ID;
     if (stream.isWriting)
     {
         stream.Serialize(ref DoubleMissileTime);
         //stream.Serialize(ref mID);
     }
     else
     {
         stream.Serialize(ref time);
         DoubleMissileTime = time;
         //stream.Serialize(ref mID);
         //ID = (PlayerIndex) mID;
     }
 }
コード例 #12
0
ファイル: TestActor.cs プロジェクト: mbhuet/MastersProject
        private void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) {
            // Serialize the position and color
            if (stream.isWriting) {
                Color color = _renderer.material.color;

                stream.Serialize(ref color.r);
                stream.Serialize(ref color.g);
                stream.Serialize(ref color.b);
                stream.Serialize(ref color.a);
            } else {
                Color color = Color.white;

                stream.Serialize(ref color.r);
                stream.Serialize(ref color.g);
                stream.Serialize(ref color.b);
                stream.Serialize(ref color.a);

                _renderer.material.color = color;
            }

            _transformInterpolation.OnSerializeNetworkView(stream, info, _transform.position, _transform.rotation);
        }
コード例 #13
0
        public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info, Vector3 position, Quaternion rotation) {
            // Always send transform (depending on reliability of the network view)
            if (stream.isWriting) {
                // When receiving, buffer the information
                stream.Serialize(ref position);
                stream.Serialize(ref rotation);
            } else {
                // Receive latest state information
                position = Vector3.zero;
                rotation = Quaternion.identity;
                stream.Serialize(ref position);
                stream.Serialize(ref rotation);

                // Shift buffer contents, oldest data erased, 18 becomes 19, ... , 0 becomes 1
                for (int i = _bufferedStates.Length - 1; i >= 1; i--) {
                    _bufferedStates[i] = _bufferedStates[i - 1];
                }

                // Save currect received state as 0 in the buffer, safe to overwrite after shifting
                State state;
                state.Timestamp = info.timestamp;
                state.Position = position;
                state.Rotation = rotation;
                _bufferedStates[0] = state;

                // Increment state count but never exceed buffer size
                _timestampCount = Mathf.Min(_timestampCount + 1, _bufferedStates.Length);

                // Check integrity, lowest numbered state in the buffer is newest and so on
                for (int i = 0; i < _timestampCount - 1; i++) {
                    if (_bufferedStates[i].Timestamp < _bufferedStates[i + 1].Timestamp)
                        Debug.Log("State inconsistent");
                }

                _isReceivedFirstInfo = true;
                // Debug.Log("stamp: " + info.Timestamp + "my time: " + Network.time + "delta: " + (Network.time - info.Timestamp));
            }
        }
コード例 #14
0
 public void FireOnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     if (OnSerializeNetworkView != null)
     {
         OnSerializeNetworkView(UnityObject, stream, info);
     }
 }
コード例 #15
0
ファイル: UnityNetwork.cs プロジェクト: devluz/webrtcnetwork
        public void SingleEndpoint_OnSerialize(BitStream stream, NetworkPlayer senderOrReceiver)
        {
            //doesnt work. server sends messages automatically to all others


            if (stream.isReading)
            {
                char countin = (char)0;
                stream.Serialize(ref countin);
                int count = (int)countin;
                //Debug.Log(count + " packages sent");
                for (int k = 0; k < count; k++)
                {
                    int length = 0;
                    short lengthin = 0;
                    stream.Serialize(ref lengthin);
                    length = ((int)(ushort)lengthin); //just making sure it converts the - values back into high positive values
                    ByteArrayBuffer msg = ByteArrayBuffer.Get(length);



                    for (int i = 0; i < length; i++)
                    {
                        char c = 'v';
                        stream.Serialize(ref c);
                        msg.array[i] = (byte)c;
                        msg.positionWrite++;
                    }
                    NetworkEvent ev = new NetworkEvent(NetEventType.UnreliableMessageReceived, NetworkPlayerToConnectionId(senderOrReceiver), msg);
                    mEvents.Enqueue(ev);
                }
            }
            else
            {
                Queue<ByteArrayBuffer> userOut;
                ConnectionId userid;
                userid = NetworkPlayerToConnectionId(senderOrReceiver);
                
                // NetworkPlayerToInt(senderOrReceiver);

                bool found = mOutgoingUnreliableMessages.TryGetValue(userid, out userOut);

                if (found && userOut.Count > 0)
                {
                    char count = (char)0;
                    if (userOut.Count > 255)
                    {
                        Debug.LogWarning("Too many messages at once");
                        count = (char)255;
                    }else
                    {
                        count = (char)userOut.Count;
                    }

                    stream.Serialize(ref count);

                    for(int i = 0; userOut.Count > 0 && i < 256; i++)
                    {
                        ByteArrayBuffer msg = userOut.Dequeue();

                        short length = (short)msg.positionWrite;

                        stream.Serialize(ref length);
                        for (int k = 0; k < length; k++)
                        {
                            char c = (char)msg.array[k];
                            stream.Serialize(ref c);
                        }
                        msg.Dispose();
                    }
                    //Debug.Log(count + " messages sent to " + userid);

                }

            }
        }
コード例 #16
0
 public void OnSerializeNetworkView(UnityEngine.BitStream a, UnityEngine.NetworkMessageInfo b)
 {
     RunFunctions(a, b);
 }
コード例 #17
0
 void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     InvokeInManagers ("OnSerializeNetworkView", stream, info);
 }
コード例 #18
0
 private void Serializev(ref Vector3 value, float maximumDelta)
 {
     BitStream.INTERNAL_CALL_Serializev(this, ref value, maximumDelta);
 }
コード例 #19
0
ファイル: BitStream.cs プロジェクト: randomize/VimConfig
 private static extern void INTERNAL_CALL_Serializeq(BitStream self, ref Quaternion value, float maximumDelta);
コード例 #20
0
        public void SyncInput(ref BitStream stream)
        {
            if (stream.isWriting)
            {
                //Debug.Log (string.Format("[WRITING] player: {0} sender: {1} time: {2}", owner, mnInfo.sender, mnInfo.timestamp));
                if (m_player.IsMine())
                {
                    float horMoveVal = m_horMov;
                    float verMoveVal = m_verMov;

                    bool lookingRight = m_lookingDirection.x > 0;

                    stream.Serialize(ref horMoveVal);
                    stream.Serialize(ref verMoveVal);
                    stream.Serialize(ref lookingRight);
                }
            }
            else if (stream.isReading)
            {
                //Debug.Log(string.Format("[READING] player: {0}  sender: {1} time: {2}", owner, mnInfo.sender, mnInfo.timestamp));
                float horMoveVal = 0;
                float verMoveVal = 0;
                bool lookingRight = true;

                stream.Serialize(ref horMoveVal);
                stream.Serialize(ref verMoveVal);
                stream.Serialize(ref lookingRight);

                m_horMov = horMoveVal;
                m_verMov = verMoveVal;
                m_lookingRight = lookingRight;
            }
        }
コード例 #21
0
 private void Serializen(ref NetworkViewID viewID)
 {
     BitStream.INTERNAL_CALL_Serializen(this, ref viewID);
 }
コード例 #22
0
 /// <summary>Used to customize synchronization of variables in a script watched by a network view.</summary>
 public override void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     if (onSerializeNetworkView != null) onSerializeNetworkView.OnNext(Tuple.Create(stream, info));
 }
コード例 #23
0
 private static extern void INTERNAL_CALL_Serializeq(BitStream self, ref Quaternion value, float maximumDelta);
コード例 #24
0
 public override void SerializeNetwork(UnityEngine.BitStream stream)
 {
     stateMachine.SerializeNetwork(stream);
 }
コード例 #25
0
ファイル: Kestrel.cs プロジェクト: Arduinology/Khylib
 public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     var vessel = GetComponent<Vessel>();
     if (stream.isWriting)
     {
         var eccentricity = (float)vessel.orbit.eccentricity;
         var semiMajorAxis = (float)vessel.orbit.semiMajorAxis;
         var inclination = (float)vessel.orbit.inclination;
         var lan = (float)vessel.orbit.LAN;
         var argumentOfPeriapsis = (float)vessel.orbit.argumentOfPeriapsis;
         var meanAnomalyAtEpoch = (float)vessel.orbit.meanAnomalyAtEpoch;
         var epoch = (float)vessel.orbit.epoch;
         var bodyId = FlightGlobals.Bodies.IndexOf(vessel.orbit.referenceBody);
         stream.Serialize(ref eccentricity, float.Epsilon);
         stream.Serialize(ref semiMajorAxis, float.Epsilon);
         stream.Serialize(ref inclination, float.Epsilon);
         stream.Serialize(ref lan, float.Epsilon);
         stream.Serialize(ref argumentOfPeriapsis, float.Epsilon);
         stream.Serialize(ref meanAnomalyAtEpoch, float.Epsilon);
         stream.Serialize(ref epoch, float.Epsilon);
         stream.Serialize(ref bodyId);
     }
     else
     {
         float eccentricity = 0f, semiMajorAxis = 0f, inclination = 0f, lan = 0f, argumentOfPeriapsis = 0f;
         var meanAnomalyAtEpoch = 0f;
         var epoch = 0f;
         var bodyId = 0;
         stream.Serialize(ref eccentricity, float.Epsilon);
         stream.Serialize(ref semiMajorAxis, float.Epsilon);
         stream.Serialize(ref inclination, float.Epsilon);
         stream.Serialize(ref lan, float.Epsilon);
         stream.Serialize(ref argumentOfPeriapsis, float.Epsilon);
         stream.Serialize(ref meanAnomalyAtEpoch, float.Epsilon);
         stream.Serialize(ref epoch, float.Epsilon);
         stream.Serialize(ref bodyId);
         var newOrbit = new Orbit(inclination, eccentricity, semiMajorAxis, lan, argumentOfPeriapsis, meanAnomalyAtEpoch, epoch, FlightGlobals.Bodies[bodyId]);
         newOrbit.UpdateFromUT(Planetarium.GetUniversalTime());
         if (vessel.packed)
         {
             if (vessel.Landed)
                 vessel.Landed = false;
             if (vessel.Splashed)
                 vessel.Splashed = false;
             vessel.orbit.UpdateFromOrbitAtUT(newOrbit, Planetarium.GetUniversalTime(), newOrbit.referenceBody);
         }
         else
         {
             vessel.SetPosition(newOrbit.pos);
             vessel.SetWorldVelocity(newOrbit.vel);
         }
     }
 }
コード例 #26
0
		void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
		{
			LogTime("OnSerializeNetworkView");
			CallScriptMethod("OnSerializeNetworkView");
		}
コード例 #27
0
 private static extern void INTERNAL_CALL_Serializen(BitStream self, ref NetworkViewID viewID);
コード例 #28
0
ファイル: DeadState.cs プロジェクト: etiens/VikingQuest
 public override void SerializeNetwork(UnityEngine.BitStream stream)
 {
 }
コード例 #29
0
 /// <summary>Used to customize synchronization of variables in a script watched by a network view.</summary>
 public virtual void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) { }
コード例 #30
0
ファイル: BoardLocation.cs プロジェクト: pmlamotte/2Pac
 // assumes a writing stream
 public void Serialize( BitStream stream )
 {
     location.Serialize( stream );
     offset.Serialize( stream );
 }
コード例 #31
0
 private static extern void INTERNAL_CALL_Serializev(BitStream self, ref Vector3 value, float maximumDelta);
コード例 #32
0
ファイル: Mover.cs プロジェクト: NotYours180/UnityHacks
		public virtual void OnSerializeNetworkView (BitStream stream, NetworkMessageInfo messageInfo)
		{
			targetPosition = Utility.Serialize (stream, targetPosition);
			targetRotation = Utility.Serialize (stream, targetRotation);
			targetVelocity = Utility.Serialize (stream, targetVelocity);
			stream.Serialize (ref drag);

			if (!stream.isWriting)
			{
				if (firstSync)
				// On first sync of remote players, set position and rotation directly
				{
					firstSync = false;
					transform.position = targetPosition;
					transform.rotation = targetRotation;
				}
				else
				{
					PredictPosition ((float)(Network.time - messageInfo.timestamp));
						// If we're reading back movement from another client, apply the predicted movement since message send to the target position
				}
			}
		}
コード例 #33
0
ファイル: BitStream.cs プロジェクト: randomize/VimConfig
 private static extern void INTERNAL_CALL_Serializen(BitStream self, ref NetworkViewID viewID);
コード例 #34
0
ファイル: GMonoBehaviour.cs プロジェクト: xqy/game
 protected virtual void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     MethodParamList paramTypeList = CLRSharpManager.instance.getParamTypeList(typeof(BitStream), typeof(NetworkMessageInfo));
     object[] paramList = new object[] { stream, info };
     doFun(GMBEventMethod.OnSerializeNetworkView, paramTypeList, paramList);
 }
コード例 #35
0
ファイル: BitStream.cs プロジェクト: randomize/VimConfig
 private static extern void INTERNAL_CALL_Serializev(BitStream self, ref Vector3 value, float maximumDelta);
コード例 #36
0
ファイル: IntVector2.cs プロジェクト: pmlamotte/2Pac
 // assumes a writing stream
 public void Serialize( BitStream stream )
 {
     int x = this.x;
     int y = this.y;
     stream.Serialize( ref x );
     stream.Serialize( ref y );
 }
コード例 #37
0
        private void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
        {
            Vector3 position = transform.position;
            Quaternion rotation = transform.rotation;
            Vector3 scale = transform.localScale;
            stream.Serialize (ref position);
            stream.Serialize (ref rotation);
            stream.Serialize (ref scale);
            if (stream.isReading) {
                transform.position = position;
                transform.rotation = rotation;
                _targetRotation = rotation;
                transform.localScale = scale;
            }

            _animationControl.OnSerializeNetworkView (stream, info);
        }
コード例 #38
0
 private void Serializeq(ref Quaternion value, float maximumDelta)
 {
     BitStream.INTERNAL_CALL_Serializeq(this, ref value, maximumDelta);
 }