/* This function is automatically called every time it sends or receives datas.
    (To use for data that constantly changed) */
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Quaternion syncRotation = Quaternion.identity;

        // The player is writing to the stream (= he moves its own Character...)
        if (stream.isWriting)
        {
            syncRotation = transform.localRotation;
            stream.Serialize(ref syncRotation);
        }
        // The ClientInstance of the player's opponent need to be moved
        else
        {
            stream.Serialize(ref syncRotation);

            // Interpolation : smoothing the transition from the old to the new data values
            syncTime = 0f;
            syncDelay = Time.time - lastSynchronizationTime;
            lastSynchronizationTime = Time.time;

            // Prediction : the rotation is "updated" before the new data is received
            syncStartRotation = transform.localRotation;
            syncEndRotation = syncRotation;
        }
    }
	void OnSerializeNetworkView (BitStream stream, NetworkMessageInfo info)
	{
		if (stream.isWriting) {
			//This is executed on the owner of the networkview
			//The owner sends it's color over the network
			
			//send color
			Vector3 tempcolor = new Vector3(gameObject.GetComponent<Renderer>().material.color.r,gameObject.GetComponent<Renderer>().material.color.g,gameObject.GetComponent<Renderer>().material.color.b);
			
			stream.Serialize (ref tempcolor);//"Encode" it, and send it
			
		} else {
			//Executed on all non-owners
			//receive a color and set the object to it
			
			//get color
			Vector3 tempcolor = Vector3.zero;
			Color colorReceive = Color.black;
			stream.Serialize (ref tempcolor);
			
			colorReceive = new Color(tempcolor.x, tempcolor.y, tempcolor.z, 1.0f);

			//We've just recieved the current servers position of this object in 'posReceive'.
			
			renderer.material.color = colorReceive;
			//To reduce laggy movement a bit you could comment the line above and use position lerping below instead:	
			//transform.position = Vector3.Lerp(transform.position, posReceive, 0.9f); //"lerp" to the posReceive by 90%
			//It would be even better to save the last received server position and lerp to it in Update because it is executed more often than OnSerializeNetworkView
			
		}
	}
Ejemplo n.º 3
0
 public void OnNetworkInstantiate(UnityEngine.NetworkMessageInfo a)
 {
     if (fn != null)
     {
         fn.invoke(gameObject, a);
     }
 }
 void OnNetworkInstantiate(NetworkMessageInfo msg)
 {
     if (networkView.isMine)
     {
         this.enabled = false;
     }
 }
Ejemplo n.º 5
0
 void OnNetworkInstantiate(NetworkMessageInfo info)
 {
     if(networkView.isMine)
     {
         StartCoroutine(DestroyAfter(duration));
     }
 }
Ejemplo n.º 6
0
    static void NetworkMessageInfo_networkView(JSVCall vc)
    {
        UnityEngine.NetworkMessageInfo _this = (UnityEngine.NetworkMessageInfo)vc.csObj;
        var result = _this.networkView;

        JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
    }
Ejemplo n.º 7
0
 public void OnNetworkInstantiate(NetworkMessageInfo info)
 {
     transform.eulerAngles = new Vector3(90f, transform.eulerAngles.y, transform.eulerAngles.z);
     enabled = false;
     gameObject.renderer.enabled = false;
     Init();
 }
Ejemplo n.º 8
0
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 syncPosition = Vector3.zero;
        Vector3 syncVelocity = Vector3.zero;
        if (stream.isWriting)
        {
            syncPosition = rigidbody.position;
            stream.Serialize(ref syncPosition);

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

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

            syncEndPosition = syncPosition + syncVelocity * syncDelay;
            syncStartPosition = rigidbody.position;
        }
    }
Ejemplo n.º 9
0
// fields

// properties
    static void NetworkMessageInfo_timestamp(JSVCall vc)
    {
        UnityEngine.NetworkMessageInfo _this = (UnityEngine.NetworkMessageInfo)vc.csObj;
        var result = _this.timestamp;

        JSApi.setDouble((int)JSApi.SetType.Rval, (System.Double)(result));
    }
Ejemplo n.º 10
0
    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;

        }
    }
 public void OnSerializeNetworkView(UnityEngine.BitStream a, UnityEngine.NetworkMessageInfo b)
 {
     if (fn != null)
     {
         fn.invoke(gameObject, a, b);
     }
 }
