ReceiveNext() public method

Read next piece of data from the stream when isReading is true.
public ReceiveNext ( ) : object
return object
	public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if(stream.isWriting)
        {
            // this is my player. need to send my actual position to the network
            stream.SendNext(transform.position);
            stream.SendNext(_charController.velocity);
            stream.SendNext(transform.rotation);

        }
        else
        {
            //this is another player. need to get his position data. then update my version of this player
            Vector3 syncPosition = (Vector3)stream.ReceiveNext();
            Vector3 syncVelocity = (Vector3)stream.ReceiveNext();
            syncEndRotation = (Quaternion)stream.ReceiveNext();

            syncStartRotation = transform.rotation;

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

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

        }
    }
Beispiel #2
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting) {
            //We own this player: send the others our data
            stream.SendNext(transform.position);
            if(GetComponent<PlayerMult>())
                stream.SendNext(GetComponent<PlayerMult>().velocity);
        //			else if(GetComponent<Wind>())
        //				stream.SendNext(GetComponent<Wind>().velocity);
            else
                stream.SendNext(Vector3.zero);
        }
        else {
            //Network player, receive data
            Vector3 syncPosition = (Vector3)stream.ReceiveNext();
            syncVelocity = (Vector3)stream.ReceiveNext();
            //Debug.Log ("INCOMING");
            syncTime = 0f;
            syncDelay = Time.time - lastSynchronizationTime;
            lastSynchronizationTime = Time.time;

            syncEndPosition = syncPosition + syncVelocity * syncDelay;
            syncStartPosition = transform.position;
        }
    }
Beispiel #3
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {

        if (stream.isWriting)
        {
            // write time & position to stream
            stream.SendNext(PhotonNetwork.time);

            // send orientation
            stream.SendNext( (double)transform.rotation.eulerAngles.y); // get Y-rotation

        }
        else
        {
            // receive keyframe
            double time = (double)stream.ReceiveNext();
            double orientation = (double)stream.ReceiveNext();
            if (m_OrientationKeyframesList == null) m_OrientationKeyframesList = new KeyframeList<double>();

            m_OrientationKeyframesList.Add(time, orientation);

            if (m_OrientationKeyframesList.Count > 2)
            {
                //Debug.Log("removing old keyframes");
                // remove old keyframes ( let's say 5 seconds old? )
                m_OrientationKeyframesList.RemoveAllBefore(time - 5);
            }
        }
    }
Beispiel #4
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (PhotonNetwork.isMasterClient) {
                        if (stream.isWriting) {
                                // We own this player: send the others our data
                                stream.SendNext (transform.position);
                                stream.SendNext (transform.rotation);
                                //stream.SendNext (this.GetComponent<DumbStates> ().signalLeft);

                                //stream.SendNext (this.GetComponent<DumbStates> ().signalRight);
                        }
                } else {
                        // Network player, receive data
                        CorrectPos = (Vector3)stream.ReceiveNext ();
                        CorrectRot = (Quaternion)stream.ReceiveNext ();
                        //signalLeft = (bool)stream.ReceiveNext ();
                        //signalRight = (bool)stream.ReceiveNext ();

                        if (!SignalON && (signalLeft || signalRight)) {
                                if (signalLeft) {
                                        //this.GetComponent<DumbStates> ().onLTS ();
                                }
                                if (signalRight) {
                                        //this.GetComponent<DumbStates> ().onRTS ();
                                }
                                SignalON = true;

                        }
                        if (SignalON && !(signalLeft || signalRight)) {
                                //this.GetComponent<DumbStates> ().offTurnSignals();
                SignalON=false;

                        }
                }
    }
Beispiel #5
0
    //Serilize Data Across the network, we want everyone to know where they are
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        //Send to everyone else a local players variables to be synced and recieved by all other players on network
        if (stream.isWriting)
        {
            //send to clients where we are
            
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            stream.SendNext(health);
 
            //Sync Animation States


        }
        else
        {
            //Get from clients where they are
            //Write in the same order we read, if not writing we are reading. 
            realPosition = (Vector3)stream.ReceiveNext();
            realRotation = (Quaternion)stream.ReceiveNext();
            health = (float)stream.ReceiveNext();
            //Sync Animation States


        }
    }
Beispiel #6
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            //We own this player: send the others our data
            stream.SendNext((int)controllerScript._characterState);
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation); 
        }
        else
        {
            //Network player, receive data
            controllerScript._characterState = (CharacterState)(int)stream.ReceiveNext();
            correctPlayerPos = (Vector3)stream.ReceiveNext();
            correctPlayerRot = (Quaternion)stream.ReceiveNext();

			// avoids lerping the character from "center" to the "current" position when this client joins
			if (firstTake)
			{
				firstTake = false;
				this.transform.position = correctPlayerPos;
				transform.rotation = correctPlayerRot;
			}

        }
    }
