SendNext() public method

Add another piece of data to send it when isWriting is true.
public SendNext ( object obj ) : void
obj object
return void
コード例 #1
0
    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;
            }
        }
    }
コード例 #2
0
	void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
	{
		if(IsActive)
		{
			if(stream.isWriting)
			{
				//stream.Serialize(_transform.position);
				stream.SendNext(_transform.localPosition);
				stream.SendNext(_transform.rotation);
				stream.SendNext(_motor.controller.velocity.sqrMagnitude);
				stream.SendNext(myStatus.curMovementSpeed);
			}
			else
			{
				realPosition = (Vector3)stream.ReceiveNext();
				realRotation = (Quaternion)stream.ReceiveNext();
				currentSpeed = (float)stream.ReceiveNext();
				myStatus.clientCurMovementSpeed = (float)stream.ReceiveNext();

				latestCorrectPos = realPosition;                 // save this to move towards it in FixedUpdate()
				onUpdatePos = _transform.localPosition;  // we interpolate from here to latestCorrectPos
				fraction = 0;  
			}
		}
	}
コード例 #3
0
    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;
            }
        }
    }
コード例 #4
0
ファイル: Player_Orientation.cs プロジェクト: McBuff/DMV
        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);
                }
            }
        }
コード例 #5
0
ファイル: NetCharacter.cs プロジェクト: jkwendorf/ProjectHERO
    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;
            }
        }
    }
コード例 #6
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();

        }
    }
コード例 #7
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;

                        }
                }
    }
コード例 #8
0
ファイル: BulletNetwork.cs プロジェクト: patricio272/VoxelVR
    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;
            }
        }
    }
コード例 #9
0
    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;
        }
    }
コード例 #10
0
ファイル: NetworkCharacter.cs プロジェクト: Goodyjake/zombinc
    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;
            }

        }
    }
コード例 #11
0
ファイル: ProjectileNetwork.cs プロジェクト: acimbru/licenta
    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();
            }
        }
    }
コード例 #12
0
ファイル: NetworkSync.cs プロジェクト: Ckeds/PortfolioWorks
    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;
        }
    }
コード例 #13
0
    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");
        }
    }
コード例 #14
0
    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();
            }
        }
    }
コード例 #15
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();

        }
    }
コード例 #16
0
ファイル: NetworkMovement.cs プロジェクト: micha224/Jan_1GAM
    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();
        }
    }
コード例 #17
0
ファイル: ThirdPersonNetwork.cs プロジェクト: na2424/ChatUni
    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;
			}

        }
    }
コード例 #18
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 bool for grounded, float for running
             if (!cam.GetComponent<RTSCamera>())
             {
                 stream.SendNext(controllerScript.forwardInput);
                 stream.SendNext(controllerScript.grounded);
                 stream.SendNext(transform.position);
                 stream.SendNext(transform.rotation);
                 stream.SendNext(controllerScript.velocity);
             }
         }
         else
         {
             //Network player, receive data
             //controllerScript._characterState = (CharacterState)(int)stream.ReceiveNext();
             //stream bool for grounded, float for running
             forwardInput = (float)stream.ReceiveNext();
             grounded = (bool)stream.ReceiveNext();
             correctPlayerPos = (Vector3)stream.ReceiveNext();
             correctPlayerRot = (Quaternion)stream.ReceiveNext();
             correctPlayerVelocity = (Vector3)stream.ReceiveNext();
         }
 }
コード例 #19
0
	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;

        }
    }
コード例 #20
0
        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();
            }
        }
コード例 #21
0
ファイル: DroneNetworkMover.cs プロジェクト: hamza765/Kelpie5
    //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


        }
    }
コード例 #22
0
    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;
        }
    }
コード例 #23
0
	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();
		}
	}
コード例 #24
0
 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();
     }
 }