Ejemplo n.º 12
0
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 syncPosition = Vector3.zero;
        Vector3 syncVelocity = Vector3.zero;
        if (stream.isWriting)
        {
            syncPosition = GetComponent<Rigidbody>().position;
            stream.Serialize(ref syncPosition);

            syncPosition = GetComponent<Rigidbody>().velocity;
            stream.Serialize(ref syncVelocity);

            //finPos = GetComponent<Rigidbody>().transform;
            //Debug.Log("FinPos: " + finPos);
        }
        else
        {
            stream.Serialize(ref syncPosition);
            stream.Serialize(ref syncVelocity);

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

            syncEndPosition = syncPosition + syncVelocity * syncDelay;
            syncStartPosition = GetComponent<Rigidbody>().position;
        }
    }
Ejemplo n.º 13
0
 void ReceiveMessage(string message, NetworkMessageInfo netInfo)
 {
     //Debug.Log(message);
     string tag = message.Split(':')[0];
     string msg = message.Split(':')[1];
     switch (tag)
     {
         case "Began":
             gesture.Begin(float.Parse(msg.Split(',')[0]), float.Parse(msg.Split(',')[1]));
             break;
         case "Moved":
             gesture.Move(float.Parse(msg.Split(',')[0]), float.Parse(msg.Split(',')[1]));
             break;
         case "Ended":
             gesture.End(float.Parse(msg.Split(',')[0]), float.Parse(msg.Split(',')[1]));
             break;
         case "Choose Candidate":
             lexicon.Accept(int.Parse(msg));
             break;
         case "Keyboard Size Msg":
             lexicon.UpdateSizeMsg(msg);
             break;
         case "Delete":
             //lexicon.Delete();
             break;
         default:
             break;
     }
 }
Ejemplo n.º 14
0
    public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 pos = observedTransform.position;
        Quaternion rot = observedTransform.rotation;

        if(stream.isWriting) {
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
        }
        else{
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
            reciever.serverPos = pos;
            reciever.serverRot = rot;

            reciever.lerpToTarget();

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

            serverStateBuffer[0] = new NetState();
            serverStateBuffer[0].setState((float)info.timestamp, pos, rot);
        }
    }
    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; // начальный поворот
        }
    }
Ejemplo n.º 16
0
 public virtual void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     if (_animator != null) {
         foreach (AnimatorControllerParameter param in _animator.parameters) {
             AnimatorControllerParameterType paramType = param.type;
             switch (paramType) {
             case AnimatorControllerParameterType.Bool:
                 bool boolParam = _animator.GetBool (param.nameHash);
                 stream.Serialize (ref boolParam);
                 if (stream.isReading) {
                     _animator.SetBool (param.nameHash, boolParam);
                 }
                 break;
             case AnimatorControllerParameterType.Float:
                 float floatParam = _animator.GetFloat (param.nameHash);
                 stream.Serialize (ref floatParam);
                 if (stream.isReading) {
                     _animator.SetFloat (param.nameHash, floatParam);
                 }
                 break;
             case AnimatorControllerParameterType.Int:
                 int intParam = _animator.GetInteger (param.nameHash);
                 stream.Serialize (ref intParam);
                 if (stream.isReading) {
                     _animator.SetInteger (param.nameHash, intParam);
                 }
                 break;
             }
         }
     }
 }
Ejemplo n.º 17
0
    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;
            }
            */
        }
    }
Ejemplo n.º 18
0
 public void RecvHealth(byte[] pckData, NetworkMessageInfo info)
 {
     //ServerCheck
     S2C.SetStructureHealth pck = new S2C.SetStructureHealth();
     pck.DeserializeFromBytes(pckData);
     TileManager.Inst.Get(pck.m_ID).RecvHealth(pck);
 }
Ejemplo n.º 19
0
    // 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;
            }
        }
    }
Ejemplo n.º 20
0
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 syncPosition = Vector3.zero;
        Quaternion rot = Quaternion.identity;

        if (stream.isWriting)
        {

            syncPosition = transform.position;
            rot = transform.rotation;

            stream.Serialize(ref syncPosition);

            stream.Serialize(ref rot);
        }
        else
        {
            stream.Serialize(ref syncPosition);
            stream.Serialize(ref rot);

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

            syncStartPosition = transform.position;
            syncEndPosition = syncPosition;

            qSrot = transform.rotation;
            qErot = rot;
        }
    }