Beispiel #7
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        // For our player
        if(stream.isWriting)
        {
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            //stream.SendNext(anim.GetFloat("Speed"));
            //stream.SendNext(anim.GetBool("Jumping"));
        }
        // For other players
        else
        {
            realPosition = (Vector3)stream.ReceiveNext();
            realRotation = (Quaternion)stream.ReceiveNext();
            //anim.SetFloat("Speed", (float)stream.ReceiveNext());
            //anim.SetBool("Jumping", (bool)stream.ReceiveNext());

            if(gotFirstUpdate == false)
            {
                transform.position = realPosition;
                transform.rotation = realRotation;
                gotFirstUpdate = true;
            }
        }
    }
Beispiel #8
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            //We own this player: send the others our data
            ControllerPlayer controllerScript = GetComponent<ControllerPlayer>();
            stream.SendNext((int)controllerScript._characterState);
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);

            Stats statsScript = GetComponent<Stats>();
            stream.SendNext(statsScript.Health);
            stream.SendNext(statsScript.Lives);
        }
        else
        {
            //Network player, receive data
            this.correctPlayerPos = (Vector3)stream.ReceiveNext();
            this.correctPlayerRot = (Quaternion)stream.ReceiveNext();

            ControllerPlayer controllerScript = GetComponent<ControllerPlayer>();
            Stats statsScript = GetComponent<Stats>();
            controllerScript._characterState = (CharacterState)(int)stream.ReceiveNext();
            statsScript.Health = (int)stream.ReceiveNext();
            statsScript.Lives = (int)stream.ReceiveNext();
        }
    }
        public void OnPhotonSerializeView(PhotonStream aStream, PhotonMessageInfo aInfo)
        {
            if (aStream.isWriting)
            {
                aStream.SendNext(transform.position);
                aStream.SendNext(transform.rotation.eulerAngles.z);
                aStream.SendNext(m_health);
            }
            else
            {

                m_photonPosition = (Vector3)aStream.ReceiveNext();
                m_photonRotation = (float)aStream.ReceiveNext();
                m_health = (int)aStream.ReceiveNext();

                stopWatch.Stop();
                if (stopWatch.ElapsedMilliseconds > (1000 / PhotonNetwork.sendRate))
                {
                    m_photonReleasedPositions.Add(new TimePosition(m_photonPosition, (float)stopWatch.ElapsedMilliseconds, m_photonRotation));
                    if (m_once && m_photonReleasedPositions.Count >= 4)
                    {
                        m_once = false;
                        StartCoroutine("ReleasePositions");
                    }
                    stopWatch.Reset();
                }
                stopWatch.Start();
            }
        }
    private void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        //Debug.Log("============>");
        if (stream.isWriting)
        {
            stream.SendNext(transform.position);
            PlayerController player = GetComponent<PlayerController>();
            string blockName = player.currentBlock == null ? "" : player.currentBlock.name;
            stream.SendNext(blockName);
        }
        else
        {
            PlayerController player = GetComponent<PlayerController>();

            this.playerPos = (Vector3)stream.ReceiveNext();
            string currentBlock = (string)stream.ReceiveNext();
            if (currentBlock != "")
            {
                player.transform.parent = null;
            }
            else
            {
                Node block = GameBoard.FindBlockByName(currentBlock);
                Debug.Log("===>"+block.name);
                player.transform.parent = block.transform;
            }
            transform.localPosition = this.playerPos;
        }
    }
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            // We own this player: send the others our data
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            stream.SendNext(text.text);

            myThirdPersonController myC = GetComponent<myThirdPersonController>();
            stream.SendNext((int)myC._characterState);
            UnityEngine.Debug.Log ("aaaaa");
        }
        else
        {
            // Network player, receive data
            this.correctPlayerPos = (Vector3)stream.ReceiveNext();
            this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
            this.ttext = (string)stream.ReceiveNext();
            UnityEngine.Debug.Log (ttext);
            if(text.text.Length < ttext.Length){
                text.text = ttext;
            }

            myThirdPersonController myC = GetComponent<myThirdPersonController>();
            myC._characterState = (CharacterState)stream.ReceiveNext();
            UnityEngine.Debug.Log ("bbb");
        }
    }