コード例 #25
0
ファイル: GameController.cs プロジェクト: remz99/simplefps
 /**
    * 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());
     }
 }
コード例 #26
0
    //    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());
        }
    }
コード例 #27
0
    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");
        }
    }
コード例 #28
0
    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();
        }
    }
コード例 #29
0
ファイル: TankMove.cs プロジェクト: blinkstar73/My-First-Repo
	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();
		}
	}
コード例 #30
0
    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);
        }
    }
コード例 #31
0
 /// <summary>
 /// Controls the exchange of data between local and remote player's VR data
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="info"></param>
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.IsWriting)
     {
         // Send local VR Headset position and rotation data to networked player
         stream.SendNext(localVRHeadset.position);
         stream.SendNext(localVRHeadset.rotation);
         stream.SendNext(localVRControllerLeft.position);
         stream.SendNext(localVRControllerLeft.rotation);
         stream.SendNext(localVRControllerRight.position);
         stream.SendNext(localVRControllerRight.rotation);
     }
     else if (stream.IsReading)
     {
         // Receive networked player's VR Headset position and rotation data
         correctPlayerHeadPosition      = (Vector3)stream.ReceiveNext();
         correctPlayerHeadRotation      = (Quaternion)stream.ReceiveNext();
         correctPlayerLeftHandPosition  = (Vector3)stream.ReceiveNext();
         correctPlayerLeftHandRotation  = (Quaternion)stream.ReceiveNext();
         correctPlayerRightHandPosition = (Vector3)stream.ReceiveNext();
         correctPlayerRightHandRotation = (Quaternion)stream.ReceiveNext();
     }
 }
コード例 #32
0
 public 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(Input.GetAxis("Vertical"));
         stream.SendNext(Input.GetAxis("Horizontal"));
         stream.SendNext(Input.GetKey("left shift"));
         stream.SendNext(Input.GetKey("e"));
     }
     else
     {
         // Network player, receive data
         this.correctPlayerPos = (Vector3)stream.ReceiveNext();
         this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
         anim.SetFloat("Speed", (float)stream.ReceiveNext());
         anim.SetFloat("Direction", (float)stream.ReceiveNext());
         anim.SetBool("Run", (bool)stream.ReceiveNext());
         anim.SetBool("Interact", (bool)stream.ReceiveNext());
     }
 }
コード例 #33
0
 public 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(anim.GetBool("run"));
         stream.SendNext(anim.GetBool("isWalk"));
         stream.SendNext(anim.GetFloat("inputH"));
         stream.SendNext(anim.GetFloat("inputV"));
     }
     else
     {
         // Network player, receive data
         correctPlayerPos = (Vector3)stream.ReceiveNext();
         correctPlayerRot = (Quaternion)stream.ReceiveNext();
         anim.SetBool("run", (bool)stream.ReceiveNext());
         anim.SetBool("isWalk", (bool)stream.ReceiveNext());
         anim.SetFloat("inputH", (float)stream.ReceiveNext());
         anim.SetFloat("inputV", (float)stream.ReceiveNext());
     }
 }
コード例 #34
0
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.IsWriting)
     {
         stream.SendNext(currentWave);
         stream.SendNext(currentWaveNumber);
         stream.SendNext(remainingEnemiesToSpawn);
         stream.SendNext(remainingLivingEnemies);
         stream.SendNext(enemyTypesToSpawn);
         stream.SendNext(enemyObjects);
         //stream.SendNext(gameStarted);
     }
     else
     {
         this.currentWave             = (Wave)stream.ReceiveNext();
         this.currentWaveNumber       = (int)stream.ReceiveNext();
         this.remainingEnemiesToSpawn = (int)stream.ReceiveNext();
         this.remainingLivingEnemies  = (int)stream.ReceiveNext();
         this.enemyTypesToSpawn       = (List <WaveEnemies>)stream.ReceiveNext();
         this.enemyObjects            = (List <GameObject>)stream.ReceiveNext();
         //this.gameStarted = (bool)stream.ReceiveNext();
     }
 }
コード例 #35
0
 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(givenInput);
         stream.SendNext(LR);
         stream.SendNext(rb.velocity);
         stream.SendNext((float)rhealth.curShield / (float)rhealth.MaxShield);
     }
     else
     {
         // Network player, receive data
         this.correctPlayerPos = (Vector3)stream.ReceiveNext();
         this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
         this.givenInput       = (bool)stream.ReceiveNext();
         this.LR  = (float)stream.ReceiveNext();
         curVel   = (Vector2)stream.ReceiveNext();
         shieldOn = (float)stream.ReceiveNext();
     }
 }
コード例 #36
0
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)
     {
         // We own this player: send the others our data
         stream.SendNext(playerScore);
         stream.SendNext(playerName);
         stream.SendNext(playerRank);
         stream.SendNext(playerId);
         stream.SendNext(deviceId);
         stream.SendNext(totalScore);
     }
     else
     {
         // Network player, receive data
         this.playerScore = (int)stream.ReceiveNext();
         this.playerName  = (string)stream.ReceiveNext();
         this.playerRank  = (string)stream.ReceiveNext();
         this.playerId    = (string)stream.ReceiveNext();
         this.deviceId    = (string)stream.ReceiveNext();
         this.totalScore  = (string)stream.ReceiveNext();
     }
 }
コード例 #37
0
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     //Debug.Log("GGGGGGGGGGGGGGGGGGGGGGGG");
     if (stream.isWriting)
     {
         stream.SendNext(first);
         stream.SendNext(second);
         stream.SendNext(third);
         stream.SendNext(firstScore);
         stream.SendNext(secondScore);
         stream.SendNext(thirdScore);
     }
     else
     {
         first       = (string)stream.ReceiveNext();
         second      = (string)stream.ReceiveNext();
         third       = (string)stream.ReceiveNext();
         firstScore  = (float)stream.ReceiveNext();
         secondScore = (float)stream.ReceiveNext();
         thirdScore  = (float)stream.ReceiveNext();
         //Debug.Log(first);
     }
 }
コード例 #38
0
    void IPunObservable.OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            globalDirection      = playerGlobal.position - globalStoredPosition;
            globalStoredPosition = playerGlobal.position;

            localDirection      = avatar.transform.localPosition - localStoredPosition;
            localStoredPosition = avatar.transform.localPosition;
            stream.SendNext(playerGlobal.position);
            stream.SendNext(playerGlobal.rotation);
            stream.SendNext(playerLocal.localPosition);
            stream.SendNext(playerLocal.localRotation);

            stream.SendNext(globalDirection);
            stream.SendNext(localDirection);
        }
        else
        {
            globalNetworkPosition = (Vector3)stream.ReceiveNext();
            globalNetworkRotation = (Quaternion)stream.ReceiveNext();
            localNetworkPosition  = (Vector3)stream.ReceiveNext();
            localNetworkRotation  = (Quaternion)stream.ReceiveNext();

            globalDirection = (Vector3)stream.ReceiveNext();
            localDirection  = (Vector3)stream.ReceiveNext();

            float lag = Mathf.Abs((float)(PhotonNetwork.Time - info.SentServerTime));
            globalNetworkPosition += globalDirection * lag;
            localNetworkPosition  += localDirection * lag;

            globalDistance = Vector3.Distance(transform.position, globalNetworkPosition);
            globalAngle    = Quaternion.Angle(transform.rotation, globalNetworkRotation);
            localDistance  = Vector3.Distance(avatar.transform.localPosition, localNetworkPosition);
            localAngle     = Quaternion.Angle(avatar.transform.localRotation, localNetworkRotation);
        }
    }
コード例 #39
0
        /// <summary>
        /// Called by Photon if a network message is serialized or deserialized
        /// The function is only called if the GameObject also has a PhotonView component where this component is registered
        /// </summary>
        /// <param name="stream">The network stream</param>
        /// <param name="info">Information about the network message</param>
        public virtual void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
        {
            // if we are writing to the stream => we are the local player and want to transmit our position and rotations
            if (stream.IsWriting)
            {
                if (timeSinceLastSearch > handSearchInterval)
                {
                    SearchHands();
                }

                // send the position and euler rotation of the camera
                stream.SendNext(transform.position);
                stream.SendNext(transform.rotation);
                // send the position and rotation of the left hand
                Vector3 leftHandPosition = EncodeHandPosition(playerLeftHand);
                stream.SendNext(leftHandPosition);
                Quaternion leftHandRotation = EncodeHandRotation(playerLeftHand);
                stream.SendNext(leftHandRotation);
                // send the position and rotation of the right hand
                Vector3 rightHandPosition = EncodeHandPosition(playerRightHand);
                stream.SendNext(rightHandPosition);
                Quaternion rightHandRotation = EncodeHandRotation(playerRightHand);
                stream.SendNext(rightHandRotation);
            }
            else // we are reading the network stream, i.e. we receive a remote player position and rotation
            {
                // get the position and rotation of the remote player's camera
                targetPosition = (Vector3)stream.ReceiveNext();
                targetRotation = (Quaternion)stream.ReceiveNext();
                // get the position of the left hand
                leftHandTargetPosition = (Vector3)stream.ReceiveNext();
                leftHandTargetRotation = (Quaternion)stream.ReceiveNext();
                // get the position of the right hand
                rightHandTargetPosition = (Vector3)stream.ReceiveNext();
                rightHandTargetRotation = (Quaternion)stream.ReceiveNext();
            }
        }
コード例 #40
0
ファイル: NPCController.cs プロジェクト: cgi4u/FindTheTheif
        public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
        {
            if (stream.isWriting)
            {
                stream.SendNext(Activated);

                stream.SendNext(startPoint);
                stream.SendNext(targetPoint);
                stream.SendNext(direction);

                stream.SendNext(isMoving);
                stream.SendNext(blockedTime);

                //stream.SendNext(curFloor);
                //stream.SendNext(prevRoom);
                //stream.SendNext(nextRoom);

                //stream.SendNext(transform.position);
            }
            else
            {
                Activated = (bool)stream.ReceiveNext();

                startPoint  = (Vector2)stream.ReceiveNext();
                targetPoint = (Vector2)stream.ReceiveNext();
                direction   = (Vector2)stream.ReceiveNext();

                isMoving    = (bool)stream.ReceiveNext();
                blockedTime = (float)stream.ReceiveNext();

                //curFloor = (int)stream.ReceiveNext();
                //prevRoom = (int)stream.ReceiveNext();
                //nextRoom = (int)stream.ReceiveNext();

                //transform.position = (Vector3)stream.ReceiveNext();
            }
        }
コード例 #41
0
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)
     {
         // We own this player: send the others our data
         connected = true;
         stream.SendNext(connected);
         stream.SendNext(transform.position);
         stream.SendNext(transform.rotation);
         stream.SendNext(HealthLevel);
         stream.SendNext(PlayerName);
         stream.SendNext(PlayerScore);
     }
     else
     {
         // Network player, receive data
         connected             = (bool)stream.ReceiveNext();
         this.correctPlayerPos = (Vector3)stream.ReceiveNext();
         this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
         HealthLevel           = (float)stream.ReceiveNext();
         PlayerName            = (string)stream.ReceiveNext();
         PlayerScore           = (int)stream.ReceiveNext();
     }
 }
コード例 #42
0
 /// 포톤 직렬화
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     //자동차의 정보를 전송
     if (stream.isWriting)
     {
         stream.SendNext((float)carInput.steer);
         stream.SendNext((float)carInput.accel);
         stream.SendNext((float)carInput.handbreak);
         stream.SendNext(transform.position);
         stream.SendNext(transform.rotation);
         stream.SendNext(rb.velocity);
     }
     //상대의 정보를 수신
     else
     {
         carInput.steer     = (float)stream.ReceiveNext();
         carInput.accel     = (float)stream.ReceiveNext();
         carInput.handbreak = (float)stream.ReceiveNext();
         correctPlayerPos   = (Vector3)stream.ReceiveNext();
         correctPlayerRot   = (Quaternion)stream.ReceiveNext();
         currentVelocity    = (Vector3)stream.ReceiveNext();
         updateTime         = Time.time;
     }
 }
コード例 #43
0
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     //sync IsReady, Mutable
     //+ Money, product, materials
     //+ Icon
     if (stream.IsWriting)
     {
         stream.SendNext(IsReady);
         stream.SendNext(Mutable);
         stream.SendNext(Director.Money);
         stream.SendNext(Director.Product);
         stream.SendNext(Director.Materials);
         stream.SendNext(IconNum);
     }
     else
     {
         IsReady            = (bool)stream.ReceiveNext();
         Mutable            = (bool)stream.ReceiveNext();
         Director.Money     = (int)stream.ReceiveNext();
         Director.Product   = (int)stream.ReceiveNext();
         Director.Materials = (int)stream.ReceiveNext();
         SetIcon((int)stream.ReceiveNext());
     }
 }
コード例 #44
0
 /// At each synchronization frame, sends/receives player input, position
 /// and rotation data to/from peers/owner
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)
     {
         // we own this car: send the others our input and transform data
         stream.SendNext((float)carInput.Steer);
         stream.SendNext((float)carInput.Accell);
         stream.SendNext((float)carInput.Handbrake);
         stream.SendNext(physicsBody.transform.position);
         stream.SendNext(physicsBody.transform.rotation);
         stream.SendNext(rb.velocity);
     }
     else
     {
         // remote car, receive data
         carInput.Steer     = (float)stream.ReceiveNext();
         carInput.Accell    = (float)stream.ReceiveNext();
         carInput.Handbrake = (float)stream.ReceiveNext();
         correctPlayerPos   = (Vector3)stream.ReceiveNext();
         correctPlayerRot   = (Quaternion)stream.ReceiveNext();
         currentVelocity    = (Vector3)stream.ReceiveNext();
         updateTime         = Time.time;
     }
 }
コード例 #45
0
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)
     {
         stream.SendNext((float)CarControl.Hinput);
         stream.SendNext((float)CarControl.Vinput);
         stream.SendNext(rb.velocity);
         stream.SendNext(transform.position);
         stream.SendNext(transform.rotation);
         stream.SendNext(topGun.transform.rotation);
     }
     else
     {
         CarControl.Hinput = (float)stream.ReceiveNext();
         CarControl.Vinput = (float)stream.ReceiveNext();
         correctPlayerPos  = (Vector3)stream.ReceiveNext();
         correctPlayerRot  = (Quaternion)stream.ReceiveNext();
         currentVelocity   = (Vector3)stream.ReceiveNext();
         updateTime        = Time.time;
         //internetPosition = (Vector3)stream.ReceiveNext();
         //internetRotation = (Quaternion)stream.ReceiveNext();
         internetTopGunRotation = (Quaternion)stream.ReceiveNext();
     }
 }
コード例 #46
0
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)
     {
         // We own this player: send the others our data
         IArmModelVisualProvider armModelVisual = armModel as IArmModelVisualProvider;
         stream.SendNext(armModelVisual.ShoulderPosition);
         stream.SendNext(armModelVisual.ElbowPosition);
         stream.SendNext(armModelVisual.WristPosition);
         stream.SendNext(armModelVisual.ShoulderRotation);
         stream.SendNext(armModelVisual.ElbowRotation);
         stream.SendNext(armModelVisual.WristRotation);
     }
     else
     {
         // Network player, receive data
         correctShoulderPos      = (Vector3)stream.ReceiveNext();
         correctElbowPos         = (Vector3)stream.ReceiveNext();
         correctWristPos         = (Vector3)stream.ReceiveNext();
         correctShoulderRotation = (Quaternion)stream.ReceiveNext();
         correctElbowRotation    = (Quaternion)stream.ReceiveNext();
         correctWristRotation    = (Quaternion)stream.ReceiveNext();
     }
 }
コード例 #47
0
 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
     if (stream.isWriting)
     {
         //// We own this player: send the others our data
         stream.SendNext(Health);
         stream.SendNext(Ammo);
         stream.SendNext(myID);
         stream.SendNext(Damage);
         stream.SendNext(myCurrGun);
         stream.SendNext(isInvincible);
     }
     else
     {
         //// Network player, receive data
         //this.IsFiring = (bool)stream.ReceiveNext();
         this.Health       = (float)stream.ReceiveNext();
         this.Ammo         = (int)stream.ReceiveNext();
         this.myID         = (int)stream.ReceiveNext();
         this.Damage       = (int)stream.ReceiveNext();
         this.myCurrGun    = (int)stream.ReceiveNext();
         this.isInvincible = (bool)stream.ReceiveNext();
     }
 }
コード例 #48
0
ファイル: Entity.cs プロジェクト: VeraGerritse/DangerDwarves
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            stream.SendNext(health.isImmortal);
            stream.SendNext(health.isInvinsible);
            stream.SendNext(health.isDead);
            stream.SendNext(health.currentHealth);

            stream.SendNext(stats.DefenseEffectiveness);
            stream.SendNext(stats.DamageEffectiveness);

            stream.SendNext(stats.stamina);
            stream.SendNext(stats.strength);
            stream.SendNext(stats.agility);
            stream.SendNext(stats.willpower);
            stream.SendNext(stats.defense);
        }
        else
        {
            health.isImmortal    = (bool)stream.ReceiveNext();
            health.isInvinsible  = (bool)stream.ReceiveNext();
            health.isDead        = (bool)stream.ReceiveNext();
            health.currentHealth = (int)stream.ReceiveNext();

            stats.DefenseEffectiveness = (float)stream.ReceiveNext();
            stats.DamageEffectiveness  = (float)stream.ReceiveNext();

            stats.stamina   = (int)stream.ReceiveNext();
            stats.strength  = (int)stream.ReceiveNext();
            stats.agility   = (int)stream.ReceiveNext();
            stats.willpower = (int)stream.ReceiveNext();
            stats.defense   = (int)stream.ReceiveNext();
        }
    }
コード例 #49
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            if (PhotonNetwork.LocalPlayer.IsLocal)
            {
                stream.SendNext(isPepe);
                stream.SendNext(shield);
                stream.SendNext(cloak);
                if (!isPepe)
                {
                    stream.SendNext(skinIndex);
                    model.material = terminal.Skins[skinIndex];
                    getMat.UpdateMaterial(terminal.Skins[skinIndex]);
                }

                else
                {
                    model.material = terminal.SecretSkin;
                    getMat.UpdateMaterial(terminal.SecretSkin);
                }
                if (cloak)
                {
                    model.material = pckm.CloakShader;
                }
                if (shield)
                {
                    model.material = pckm.ForceFieldShader;
                }
            }
        }
        else
        {
            if (PhotonNetwork.LocalPlayer.IsLocal)
            {
                isPepe = (bool)stream.ReceiveNext();
                shield = (bool)stream.ReceiveNext();
                cloak  = (bool)stream.ReceiveNext();
                if (!isPepe)
                {
                    skinIndex = (int)stream.ReceiveNext();
                }
                if (!isPepe)
                {
                    if (model.material != terminal.Skins[skinIndex])
                    {
                        model.material = terminal.Skins[skinIndex];
                        getMat.UpdateMaterial(terminal.Skins[skinIndex]);
                    }
                }
                else if (isPepe)
                {
                    model.material = terminal.SecretSkin;
                    getMat.UpdateMaterial(terminal.SecretSkin);
                }
                if (cloak)
                {
                    model.material = pckm.CloakShader;
                }
                if (shield)
                {
                    model.material = pckm.ForceFieldShader;
                }
            }
        }
    }
コード例 #50
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            if (this.m_SynchronizePosition)
            {
                this.m_Direction      = transform.position - this.m_StoredPosition;
                this.m_StoredPosition = transform.position;
                stream.SendNext(new Vector3(transform.position.x, transform.position.y, fixPositionZ));
                stream.SendNext(this.m_Direction);
            }

            if (this.m_SynchronizeRotation)
            {
                stream.SendNext(transform.rotation);
            }

            if (this.m_SynchronizeScale)
            {
                stream.SendNext(transform.localScale);
            }
        }
        else
        {
            if (this.m_SynchronizePosition)
            {
                this.m_NetworkPosition = (Vector3)stream.ReceiveNext();
                this.m_Direction       = (Vector3)stream.ReceiveNext();

                if (m_firstTake)
                {
                    transform.position = this.m_NetworkPosition;
                    this.m_Distance    = 0f;
                }
                else
                {
                    float lag = Mathf.Abs((float)(PhotonNetwork.Time - info.SentServerTime));
                    this.m_NetworkPosition += this.m_Direction * lag;
                    this.m_Distance         = Vector3.Distance(transform.position, this.m_NetworkPosition);
                    if (this.m_Distance > 30)
                    {
                        transform.position = m_NetworkPosition;
                    }
                }
                // float lag = Mathf.Abs((float)(PhotonNetwork.Time - info.SentServerTime));
                // this.m_NetworkPosition += this.m_Direction * lag;
                // this.m_Distance = Vector3.Distance(transform.position, this.m_NetworkPosition);
            }

            if (this.m_SynchronizeRotation)
            {
                this.m_NetworkRotation = (Quaternion)stream.ReceiveNext();

                if (m_firstTake)
                {
                    this.m_Angle       = 0f;
                    transform.rotation = this.m_NetworkRotation;
                }
                else
                {
                    this.m_Angle = Quaternion.Angle(transform.rotation, this.m_NetworkRotation);
                }
            }

            if (this.m_SynchronizeScale)
            {
                transform.localScale = (Vector3)stream.ReceiveNext();
            }

            if (m_firstTake)
            {
                m_firstTake = false;
            }
        }
    }
コード例 #51
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        inputByte = 0;
        if (stream.isWriting)
        {
            if (movemantController.verticalMove != 0)
            {
                inputByte = SetBitInByte(inputByte, 1, true);
                if (movemantController.verticalMove > 0)
                {
                    inputByte = SetBitInByte(inputByte, 2, true);
                }
            }

            if (movemantController.horizontalMove != 0)
            {
                inputByte = SetBitInByte(inputByte, 5, true);
                if (movemantController.horizontalMove > 0)
                {
                    inputByte = SetBitInByte(inputByte, 6, true);
                }
            }

            stream.SendNext(statController.health.value);
            stream.SendNext(statController.mana.value);
            stream.SendNext(transform.position);
            stream.SendNext(inputByte);
        }
        else
        {
            statController.health.value = (float)stream.ReceiveNext();
            statController.mana.value   = (float)stream.ReceiveNext();
            correctCharacterPosition    = (Vector3)stream.ReceiveNext();

            inputByte = (byte)stream.ReceiveNext();

            hasInputVertical = GetBitValue(inputByte, 1);
            if (hasInputVertical)
            {
                inputVertical = GetBitValue(inputByte, 2) == true ? 1 : -1;
            }
            else
            {
                inputVertical = 0;
            }

            hasInputHorizontal = GetBitValue(inputByte, 5);
            if (GetBitValue(inputByte, 5))
            {
                inputHorizontal = GetBitValue(inputByte, 6) == true ? 1 : -1;
            }
            else
            {
                inputHorizontal = 0;
            }

            if (movemantCheatDetection != null)
            {
                movemantCheatDetection.SetNext(correctCharacterPosition);
            }

            movemantController.SetMovemant(inputVertical, inputHorizontal, statController.stats.speed);
            StartPositionLerping();
        }
    }
コード例 #52
0
    internal protected void SerializeComponent(Component component, PhotonStream stream, PhotonMessageInfo info)
    {
        if (component == null)
        {
            return;
        }

        if (component is MonoBehaviour)
        {
            ExecuteComponentOnSerialize(component, stream, info);
        }
        else if (component is Transform)
        {
            Transform trans = (Transform)component;

            switch (onSerializeTransformOption)
            {
            case OnSerializeTransform.All:
                stream.SendNext(trans.localPosition);
                stream.SendNext(trans.localRotation);
                stream.SendNext(trans.localScale);
                break;

            case OnSerializeTransform.OnlyPosition:
                stream.SendNext(trans.localPosition);
                break;

            case OnSerializeTransform.OnlyRotation:
                stream.SendNext(trans.localRotation);
                break;

            case OnSerializeTransform.OnlyScale:
                stream.SendNext(trans.localScale);
                break;

            case OnSerializeTransform.PositionAndRotation:
                stream.SendNext(trans.localPosition);
                stream.SendNext(trans.localRotation);
                break;
            }
        }
        else if (component is Rigidbody)
        {
            Rigidbody rigidB = (Rigidbody)component;

            switch (onSerializeRigidBodyOption)
            {
            case OnSerializeRigidBody.All:
                stream.SendNext(rigidB.velocity);
                stream.SendNext(rigidB.angularVelocity);
                break;

            case OnSerializeRigidBody.OnlyAngularVelocity:
                stream.SendNext(rigidB.angularVelocity);
                break;

            case OnSerializeRigidBody.OnlyVelocity:
                stream.SendNext(rigidB.velocity);
                break;
            }
        }
        else if (component is Rigidbody2D)
        {
            Rigidbody2D rigidB = (Rigidbody2D)component;

            switch (onSerializeRigidBodyOption)
            {
            case OnSerializeRigidBody.All:
                stream.SendNext(rigidB.velocity);
                stream.SendNext(rigidB.angularVelocity);
                break;

            case OnSerializeRigidBody.OnlyAngularVelocity:
                stream.SendNext(rigidB.angularVelocity);
                break;

            case OnSerializeRigidBody.OnlyVelocity:
                stream.SendNext(rigidB.velocity);
                break;
            }
        }
        else
        {
            Debug.LogError("Observed type is not serializable: " + component.GetType());
        }
    }
コード例 #53
0
ファイル: PlayerStats.cs プロジェクト: mosheepdev/mobastorm
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    //void uLink_OnSerializeNetworkView (uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        // Always send transform (depending on reliability of the network view)
        if (stream.isWriting)
        {
            stream.SendNext(networkOwner);
            stream.SendNext(gameObject.name);
            stream.SendNext(myHealth);
            stream.SendNext(maxHealth);
            stream.SendNext(healthRegenerate);
            stream.SendNext(mana);
            stream.SendNext(baseMana);
            stream.SendNext(rechargeRateMana);
            stream.SendNext(playerTeam);
            stream.SendNext(playerScore);
            stream.SendNext(playerLvl);
            stream.SendNext(playerExp);
            stream.SendNext(maxPlayerExp);
            stream.SendNext(kills);
            stream.SendNext(deaths);
            stream.SendNext(assist);
            stream.SendNext(gold);
            stream.SendNext(rechargeRateGold);

            if (isPlayer)
            {
                stream.SendNext(destroyed);
                stream.SendNext(playerLvl);
                stream.SendNext(stats.basic.ad);
                stream.SendNext(stats.basic.ad);
                stream.SendNext(adRes);
                stream.SendNext(apRes);
                stream.SendNext(_adValueAdd);
                stream.SendNext(_apValueAdd);
                stream.SendNext(adResAdd);
                stream.SendNext(apResAdd);
                stream.SendNext(speed);
                stream.SendNext(speedAdd);
                stream.SendNext(attackRedAdd);
            }
        }
        else
        {
            networkOwner     = (PhotonPlayer)stream.ReceiveNext();
            gameObject.name  = (string)stream.ReceiveNext();
            myHealth         = (float)stream.ReceiveNext();
            maxHealth        = (float)stream.ReceiveNext();
            healthRegenerate = (float)stream.ReceiveNext();
            mana             = (float)stream.ReceiveNext();
            baseMana         = (float)stream.ReceiveNext();
            rechargeRateMana = (float)stream.ReceiveNext();
            playerTeam       = (string)stream.ReceiveNext();
            playerScore      = (int)stream.ReceiveNext();
            playerLvl        = (int)stream.ReceiveNext();
            playerExp        = (int)stream.ReceiveNext();
            maxPlayerExp     = (int)stream.ReceiveNext();
            kills            = (int)stream.ReceiveNext();
            deaths           = (int)stream.ReceiveNext();
            assist           = (int)stream.ReceiveNext();
            gold             = (float)stream.ReceiveNext();
            rechargeRateGold = (float)stream.ReceiveNext();

            if (isPlayer)
            {
                destroyed      = (bool)stream.ReceiveNext();
                playerLvl      = (int)stream.ReceiveNext();
                stats.basic.ad = (float)stream.ReceiveNext();
                stats.basic.ap = (float)stream.ReceiveNext();
                adRes          = (float)stream.ReceiveNext();
                apRes          = (float)stream.ReceiveNext();
                _adValueAdd    = (float)stream.ReceiveNext();
                _apValueAdd    = (float)stream.ReceiveNext();
                adResAdd       = (float)stream.ReceiveNext();
                apResAdd       = (float)stream.ReceiveNext();
                speed          = (float)stream.ReceiveNext();
                speedAdd       = (float)stream.ReceiveNext();
                attackRedAdd   = (float)stream.ReceiveNext();
            }
        }
    }
コード例 #54
0
ファイル: Player.cs プロジェクト: kwhk94/EldrichHorror
 public void SerializeSend(PhotonStream stream, PhotonMessageInfo info)
 {
     stream.SendNext(hp);
     stream.SendNext(mp);
     stream.SendNext(power);
 }
    /*
     *  Photon stream is a container class that sends and receives data to and from a photo beam.
     */
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        //Stream is a container that sends and recieves data to and from a photon view.
        if (stream.IsWriting)
        {
            //Writing data
            //If this photn view is belonging to me.
            //I am controlling this player. Send position and velocity data to the other player
            stream.SendNext(rb.position - battleArenaGameobject.transform.position);
            stream.SendNext(rb.rotation);

            if (syncVelocity)
            {
                //Send velocity
                stream.SendNext(rb.velocity);
            }

            if (syncAngularVelocity)
            {
                //Send angular velocity
                stream.SendNext(rb.angularVelocity);
            }
        }
        else
        {
            //reading data
            //Player game object which exists in the remote players game
            networkPos      = (Vector3)stream.ReceiveNext() + battleArenaGameobject.transform.position; // also send our arena postion
            networkRotation = (Quaternion)stream.ReceiveNext();

            //if teleport is set to true
            if (isTelePort)
            {
                //if the distance is greater than the teleport value
                if (Vector3.Distance(rb.position, networkPos) > teleport)
                {
                    //Rigid body position is = network position
                    rb.position = networkPos;
                }
            }

            if (syncVelocity || syncAngularVelocity)
            {
                // Lag variable

                /*
                 *  PhotonNetwork.Time is used to syncronise time for all players.
                 *  It is actually the server time though so it is the sem for each client.
                 *  info.SentServerTime is the the time it takes to send the data.
                 *  This is called LAG
                 *
                 */
                float lag = Mathf.Abs((float)(PhotonNetwork.Time - info.SentServerTime));

                if (syncVelocity)
                {
                    //Recevive the velocity
                    rb.velocity = (Vector3)stream.ReceiveNext();

                    //current position is rigis bodys velocity * lag
                    networkPos += rb.velocity * lag;

                    //distance set to the Vector3 distance
                    distance = Vector3.Distance(rb.position, networkPos);
                }

                if (syncAngularVelocity)
                {
                    //Recevive the angualr velocity
                    rb.angularVelocity = (Vector3)stream.ReceiveNext();

                    //current position is rigid bodys angualrvelocity * lag
                    networkRotation = Quaternion.Euler(rb.angularVelocity * lag) * networkRotation;

                    //angle
                    angle = Quaternion.Angle(rb.rotation, networkRotation);
                }
            }
        }
    }