Ejemplo n.º 21
0
    void OnNetworkInstantiate(NetworkMessageInfo info)
    {
        Debug.Log("New object instantiated by " + info.sender);
        string sender = info.sender.ToString();
        if (!Network.isServer) {
            if (!sender.Equals ("-1")) {
                Debug.Log("healer instant cams = " + Camera.allCameras.Length);
                for (int i = 0; i < Camera.allCameras.Length; i++) {
                    Debug.Log ("Camera[" + i + "] = " + Camera.allCameras[i]);
                }
                //Camera.allCameras[Camera.allCameras.Length - 1].enabled = false;
                Camera.allCameras[1].enabled = false;
                GameObject[] launchers = GameObject.FindGameObjectsWithTag("Launcher");
                Debug.Log ("Number of launchers = " + launchers.Length);
                launchers[launchers.Length - 1].SetActive(false);
            } else {
                Camera.allCameras[1].enabled = false;
            }
        }

        /*Debug.Log("cams = " + Camera.allCameras.Length);
        string sender = info.sender.ToString();
        GameObject[] launchers = GameObject.FindGameObjectsWithTag("Launcher");
        Debug.Log ("Number of launchers = " + launchers.Length);
        if (!Network.isServer) {
            if (sender.Equals ("-1")) {
                Camera.allCameras[1].enabled = false;
                Camera.allCameras[0].enabled = true;
            } else {
                Camera.allCameras[Camera.allCameras.Length-1].enabled = false;
                launchers[launchers.Length - 1].SetActive(false);
            }
        }*/
    }
Ejemplo n.º 22
0
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        //locateMarkersAndLimbs();
        Vector3 tempPos = Vector3.zero;
        Quaternion tempRot = Quaternion.identity;

        //ADD THE parentP2 changes here as well! To stop jitter!!

        if((Network.isServer)&&(stream.isWriting))
        {
            if(!parentP1)
            {
                tempPos = transform.position;
                tempRot = transform.rotation;

                stream.Serialize(ref tempPos);
                stream.Serialize(ref tempRot);
            }

        }
        if(Network.isClient)
        {
            if(!parentP1)
            {
                stream.Serialize(ref tempPos);
                stream.Serialize(ref tempRot);

                transform.position = tempPos;
                transform.rotation = tempRot;
            }

        }
    }
Ejemplo n.º 23
0
 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;
         }
     }
 }
Ejemplo n.º 24
0
    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;
        }
    }
Ejemplo n.º 25
0
    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);
        }
    }
Ejemplo n.º 26
0
    void OnNetworkInstantiate(NetworkMessageInfo info)
    {
        if (networkView.isMine)
        {
            // Disable interpolated transform, we control the movement on this client
            GetComponent<NetworkInterpolatedTransform>().enabled = false;
        }
        else
        {
            name += "Remote";

            if (_owner == Network.player)
            {
                // note; we should enable some prediction components here
                GetComponent<NetworkInterpolatedTransform>().enabled = true;
                rigidbody.useGravity = false;
                collider.enabled = false;
            }
            else
            {
                GetComponent<NetworkInterpolatedTransform>().enabled = true;
                rigidbody.useGravity = false;
                collider.enabled = false;
            }
        }

        // we will decide when the object is destroyed
        autoDestroy = false;
    }
    /*
    [RPC]
    public void reeling(float angle)
    {

    }
    */
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        if (stream.isWriting) {

        } else {

        //            if (boat)
        //                transform.position = new Vector3(transform.position.x, boat.transform.position.y + boatOffsetY, transform.position.z);

           /* Quaternion receivedRot = new Quaternion(0, 0, 0, 0);
            stream.Serialize(ref receivedRot);
            Quaternion rotationToUse = receivedRot;
            transform.rotation = rotationToUse;*/

            Vector3 receivedRot = Vector3.zero;
            stream.Serialize (ref receivedRot);
            acceRotationVector = receivedRot;

            Quaternion rotation = Quaternion.LookRotation (receivedRot);
            float angle = Quaternion.Angle (transform.rotation, rotation);

            rotZ = rotation.eulerAngles.z;
            rotX = rotation.eulerAngles.x;
            rotY = rotation.eulerAngles.y;

            if (angle > rotationBreak) {
                transform.rotation = Quaternion.Lerp (transform.rotation, rotation, Time.deltaTime * rotationSpeed);
                // Works -> transform.rotation = Quaternion.Lerp(transform.rotation, rotation, Time.deltaTime * rotationSpeed);

        }
        }
    }