Beispiel #12
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            //We own this player: send the others our data
           // stream.SendNext((int)controllerScript._characterState);
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            //stream.SendNext(GetComponent<Rigidbody>().velocity); 

        }
        else
        {
            //Network player, receive data
            //controllerScript._characterState = (CharacterState)(int)stream.ReceiveNext();
            correctPlayerPos = (Vector3)stream.ReceiveNext();
            correctPlayerRot = (Quaternion)stream.ReceiveNext();
            //GetComponent<Rigidbody>().velocity = (Vector3)stream.ReceiveNext();

            if (!appliedInitialUpdate)
            {
                appliedInitialUpdate = true;
                transform.position = correctPlayerPos;
                transform.rotation = correctPlayerRot;
                //GetComponent<Rigidbody>().velocity = Vector3.zero;
            }
        }
    }
Beispiel #13
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if(stream.isWriting) {
            // This is our player. We need to send our actual position to the network.

            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            stream.SendNext(anim.GetFloat("Speed"));
            stream.SendNext(anim.GetBool("Jumping"));

        }
        else {
            // This is someone else's player. We need to reciece their position.

            // Right now, "realPosition" holds the other person's position at the LAST frame.
            // Instead of simply updating "realPosition" and continuing to lerp,
            //we MAY want to set our transform.position to immediately to this old "realPosition"
            //and then update realPosition

            realPosition = (Vector3)stream.ReceiveNext ();
            realRotation = (Quaternion)stream.ReceiveNext ();
            anim.SetFloat ("Speed", (float)stream.ReceiveNext() );
            anim.SetBool ("Jumping", (bool)stream.ReceiveNext() );

            if(gotFirstUpdate == false) {
                transform.position = realPosition;
                transform.rotation = realRotation;
                gotFirstUpdate = true;
            }

        }
    }
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting == true)
        {
            if (this.m_SynchronizeVelocity == true)
            {
                stream.SendNext(this.m_Body.velocity);
            }

            if (this.m_SynchronizeAngularVelocity == true)
            {
                stream.SendNext(this.m_Body.angularVelocity);
            }
        }
        else
        {
            if (this.m_SynchronizeVelocity == true)
            {
                this.m_Body.velocity = (Vector3)stream.ReceiveNext();
            }

            if (this.m_SynchronizeAngularVelocity == true)
            {
                this.m_Body.angularVelocity = (Vector3)stream.ReceiveNext();
            }
        }
    }
Beispiel #15
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            //We own this player: send the others our data
            stream.SendNext(myRigid);
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            if(myRigid){
                stream.SendNext(rigidbody.velocity);
            }
        }
        else
        {
            if (!appliedInitialUpdate && hisRigid)
            {
                appliedInitialUpdate = true;
                transform.position = correctPlayerPos;
                transform.rotation = correctPlayerRot;
                rigidbody.velocity = Vector3.zero;
            }

            //Network player, receive data
            hisRigid         = (bool)stream.ReceiveNext();
            correctPlayerPos = (Vector3)stream.ReceiveNext();
            correctPlayerRot = (Quaternion)stream.ReceiveNext();

            if(hisRigid){
                rigidbody.velocity = (Vector3)stream.ReceiveNext();
            }
        }
    }
    private void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            //We own this player: send the others our data
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);

            // animation data
            int[] animStates = _playerAnim.GetAnimationBooleans();
            stream.SendNext(animStates[0]);
            stream.SendNext(animStates[1]);
            stream.SendNext(animStates[2]);
        }
        else
        {
            //Network player, receive data
            _correctPlayerPos = (Vector3)stream.ReceiveNext();
            _correctPlayerRot = (Quaternion)stream.ReceiveNext();

            // animation data
            _playerAnim.ApplyNetworkAnimations((int)stream.ReceiveNext(), (int)stream.ReceiveNext(), (int)stream.ReceiveNext());

            syncTime = 0f;
            syncDelay = Time.time - lastSynchronizationTime;
            lastSynchronizationTime = Time.time;
        }
    }
Beispiel #17
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if(stream.isWriting)
        {

            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            if(anim.IsPlaying("Run"))
            {

                stream.SendNext(useThisMove = 1);

            }
            if(anim.IsPlaying ("Idle"))
            {
                stream.SendNext (useThisMove = -1);

            }
            if(anim.IsPlaying ("AutoAttack"))
            {
                stream.SendNext(useThisMove = -2);

            }

        }
        else
        {

            realPosition = (Vector3)stream.ReceiveNext();
            realRotation = (Quaternion)stream.ReceiveNext();

            useThisMove = (int)stream.ReceiveNext();

        }
    }