コード例 #56
0
        /// <summary>
        /// Transformをやり取りする
        /// </summary>
        /// <param name="stream">値のやり取りを可能にするストリーム</param>
        /// <param name="info">タイムスタンプ等の細かい情報がやり取り可能</param>
        void IPunObservable.OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
        {
            //何かの初期化が終わってなかったらリターン
            if (_isInitializedBoneL == false || _isInitializedBoneR == false || _isInitializedHandL == false || _isInitializedHandR == false)
            {
                return;
            }

            if (stream.IsWriting)
            {
                //頭
                stream.SendNext(_headVisual.transform.position);
                stream.SendNext(_headVisual.transform.rotation);

                //左手
                stream.SendNext(_leftHandVisual.transform.position);
                stream.SendNext(_leftHandVisual.transform.rotation);

                //ボーンのリストに受け取った値を反映
                foreach (var t in _bonesL)
                {
                    stream.SendNext(t.transform.localRotation);
                }

                //右手
                stream.SendNext(_rightHandVisual.transform.position);
                stream.SendNext(_rightHandVisual.transform.rotation);

                //ボーンのリストに受け取った値を反映
                foreach (var t in _bonesR)
                {
                    stream.SendNext(t.transform.localRotation);
                }
            }
            else
            {
                //頭
                _headVisual.transform.position = (Vector3)stream.ReceiveNext();
                _headVisual.transform.rotation = (Quaternion)stream.ReceiveNext();

                //左手
                _leftHandVisual.transform.position = (Vector3)stream.ReceiveNext();
                _leftHandVisual.transform.rotation = (Quaternion)stream.ReceiveNext();

                //ボーンのリストに受け取った値を反映
                foreach (var t in _bonesL)
                {
                    t.transform.localRotation = (Quaternion)stream.ReceiveNext();
                }

                //右手
                _rightHandVisual.transform.position = (Vector3)stream.ReceiveNext();
                _rightHandVisual.transform.rotation = (Quaternion)stream.ReceiveNext();

                //ボーンのリストに受け取った値を反映
                foreach (var t in _bonesR)
                {
                    t.transform.localRotation = (Quaternion)stream.ReceiveNext();
                }
            }
        }