Ejemplo n.º 28
0
    private void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        if (stream.isWriting)
        {
            Debug.Log("Writing.");

            Vector3 pos = this.transform.position;
            Vector3 orientation = this.transform.eulerAngles;

            stream.Serialize(ref pos);
            stream.Serialize(ref orientation);
        }
        else
        {
            Debug.Log("Receiving.");

            Vector3 pos = Vector3.zero;
            Vector3 orientation = Vector3.zero;

            stream.Serialize(ref pos);
            stream.Serialize(ref orientation);

            this.transform.position = pos;
            this.transform.eulerAngles = orientation;
        }
    }
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        if (!stream.isWriting)
        {

        }
    }
    void GiveMeACart(string cartModel, string ballModel, string characterModel, NetworkMessageInfo info)
    {
        // create new buggy for the new guy - his must be done on the server otherwise collisions wont work!
        Vector3 spawnLocation = new Vector3(0,5,0);
        Vector3 velocity = new Vector3(0,0,0);

        // instantiate the prefabs
        GameObject cartContainerObject = (Instantiate(Resources.Load(cartModel), spawnLocation, Quaternion.identity) as GameObject);
        GameObject ballGameObject = Instantiate(Resources.Load(ballModel), spawnLocation + new Vector3(3,0,0), Quaternion.identity) as GameObject;
        GameObject characterGameObject = Instantiate(Resources.Load(characterModel), spawnLocation + new Vector3(0,-1,0), Quaternion.identity) as GameObject;
        GameObject cartGameObject = cartContainerObject.transform.FindChild ("buggy").gameObject;
        // set buggy as characters parent
        characterGameObject.transform.parent = cartGameObject.transform;

        // create and set viewIDs
        NetworkViewID cartViewIDTransform = Network.AllocateViewID();
        NetworkView cgt = cartContainerObject.AddComponent("NetworkView") as NetworkView;
        cgt.observed = cartContainerObject.transform;
        cgt.viewID = cartViewIDTransform;
        cgt.stateSynchronization = NetworkStateSynchronization.Unreliable;
        NetworkViewID cartViewIDRigidbody = Network.AllocateViewID();
        NetworkView cgr = cartGameObject.AddComponent("NetworkView") as NetworkView;
        cgr.observed = cartGameObject.rigidbody;
        cgr.viewID = cartViewIDRigidbody;
        cgr.stateSynchronization = NetworkStateSynchronization.Unreliable;
        NetworkViewID ballViewID = Network.AllocateViewID();
        ballGameObject.networkView.viewID = ballViewID;
        NetworkViewID characterViewID = Network.AllocateViewID();
        characterGameObject.networkView.viewID = characterViewID;

        // tell everyone else about it
        networkView.RPC("SpawnPrefab", RPCMode.Others, cartViewIDTransform, spawnLocation, velocity, cartModel);
        networkView.RPC("SpawnPrefab", RPCMode.Others, ballViewID, spawnLocation, velocity, ballModel);
        networkView.RPC("SpawnPrefab", RPCMode.Others, characterViewID, spawnLocation, velocity, characterModel);

        // tell all players this is a player and not some random objects
        networkView.RPC("SpawnPlayer", RPCMode.Others, cartViewIDTransform, cartViewIDRigidbody, ballViewID, characterViewID, 0, info.sender);

        // tell the player it's theirs
        networkView.RPC("ThisOnesYours", info.sender, cartViewIDTransform, ballViewID, characterViewID);

        // create a PlayerInfo for it
        PlayerInfo newGuy = new PlayerInfo();
        newGuy.cartModel = cartModel;
        newGuy.cartContainerObject = cartContainerObject;
        newGuy.cartGameObject = cartGameObject;
        newGuy.cartViewIDTransform = cartViewIDTransform;
        newGuy.cartViewIDRigidbody = cartViewIDRigidbody;
        newGuy.ballModel = ballModel;
        newGuy.ballGameObject = ballGameObject;
        newGuy.ballViewID = ballViewID;
        newGuy.characterModel = characterModel;
        newGuy.characterGameObject = characterGameObject;
        newGuy.characterViewID = characterViewID;
        newGuy.currentMode = 0;	// set them in buggy
        newGuy.player = info.sender;

        // add it to the lists
        nvs.players.Add(newGuy);
    }
    public override bool controlSelectedObjects(bool select, NetworkViewID viewID, NetworkMessageInfo info)
    {
        if (isObjectAccessGranted(info.sender))
        {
            if (base.controlSelectedObjects(select,viewID,info))
            {
                /* ------------------ VRUE Tasks START   -------------------
                 *	- set the current NetworkPlayer to the player calling the RPC-method or
                 *	the default NetworkPlayer depending on "select"
                ----------------------------------------------------------------- */

                //return true;//replace me

                if (select)
                {
                    currentAccessPlayer = info.sender;
                }
                else
                {
                    currentAccessPlayer = defaultAccessPlayer;
                }
                return true;

                // ------------------ VRUE Tasks END ----------------------------

            }
        }
        return false;
    }