Beispiel #18
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        UnityEngine.Debug.Log("point");
        if (stream.isWriting)
        {
            var pointText = GameObject.Find("Point").GetComponent<Text>();
            string point = pointText.text;
            // We own this player: send the others our data
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            UnityEngine.Debug.Log(pointText.text);
            stream.SendNext(pointText.text);
            UnityEngine.Debug.Log("point2");
        }
        else
        {
            // Network player, receive data
            this.correctPlayerPos = (Vector3)stream.ReceiveNext();
            this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
            UnityEngine.Debug.Log((Vector3)stream.ReceiveNext());
            var pointText = GameObject.Find("EnemyPoint").GetComponent<Text>();
            UnityEngine.Debug.Log("point3");
            pointText.text = (string)stream.ReceiveNext();

        }
    }
    void OnPhotonSerializeView(PhotonStream aStream, PhotonMessageInfo aInfo)
    {
        CacheComponents ();

        if (aStream.isWriting) {
            // this is our player, we must send out our actual position
            aStream.SendNext(transform.position);
            aStream.SendNext(transform.rotation);
            aStream.SendNext(anim.GetFloat("Speed"));
            aStream.SendNext(anim.GetBool("Jumping"));
            aStream.SendNext (anim.GetFloat("AimAngle"));
        }
        else {
            // this is someone elses player, we need to receive their player and update
            // our version of that player
            realPosition = (Vector3) aStream.ReceiveNext();
            realRotation = (Quaternion) aStream.ReceiveNext();
            anim.SetFloat("Speed", (float)aStream.ReceiveNext());
            anim.SetBool("Jumping", (bool)aStream.ReceiveNext());
            realAimAngle  = (float) aStream.ReceiveNext();

            if(gotFirstUpdate == false) {
                transform.position = realPosition;
                transform.rotation = realRotation;
                anim.SetFloat("AimAngle", realAimAngle);
                gotFirstUpdate = true;
            }
        }
    }
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if(stream.isWriting){
            // this is our player, we send of posision data here
            stream.SendNext(transform.position); //send our posision to the network
            stream.SendNext(transform.rotation); // send our rotation to the network
            stream.SendNext(anim.GetFloat("Speed"));
            stream.SendNext(anim.GetBool("Jumping"));
            stream.SendNext(anim.GetFloat("AimAngle"));
        }
        else {
            //this is everyone elses players, we recieve their posisions here

            // right now realPosition holds the player position on the Last frame
            // instead of simply updating "RealPosition" and continuing to lerp
            // we MAY want to set out transform.position IMMEDIITLY to this old "realPosition"
            // then update realPosition

            realPosition = (Vector3)stream.ReceiveNext(); //recieve others posisions
            realRotation = (Quaternion)stream.ReceiveNext(); // recieve others rotations
            anim.SetFloat("Speed", (float)stream.ReceiveNext());
            anim.SetBool("Jumping", (bool)stream.ReceiveNext());
            realAimAngle = (float)stream.ReceiveNext();

            if (gotFirstUpdate == false) {
                transform.position = realPosition;
                transform.rotation = realRotation;
                anim.SetFloat("AimAngle", realAimAngle);
                gotFirstUpdate = true;
            }
        }
    }
	void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
		if(stream.isWriting) {
			stream.SendNext(transform.position);
			stream.SendNext(transform.rotation);
		} else {
			position = (Vector3)stream.ReceiveNext();
			rotation = (Quaternion)stream.ReceiveNext();
		}
	}
Beispiel #22
0
 public static Vector3 ReadVectorFromShort(PhotonStream stream)
 {
     Vector3 newPosition = Vector3.zero;
     //Debug.Log (stream.ReceiveNext ());
     newPosition.x = ((short)stream.ReceiveNext())/FLOAT_COEF;
     //Debug.Log (newPosition.x);
     newPosition.y = ((short)stream.ReceiveNext())/FLOAT_COEF;
     newPosition.z = ((short)stream.ReceiveNext())/FLOAT_COEF;
     return newPosition;
 }
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting) {
         stream.SendNext(todScript.slider);
         stream.SendNext(todScript.slider2);
     }  else {
         todScript.slider = (float) stream.ReceiveNext();
         todScript.slider2 =  (float) stream.ReceiveNext();
     }
 }