コード例 #57
0
 private void WriteStream(PhotonStream stream)
 {
     stream.SendNext(currentLoot);
     stream.SendNext(currentNoise);
 }
コード例 #58
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        var tr = transform;

        // Write
        if (stream.IsWriting)
        {
            if (this.m_SynchronizePosition)
            {
                if (m_UseLocal)
                {
                    this.m_Direction      = tr.localPosition - this.m_StoredPosition;
                    this.m_StoredPosition = tr.localPosition;
                    stream.SendNext(tr.localPosition);
                    stream.SendNext(this.m_Direction);
                }
                else
                {
                    this.m_Direction      = tr.position - this.m_StoredPosition;
                    this.m_StoredPosition = tr.position;
                    stream.SendNext(tr.position);
                    stream.SendNext(this.m_Direction);
                }
            }

            if (this.m_SynchronizeRotation)
            {
                if (m_UseLocal)
                {
                    stream.SendNext(tr.localRotation);
                }
                else
                {
                    stream.SendNext(tr.rotation);
                }
            }

            if (this.m_SynchronizeScale)
            {
                stream.SendNext(tr.localScale);
            }

            stream.SendNext(nameTextField.text);
            stream.SendNext(ColorUtility.ToHtmlStringRGB(rend[0].material.color));
            stream.SendNext(isHandRaised);
            stream.SendNext(isTeacher);
        }
        // Read
        else
        {
            if (this.m_SynchronizePosition)
            {
                this.m_NetworkPosition = (Vector3)stream.ReceiveNext();
                this.m_Direction       = (Vector3)stream.ReceiveNext();

                if (m_firstTake)
                {
                    if (m_UseLocal)
                    {
                        tr.localPosition = this.m_NetworkPosition;
                    }
                    else
                    {
                        tr.position = this.m_NetworkPosition;
                    }

                    this.m_Distance = 0f;
                }
                else
                {
                    float lag = Mathf.Abs((float)(PhotonNetwork.Time - info.SentServerTime));
                    this.m_NetworkPosition += this.m_Direction * lag;
                    if (m_UseLocal)
                    {
                        this.m_Distance = Vector3.Distance(tr.localPosition, this.m_NetworkPosition);
                    }
                    else
                    {
                        this.m_Distance = Vector3.Distance(tr.position, this.m_NetworkPosition);
                    }
                }
            }

            if (this.m_SynchronizeRotation)
            {
                this.m_NetworkRotation = (Quaternion)stream.ReceiveNext();

                if (m_firstTake)
                {
                    this.m_Angle = 0f;

                    if (m_UseLocal)
                    {
                        tr.localRotation = this.m_NetworkRotation;
                    }
                    else
                    {
                        tr.rotation = this.m_NetworkRotation;
                    }
                }
                else
                {
                    if (m_UseLocal)
                    {
                        this.m_Angle = Quaternion.Angle(tr.localRotation, this.m_NetworkRotation);
                    }
                    else
                    {
                        this.m_Angle = Quaternion.Angle(tr.rotation, this.m_NetworkRotation);
                    }
                }
            }

            if (this.m_SynchronizeScale)
            {
                tr.localScale = (Vector3)stream.ReceiveNext();
            }

            if (m_firstTake)
            {
                m_firstTake = false;
            }


            nameString   = (string)stream.ReceiveNext();
            colorString  = (string)stream.ReceiveNext();
            isHandRaised = (bool)stream.ReceiveNext();
            isTeacher    = (bool)stream.ReceiveNext();
        }
    }