Ejemplo n.º 32
0
 void ReceiveReply(NetworkMessageInfo info)
 {
     if(!connectedStatus.ContainsKey(info.sender))
         connectedStatus.Add(info.sender, true);
     else
         connectedStatus[info.sender] = true;
 }
    //Sends or Recieves Serialized variables over the network.
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        //Variable to be used over the network.
        Vector3 syncPosition = Vector3.zero;

        //If you're the owner of the object you are sending the objects position over the network.
        if(stream.isWriting)
        {
            //Set syncPosition to this objects current position.
            syncPosition = transform.position;
            //Send the position over the network.
            stream.Serialize(ref syncPosition);
        }
        //You're recieving the position from the Owner.
        else
        {
            //Serialize the new incoming position.
            stream.Serialize(ref syncPosition);

            syncTime = 0.0f;
            syncDelay = Time.time - lastSyncTime;
            lastSyncTime = Time.time;

            syncStartPosition = transform.position;
            syncEndPosition = syncPosition;
        }
    }
Ejemplo n.º 34
0
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 syncPosition = Vector3.zero;
        if ((networkView.isMine) && stream.isWriting)
        {
            //Write data to stream
            syncPosition = transform.position;
            stream.Serialize(ref syncPosition);
            print (gameObject.name);
        }
        else
        {
            //Get data from stream
            stream.Serialize(ref syncPosition);

            //Calculate sync delay (ping, kind of)
            syncDelay = Time.time - lastSynchronizationTime;
            lastSynchronizationTime = Time.time;
            NetworkManager.changeMenuDebugStatus("syncDelay: "+syncDelay);

            //Set new start and end position for movement interpolation
            syncStartPosition = syncEndPosition;
            syncEndPosition = syncPosition;
            print (syncStartPosition);
            print ("end: "+syncEndPosition);
        }
    }
Ejemplo n.º 35
0
    public override void ReceiveRPC(Distance::BitStreamReader bitStreamReader, UnityEngine.NetworkMessageInfo info)
    {
        T data = DeserializeRPC(bitStreamReader);

        foreach (var handler in subscriptions)
        {
            handler(data, info);
        }
    }
    public override void ReceiveRPC(Distance::BitStreamReader bitStreamReader, UnityEngine.NetworkMessageInfo info)
    {
        T data = DeserializeRPC(bitStreamReader);

        foreach (var conn in subscriptions)
        {
            conn.Handler(data);
        }
        ReceiveInstanced(instance, data);
    }
Ejemplo n.º 37
0
 public abstract void ReceiveSerializeEvent(byte[] bytes, UnityEngine.NetworkMessageInfo info);
Ejemplo n.º 38
0
 void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
 }
Ejemplo n.º 39
0
 public void OnSerializeNetworkView(UnityEngine.BitStream a, UnityEngine.NetworkMessageInfo b)
 {
     RunFunctions(a, b);
 }
Ejemplo n.º 40
0
 public virtual void ReceiveRPC(Distance::BitStreamReader bitStreamReader, UnityEngine.NetworkMessageInfo info)
 {
     Log.WriteLine("Received RPC to unimplemented NetworkEvent");
 }
Ejemplo n.º 41
0
 void OnNetworkInstantiate(NetworkMessageInfo info)
 {
 }
Ejemplo n.º 42
0
 public void OnNetworkInstantiate(UnityEngine.NetworkMessageInfo a)
 {
     RunFunctions(a);
 }