Beispiel #24
0
 /**
    * For Photon updates send the current progress state
    * and the current game time
    */
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting) {
       stream.SendNext(inProgress);
       stream.SendNext(gameTimer.GameTime());
     } else {
       inProgress = (bool) stream.ReceiveNext();
       gameTimer.GameTime((float) stream.ReceiveNext());
     }
 }
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            // We own this player: send the others our data
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            anim = GetComponent< Animator >();
            stream.SendNext(anim.GetFloat("Speed"));
            stream.SendNext(anim.GetFloat("Direction"));
            stream.SendNext(anim.GetBool("Punch_L"));
            stream.SendNext(anim.GetBool("LowKick"));
            stream.SendNext(anim.GetBool("HiKick"));
            stream.SendNext(anim.GetBool("Shoryuken"));

            myThirdPersonController myC = GetComponent<myThirdPersonController>();
            stream.SendNext((int)myC._characterState);
        }
        else
        {
            // Network player, receive data
            this.correctPlayerPos = (Vector3)stream.ReceiveNext();
            this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
            anim = GetComponent< Animator >();
            anim.SetFloat("Speed",(float)stream.ReceiveNext());
            anim.SetFloat("Direction",(float)stream.ReceiveNext());
            anim.SetBool("Punch_L",(bool)stream.ReceiveNext());
            anim.SetBool("LowKick",(bool)stream.ReceiveNext());
            anim.SetBool("HiKick", (bool)stream.ReceiveNext());
            anim.SetBool("Shoryuken", (bool)stream.ReceiveNext());

            myThirdPersonController myC = GetComponent<myThirdPersonController>();
            myC._characterState = (CharacterState)stream.ReceiveNext();
        }
    }
    //    void Update() {
    //        if (!photonView.isMine) {
    //            transform.position = Vector3.Lerp(transform.position, correctPlayerPosition, 0.1f);
    //            transform.rotation = Quaternion.Lerp (transform.rotation, correctPlayerRotation, 0.1f);
    //        }
    //    }
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        Animator anim = transform.GetComponentInChildren<Animator> ();

        if (stream.isWriting) {
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            stream.SendNext(anim.GetFloat("Forward"));
            stream.SendNext(anim.GetFloat("Turn"));
            stream.SendNext(anim.GetBool("OnGround"));
            stream.SendNext(anim.GetFloat("Jump"));
            stream.SendNext(anim.GetFloat("JumpLeg"));
            stream.SendNext(anim.GetBool("Guard"));
            stream.SendNext(anim.GetFloat("Block"));
        }  else {
            this.correctPlayerPosition = (Vector3) stream.ReceiveNext();
            this.correctPlayerRotation =  (Quaternion) stream.ReceiveNext();
            this.anim.SetFloat("Forward", (float) stream.ReceiveNext());
            this.anim.SetFloat("Turn", (float) stream.ReceiveNext());
            this.anim.SetBool("OnGround", (bool) stream.ReceiveNext());
            this.anim.SetFloat("Jump", (float) stream.ReceiveNext());
            this.anim.SetFloat("JumpLeg", (float) stream.ReceiveNext());
            this.anim.SetBool("Guard", (bool) stream.ReceiveNext());
            this.anim.SetFloat("Block", (float) stream.ReceiveNext());
        }
    }
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            stream.SendNext(anim.GetFloat("posX"));
            stream.SendNext(anim.GetFloat("Ydirection"));
            stream.SendNext(anim.GetFloat("Run"));
            stream.SendNext(anim.GetFloat("inputH"));
            stream.SendNext(anim.GetFloat("inputV"));
            stream.SendNext(anim.GetBool("isRunning"));
            stream.SendNext(anim.GetBool("isBlocking"));

        }
        else
        {
            realPosition = (Vector3)stream.ReceiveNext();
            realRotation = (Quaternion)stream.ReceiveNext();
            anim.SetFloat("posX", (float)stream.ReceiveNext());
            anim.SetFloat("Ydirection", (float)stream.ReceiveNext());
            anim.SetFloat("Run", (float)stream.ReceiveNext());
            anim.SetFloat("inputH", (float)stream.ReceiveNext());
            anim.SetFloat("inputV", (float)stream.ReceiveNext());
            anim.SetBool("isRunning", (bool)stream.ReceiveNext());
            anim.SetBool("isBlocking", (bool)stream.ReceiveNext());
            //myView.RPC("setTrigger", PhotonTargets.All, "Attack");
        }
    }
Beispiel #28
0
	void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
	{
		// 로컬 플레이어의 위치 정보 송신
		if (stream.isWriting) {
			stream.SendNext (tr.position);
			stream.SendNext (tr.rotation);
		} else {
			currPos = (Vector3) stream.ReceiveNext();
			currRot = (Quaternion) stream.ReceiveNext();
		}
	}
	public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
		//Debug.Log("Event exist!");
		if (stream.isWriting) {
			//Our player in network. Sending out our actual position to the network
			stream.SendNext(transform.position);
			stream.SendNext (transform.rotation);
		} else {
			//Other player in network. recieving their actual position to the network
			realPosition = (Vector3)stream.ReceiveNext();
			realRotation = (Quaternion)stream.ReceiveNext ();
		}
	}
    Vector3 newTransform = Vector3.zero; //the object's actual position on the owner's game

    #endregion Fields

    #region Methods

    //updates the players positions by sending/receiving data to other players
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isReading) {//we don't own this character so we are receiving data about this character
            newTransform = (Vector3) stream.ReceiveNext();
            newRotation = (Quaternion) stream.ReceiveNext ();

        }
        else { //we own this character, so send data
            stream.SendNext (transform.position);
            stream.SendNext (transform.rotation);
        }
    }
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)
     {
         for (int i = 0; i < teamScore.Length; i++)
         {
             stream.SendNext(teamScore[i]);
         }
     }
     else
     {
         for (int i = 0; i < teamScore.Length; i++)
         {
             teamScore[i] = (int)stream.ReceiveNext();
         }
     }
 }
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            //Executed on the owner of this PhotonView;
            //The server sends it's position over the network

            stream.SendNext(transform.position);//"Encode" it, and send it
        }
        else
        {
            //Executed on the others;
            //receive a position and set the object to it

            transform.position = (Vector3)stream.ReceiveNext();
        }
    }