コード例 #59
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        Debug.Log("DBWORK UPDATES!");
//   if (stream.isWriting)
//   {
//       NetworkStreetPath[] paths = _dBwork.GetAllPaths();
//       stream.SendNext(paths.Length);
//
//       foreach (NetworkStreetPath networkStreetPath in paths)
//       {
//           stream.SendNext(networkStreetPath.GetIdStreetPath());
//           stream.SendNext(networkStreetPath.GetIdStreetParent());
//           stream.SendNext(networkStreetPath.GetRenta());
//           stream.SendNext(networkStreetPath.start);
//           stream.SendNext(networkStreetPath.end);
//           stream.SendNext(networkStreetPath.isBridge);
//           stream.SendNext(networkStreetPath.NeighborsId);
//           stream.SendNext(networkStreetPath.NamePath);
//           stream.SendNext(networkStreetPath.CanBuy);
//           stream.SendNext(networkStreetPath.GetNameOfPrefab());
//
//       }
//
//       List<NetworkPathForBuy> pathForBuys = _dBwork.GetAllPathForBuys();
//
//        stream.SendNext(pathForBuys.Count);
//       foreach (NetworkPathForBuy pathForBuy in pathForBuys)
//       {
//           stream.SendNext(pathForBuy.GetIdStreetPath());
//           stream.SendNext(pathForBuy.IdPlayer);
//           stream.SendNext(pathForBuy.Builds);
//           stream.SendNext(pathForBuy.PriceStreetPath);
//           stream.SendNext(pathForBuy.IsBlocked);
//       }
//
//       List<NetworkGovermentPath> govermentPaths = _dBwork.GetAllGovermentPaths();
//       stream.SendNext(govermentPaths.Count);
//
//       foreach (NetworkGovermentPath govermentPath in govermentPaths)
//       {
//           stream.SendNext(govermentPath.GetIdStreetPath());
//           Event[] events = govermentPath.events;
//           stream.SendNext(events.Length);
//           foreach (Event eve in events)
//           {
//               if (eve != null)
//               {
//                   stream.SendNext(eve.Id);
//                   stream.SendNext(eve.Info);
//                   stream.SendNext(eve.Name);
//                   stream.SendNext(eve.Price);
//               }
//               else
//               {
//                   stream.SendNext(0);
//               }
//
//           }
//       }
//
//       NetworkStreet[] streets = _dBwork.GetAllStreets();
//
//       stream.SendNext(streets.Length);
//
//       foreach (NetworkStreet street in streets)
//       {
//           stream.SendNext(street.IdStreet);
//           stream.SendNext(street.NameStreet);
//           stream.SendNext(street.AboutStreet);
//           stream.SendNext(street.Paths);
//       }
//
//       NetworkBuild[] builds = _dBwork.GetAllBuilds();
//       stream.SendNext(builds.Length);
//       foreach (NetworkBuild build in builds)
//       {
//           stream.SendNext(build.IdBuild);
//           stream.SendNext(build.NameBuild);
//           stream.SendNext(build.AboutBuild);
//           stream.SendNext(build.IdStreetPath);
//           stream.SendNext(build.PriceBuild);
//           stream.SendNext(build.Enable);
//           stream.SendNext(build.Place);
//       }
//
//       NetworkPlayer[] players = _dBwork.GetAllPlayers();
//       stream.SendNext(players.Length);
//       foreach (NetworkPlayer networkPlayer in players)
//       {
//           stream.SendNext(networkPlayer.IdPlayer);
//           stream.SendNext(networkPlayer.ViewId);
//           stream.SendNext(networkPlayer.NickName);
//           stream.SendNext(networkPlayer.Money);
//           stream.SendNext(networkPlayer.MaxSteps);
//           stream.SendNext(networkPlayer.CurrentSteps);
//           stream.SendNext(networkPlayer.IsBankrupt);
//           stream.SendNext(networkPlayer.Destination);
//           stream.SendNext(networkPlayer.CurrentStreetPath.GetIdStreetPath());
//           stream.SendNext(networkPlayer.isBot);
//
//       }
//   }
//   else
//   {
//       Debug.Log("DBWORK UPDATES!");
//
//       NetworkStreetPath[] paths = new NetworkStreetPath[(int)stream.ReceiveNext()];
//       for (int i = 0; i < paths.Length; i++)
//       {
//           int pathId = (int)stream.ReceiveNext();
//           int parentId = (int) stream.ReceiveNext();
//           int renta = (int) stream.ReceiveNext();
//           Vector3 start = (Vector3) stream.ReceiveNext();
//           Vector3 end = (Vector3) stream.ReceiveNext();
//           bool isBridge = (bool) stream.ReceiveNext();
//           int[] neighbours = (int[]) stream.ReceiveNext();
//           string namePath = (string) stream.ReceiveNext();
//           bool canBuy = (bool) stream.ReceiveNext();
//           string nameOfPref = (string) stream.ReceiveNext();
//
//           paths[i] = new NetworkStreetPath(pathId,namePath, parentId, renta, start, end, isBridge, nameOfPref);
//           paths[i].neighborsId = neighbours;
//           paths[i].CanBuy = canBuy;
//       }
//
//       List<NetworkPathForBuy> pathForBuys = new List<NetworkPathForBuy>();
//       int count = (int)stream.ReceiveNext();
//
//       Debug.Log("DBWORK UPDATES!");
//       for (int i=0; i < count; i++)
//       {
//           int id = (int) stream.ReceiveNext();
//           NetworkStreetPath path = paths[id];
//           int owmerId = (int) stream.ReceiveNext();
//           int[] buildes = (int[]) stream.ReceiveNext();
//           int price = (int) stream.ReceiveNext();
//           bool isBlocked = (bool) stream.ReceiveNext();
//
//           pathForBuys.Add(new NetworkPathForBuy(id,path.NamePath,path.GetIdStreetParent(), path.GetRenta(), path.start, path.end, owmerId, buildes, price, path.isBridge,path.GetNameOfPrefab(),isBlocked));
//       }
//
//
//
//       List<NetworkGovermentPath> govermentPaths = new List<NetworkGovermentPath>();
//       count = (int) stream.ReceiveNext();
//
//       for (int i=0; i < count; i++)
//       {
//           int id = (int) stream.ReceiveNext();
//           NetworkStreetPath path = paths[id];
//
//           int countEvent = (int) stream.ReceiveNext();
//           Event[] eves = new Event[countEvent];
//           for (int j = 0; j < countEvent; j++)
//           {
//               int eId = (int) stream.ReceiveNext();
//               if (eId == 0)
//               {
//                   eves[i] = null;
//               }
//               else
//               {
//                   string eInfo = (string) stream.ReceiveNext();
//                   string eName = (string) stream.ReceiveNext();
//                   int ePrice = (int) stream.ReceiveNext();
//                   eves[i] = new Event(eId, eInfo, eName, ePrice, id);
//               }
//           }
//
//
//           govermentPaths.Add(new NetworkGovermentPath(id,path.NamePath,path.GetIdStreetParent(), path.GetRenta(), path.start, path.end, path.isBridge,path.GetNameOfPrefab(),eves));
//       }
//
//       NetworkStreet[] streets = new NetworkStreet[(int)stream.ReceiveNext()];
//       for (int i = 0; i < streets.Length; i++)
//       {
//           int stId = (int)stream.ReceiveNext();
//           string stName = (string)stream.ReceiveNext();
//           string stAbout = (string)stream.ReceiveNext();
//           int[] stPaths = (int[])stream.ReceiveNext();
//
//           streets[i] = new NetworkStreet(stId,stName,stAbout,stPaths);
//       }
//
//       NetworkBuild[] builds = new NetworkBuild[(int)stream.ReceiveNext()];
//
//       for (int i = 0; i < builds.Length; i++)
//       {
//           int bId = (int)stream.ReceiveNext();
//           string bName = (string)stream.ReceiveNext();
//           string bAbout = (string)stream.ReceiveNext();
//           int bstID = (int)stream.ReceiveNext();
//           int bPrice = (int)stream.ReceiveNext();
//           bool ben = (bool)stream.ReceiveNext();
//           Vector3 bplace = (Vector3) stream.ReceiveNext();
//
//           builds[i] = new NetworkBuild(bId,bName,bAbout,bstID,bPrice,ben,bplace.x, bplace.z);
//       }
//
//       NetworkPlayer[] players = new NetworkPlayer[(int)stream.ReceiveNext()];
//       for (int i = 0; i < players.Length; i++)
//       {
//           int plId = (int)stream.ReceiveNext();
//           int plVId = (int)stream.ReceiveNext();
//           string plName = (string) stream.ReceiveNext();
//           int plMoney = (int) stream.ReceiveNext();
//           bool plBank = (bool)stream.ReceiveNext();
//           Vector3 plDest = (Vector3)stream.ReceiveNext();
//           NetworkStreetPath
//               plPath = pathForBuys[(int) stream.ReceiveNext()];
//           bool plIsBot = (bool) stream.ReceiveNext();
//
//           players[i] = new NetworkPlayer(plId,plName,plMoney,plBank,plIsBot,plDest);
//           players[i].ViewId = plVId;
//
//       }
//
//       object name;
//       PhotonNetwork.room.CustomProperties.TryGetValue("ngame", out name);
//       string nameOfGane = (string) name;
//       PhotonNetwork.room.CustomProperties.TryGetValue("ntown", out name);
//       string nameOfTown = (string) name;
//
//       _dBwork.SetAll(paths,pathForBuys,govermentPaths,streets,builds,players,nameOfGane, nameOfTown);
//       _dBwork.ready = true;
//
//       Debug.Log("DBWORK UPDATES!");
//   }

        if (stream.isWriting)
        {
            if (CurrentPlayer != null)
            {
                stream.SendNext(CurrentPlayer.IdPlayer);
            }
            else
            {
                stream.SendNext(0);
            }

            stream.SendNext(CountStepsInAllGame);
        }
        else
        {
            int id = (int)stream.ReceiveNext();
            if (id != 0)
            {
                CurrentPlayer = _dBwork.GetPlayerbyId(id);
            }



            CountStepsInAllGame = (int)stream.ReceiveNext();
        }
    }