Beispiel #33
0
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)
     {
         //send weapons
         stream.SendNext(RangedId);
         //stream.SendNext(MeleeId);
     }
     else
     {
         //get weapons
         RangedId      = (int)stream.ReceiveNext();
         EquipedRanged = GameObject.FindGameObjectWithTag("ScriptManager").transform.FindChild("Weapons").GetComponents <WeaponScript>()[RangedId];
         //MeleeId = (int)stream.ReceiveNext();
         //EquipedMelee = GameObject.FindGameObjectWithTag("ScriptManager").transform.FindChild("Weapons").GetComponents<WeaponScript>()[MeleeId];
     }
 }
Beispiel #34
0
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.IsWriting)
     {
         stream.SendNext(justRemath);
         justRemath = false;
     }
     else
     {
         if ((bool)stream.ReceiveNext())
         {
             GameObject.Find("EndGame").GetComponent <EndGameScript>().Rematch();
             GameObject.Find("ScoreController").GetComponent <ScoreManager>().Rematch();
             Frog.LocalPlayerInstance.transform.position = (PhotonNetwork.IsMasterClient) ? player1Spawn.position : player2Spawn.position;
         }
     }
 }
Beispiel #35
0
 void IPunObservable.OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.IsWriting)
     {
         if (MultiPlayer.jogador == 2)
         {
             stream.SendNext(senhaPass);
         }
     }
     else
     {
         if (stream.IsReading)
         {
             senha = (int[])stream.ReceiveNext();
         }
     }
 }
Beispiel #36
0
    void IPunObservable.OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            stream.SendNext(super);
        }
        else
        {
            float ls = (float)stream.ReceiveNext();

            if (ls != super)
            {
                super = ls;
                OnUIShouldUpdate?.Invoke();
            }
        }
    }
Beispiel #37
0
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.IsWriting)
     {
         if (photonView.IsMine)
         {
             stream.SendNext(sendKills);
         }
     }
     else if (stream.IsReading)
     {
         if (!photonView.IsMine)
         {
             receivedKills = (int)stream.ReceiveNext();
         }
     }
 }
Beispiel #38
0
    public void OnPhotonSerializeView(Vector3 currentScale, PhotonStream stream, PhotonMessageInfo info)
    {
        if (m_Model.SynchronizeEnabled == false)
        {
            return;
        }

        if (stream.isWriting == true)
        {
            stream.SendNext(currentScale);
            m_NetworkScale = currentScale;
        }
        else
        {
            m_NetworkScale = (Vector3)stream.ReceiveNext();
        }
    }
Beispiel #39
0
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.IsWriting)
     {
         if (GetComponent <Player>().isGameMaster)
         {
             stream.SendNext(newZoneCreated);
         }
     }
     else
     {
         if (!GetComponent <Player>().isGameMaster)
         {
             newZoneCreated = (bool)stream.ReceiveNext();
         }
     }
 }
Beispiel #40
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        Debug.Log("On serialize view.");

        if (stream.isWriting)
        {
            if (PhotonNetwork.isMasterClient)
            {
                stream.SendNext(isOn);
            }
        }
        else
        {
            isOn = (bool)stream.ReceiveNext();
            OnValueChanged_Toggle();
        }
    }
Beispiel #41
0
    public void OnPhotonSerializeView(Quaternion currentRotation, PhotonStream stream, PhotonMessageInfo info)
    {
        if (m_Model.SynchronizeEnabled == false)
        {
            return;
        }

        if (stream.isWriting == true)
        {
            stream.SendNext(currentRotation);
            m_NetworkRotation = currentRotation;
        }
        else
        {
            m_NetworkRotation = (Quaternion)stream.ReceiveNext();
        }
    }
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            //this is our character since it's in writing state
            // stream.SendNext()

            stream.SendNext(ourWeaponInventory.activeWeaponIndex);
        }
        else
        {
            //this is a network player because it's in Read, not write
            //stream.ReceiveNext();

            ourWeaponInventory.SwapWeapon((int)stream.ReceiveNext());
        }
    }