コード例 #60
0
    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            // Sending data over
            stream.SendNext((transform.position.x - -m_HalfDimension.x) / (m_HalfDimension.x * 2.0f));
            stream.SendNext((transform.position.y - -m_HalfDimension.y) / (m_HalfDimension.y * 2.0f));
            stream.SendNext((GetComponent <Link>().Linking));
            stream.SendNext((GetComponent <Link>().LinkType));
        }
        else
        {
            // Receiving data
            float factorX = ( float )stream.ReceiveNext();
            float factorY = ( float )stream.ReceiveNext();

            bool linking  = ( bool )stream.ReceiveNext();
            int  linkType = ( int )stream.ReceiveNext();

            if (linkType != m_Link.LinkType)
            {
                if (linkType == GemSpawner.INVALID_GEM)
                {
                    // Ignore
                }
                else
                {
                    m_Link.ChangeLinkColor(linkType);
                    m_Link.SetLinkOpacity(LINK_ALPHA);

                    m_OtherDustEmitter.startColor = m_Link.GetLinkColor(linkType);
                }
            }

            if (linking != m_Link.Linking)
            {
                if (!linking)
                {
                    m_Link.BreakLink();
                    m_Link.SetLinkOpacity(LINK_ALPHA);

                    m_OtherDustEmitter.startColor = m_Link.GetLinkColor(GemSpawner.INVALID_GEM);
                }
                else
                {
                    m_Link.StartLink();

                    m_OtherDustEmitter.Stop();
                    m_OtherDustEmitter.transform.position = new Vector3(transform.position.x, transform.position.y, 0.0f);
                    m_OtherDustEmitter.Play();
                }
            }

            Vector3 pos = transform.position;
            pos.x = (factorX * m_HalfDimension.x * 2.0f) + -m_HalfDimension.x;
            pos.y = (factorY * m_HalfDimension.y * 2.0f) + -m_HalfDimension.y;
            transform.position = pos;

            m_OtherDustEmitter.transform.position = new Vector3(pos.x, pos.y, 0.0f);
        }
    }