Beispiel #43
0
    private void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        // send data
        if (stream.isWriting)
        {
            Debug.Log("Writing");
            stream.SendNext(playerHealth);
        }

        // receive data
        else if (stream.isReading)
        {
            Debug.Log("Reading");
            playerHealth = (int)stream.ReceiveNext();
            updateUI(playerHealth);
        }
    }
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            //stream.SendNext (owner);
            //	stream.SendNext (id);

            //stream.SendNext (new Serializer().SerializeToString(minions));
            stream.SendNext(minionCount);
        }
        else
        {
            //minions=new Serializer().DeserializeFromString<List<minionData>> ((string)stream.ReceiveNext ());
            //	id=(string) stream.ReceiveNext();
            minionCount = (int)stream.ReceiveNext();
        }
    }
Beispiel #45
0
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     {
         if (stream.IsWriting) //if i'm local player, i send my info to sync my replicate in others clients...
         {
             stream.SendNext((Vector3)transform.position);
         }
         else //else if i'm a replicated of the local player, i set the data to te actuale replicated
         {
             currentTime          = 0.0;
             positionAtLastPacket = transform.position;            //last position received previously
             realPosition         = (Vector3)stream.ReceiveNext(); //actual position from data pack
             lastPacketTime       = currentPacketTime;
             currentPacketTime    = info.timestamp;
         }
     }
 }
Beispiel #46
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            // We own this player: send the others our data

            stream.SendNext(_curAngle); // 총알 방향 UI
        }
        else
        {
            // Network player, receive data

            _curAngle = (float)stream.ReceiveNext();

            _range.rotation = Quaternion.AngleAxis(_curAngle, Vector3.forward);
        }
    }
Beispiel #47
0
 // sync the activation status of all children
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.IsWriting)
     {
         foreach (GameObject go in instances)
         {
             stream.SendNext(go.activeInHierarchy);
         }
     }
     else
     {
         foreach (GameObject go in instances)
         {
             go.SetActive((bool)stream.ReceiveNext());
         }
     }
 }
Beispiel #48
0
        public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
        {
            if (stream.IsWriting)
            {
                Debug.Log("wysylam wiad");
                // We own this player: send the others our data
                stream.SendNext(visible);

                //Debug.Log("dupa");
            }
            else
            {
                // Network player, receive data
                Debug.Log("odbieram wiad");
                gob.SetActive((bool)stream.ReceiveNext());
            }
        }
Beispiel #49
0
    }                                            // 게임 오버 상태

    //주기적으로 자동실행되는 동기화 메서드
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        //로컬 오브젝트라면 쓰기 부분이 실행됨
        if (stream.IsWriting)
        {
            //네트워크를 통해 score 값 보내기
            stream.SendNext(score);
        }
        else
        {
            //리모트 오브젝트라면 읽기 부분이 실행됨
            //네트워크를 통해 score값 받기
            score = (int)stream.ReceiveNext();
            //동기화 하여 받은점수를 UI로 표시
            UIManager.instance.UpdateScoreText(score);
        }
    }
Beispiel #50
0
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)
     {
         //送信処理
         stream.SendNext(_pos);
     }
     else
     {
         //受信処理
         Vector2 pos = (Vector2)stream.ReceiveNext();
         if (pos != _pos)
         {
             _pos = pos;
         }
     }
 }
Beispiel #51
0
    /// <summary>
    /// serialization method of photon
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        m_PositionControl.OnPhotonSerializeView(transform.localPosition, stream, info);
        m_RotationControl.OnPhotonSerializeView(transform.localRotation, stream, info);
        m_ScaleControl.OnPhotonSerializeView(transform.localScale, stream, info);
        if (isMine == false && m_PositionModel.DrawErrorGizmo == true)
        {
            DoDrawEstimatedPositionError();
        }
        if (stream.isWriting)
        {
            //We own this player: send the others our data
            stream.SendNext(gameObject.name);
            stream.SendNext(HeatTarget.position);
            stream.SendNext(HeatTarget.rotation);
            stream.SendNext((int)Controller.State);
            stream.SendNext(Controller.isGrounded);
            stream.SendNext(GManager.GetCurrentWeapon().GunID);
            stream.SendNext(Settings.m_Team.ToString());
            stream.SendNext(WeaponState);
            stream.SendNext(Controller.Velocity);
        }
        else
        {
            //Network player, receive data
            RemotePlayerName = (string)stream.ReceiveNext();
            HeadPos          = (Vector3)stream.ReceiveNext();
            HeadRot          = (Quaternion)stream.ReceiveNext();
            m_state          = (int)stream.ReceiveNext();
            m_grounded       = (bool)stream.ReceiveNext();
            CurNetGun        = (int)stream.ReceiveNext();
            RemoteTeam       = (string)stream.ReceiveNext();
            UpperState       = (string)stream.ReceiveNext();
            velocity         = (Vector3)stream.ReceiveNext();

            m_ReceivedNetworkUpdate = true;
        }
    }
Beispiel #52
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            // 自クライアント所有のオブジェクトの状態変更を送信
            string myName = this.gameObject.name;
            stream.SendNext(myName);
        }
        else
        {
            // 他クライアント所有のオブジェクトの状態変更を受信
            string otherName = (string)stream.ReceiveNext();

            // 名前の変更を反映する
            this.gameObject.name = otherName;
            transform.Find("NameUI").gameObject.GetComponent <TextMesh>().text = otherName;
        }
    }
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.IsWriting)
     {
         stream.SendNext(transform.localRotation);
         stream.SendNext(PlayerMovementModel.AimPoint);
         stream.SendNext(Animator.GetFloat(SpeedHash));
         stream.SendNext(RightShoulderIK.localPosition);
         stream.SendNext(RightShoulderIK.localRotation);
     }
     else
     {
         ReceiveLocalRotation(stream);
         NetworkAimPos = (Vector3)stream.ReceiveNext();
         ReceiveAnimationStates(stream);
         ReceiveShouldState(stream);
     }
 }
Beispiel #54
0
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.IsWriting)
     {
         stream.SendNext((int)GameManager.CurrentGameSate);
     }
     else
     {
         if (!photonView.IsMine)
         {
             GameManager.GameState newState = (GameManager.GameState)stream.ReceiveNext();
             if (playerState != newState)
             {
                 SetPlayerState(newState);
             }
         }
     }
 }
Beispiel #55
0
        public virtual void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
        {
            if (stream.isWriting)
            {
                stream.SendNext(m_Control.BehaviourModeKey);
            }
            else                                                                                                                // !stream.isWriting
            {
                m_Control.BehaviourModeKey = (string)stream.ReceiveNext();

                /*m_SyncEndPosition = (Vector3)stream.ReceiveNext();
                 * m_SyncStartPosition = transform.position;*/

                m_SyncTime  = 0f;
                m_SyncDelay = Time.time - m_LastSynchronizationTime;
                m_LastSynchronizationTime = Time.time;
            }
        }
Beispiel #56
0
    public virtual void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            PrepareToSerialize();

            serializedString = stringToSend;
            stringToSend     = "";

            stream.SendNext(serializedString);
        }
        else
        {
            stringReceived = (string)stream.ReceiveNext();

            ReadString();
        }
    }
Beispiel #57
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            //Debug.Log(gameObject.transform.position);
            //send data to the other player
            //stream.SendNext(rb.position - chessBoard.transform.position);
            stream.SendNext(gameObject.transform.position - chessBoard.transform.position);
        }
        else
        {
            //called on my object in the remote player's game
            networkedPosition = (Vector3)stream.ReceiveNext() + chessBoard.transform.position;
        }

        //distance = Vector3.Distance(rb.position, networkedPosition);
        distance = Vector3.Distance(gameObject.transform.position, networkedPosition);
    }
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            // We own this player: send the others our data
            //stream.SendNext(transform.position);
            //stream.SendNext(transform.rotation);
            stream.SendNext(info);
        }
        else
        {
            // Network player, receive data
            //this.correctPlayerPos = (Vector3)stream.ReceiveNext();
            //this.correctPlayerRot = (Quaternion)stream.ReceiveNext();

            this.info = (ChunkInfo)stream.ReceiveNext();
        }
    }
Beispiel #59
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            stream.SendNext(GetComponent <Rigidbody2D> ().transform.position);
        }

        else
        {
            syncEndPosition         = (Vector3)stream.ReceiveNext();
            syncStartPosition       = GetComponent <Rigidbody2D>().transform.position;
            syncTime                = 0f;
            syncDelay               = Time.time - lastSynchronizationTime;
            lastSynchronizationTime = Time.time;

            //GetComponentInChildren<Rigidbody2D>().transform.position = (Vector3)stream.ReceiveNext();
        }
    }
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (index == 1)
     {
         if (stream.isWriting)
         {
             // 我们是本地玩家,则把数据发送给远程玩家
             // stream.SendNext(this.IsFiring);
             stream.SendNext(this.Health);
         }
         else
         {
             //网络玩家则接收数据
             //  this.IsFiring = (bool)stream.ReceiveNext();
             this.Health = (float)stream.ReceiveNext();
         }
     }
 }