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


C# PhotonStream.SendNext方法代码示例

本文整理汇总了C#中PhotonStream.SendNext方法的典型用法代码示例。如果您正苦于以下问题:C# PhotonStream.SendNext方法的具体用法?C# PhotonStream.SendNext怎么用?C# PhotonStream.SendNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhotonStream的用法示例。


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

示例1: OnPhotonSerializeView

    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();
            }
        }
    }
开发者ID:acimbru,项目名称:licenta,代码行数:32,代码来源:ProjectileNetwork.cs

示例2: OnPhotonSerializeView

    //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


        }
    }
开发者ID:hamza765,项目名称:Kelpie5,代码行数:28,代码来源:DroneNetworkMover.cs

示例3: OnPhotonSerializeView

    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");
        }
    }
开发者ID:chocopuyo,项目名称:photon_invador,代码行数:29,代码来源:NewNetworkCharacter.cs

示例4: OnPhotonSerializeView

    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;
        }
    }
开发者ID:azanium,项目名称:TruthNIslam-Unity,代码行数:29,代码来源:RemotePlayer.cs

示例5: OnPhotonSerializeView

    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;

                        }
                }
    }
开发者ID:arslanyilmaz,项目名称:GMOST,代码行数:35,代码来源:NetworkCharacter.cs

示例6: OnPhotonSerializeView

	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;

        }
    }
开发者ID:Pecke123,项目名称:Genesis_Unknown,代码行数:28,代码来源:NetworkCharacter.cs

示例7: OnPhotonSerializeView

    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;
        }
    }
开发者ID:Ckeds,项目名称:PortfolioWorks,代码行数:25,代码来源:NetworkSync.cs

示例8: OnPhotonSerializeView

    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();
        }
    }
开发者ID:micha224,项目名称:Jan_1GAM,代码行数:27,代码来源:NetworkMovement.cs

示例9: OnPhotonSerializeView

    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();

        }
    }
开发者ID:jordanepickett,项目名称:RPG,代码行数:35,代码来源:NetworkCharacter.cs

示例10: OnPhotonSerializeView

    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;
            }
        }
    }
开发者ID:sharkbound,项目名称:Unity-Projects,代码行数:32,代码来源:NetworkPlayer.cs

示例11: OnPhotonSerializeView

        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();
            }
        }
开发者ID:Vince-Bitheads,项目名称:UnityExamples,代码行数:29,代码来源:PlaneController.cs

示例12: OnPhotonSerializeView

	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;  
			}
		}
	}
开发者ID:reaganq,项目名称:MagnetBots_unity,代码行数:25,代码来源:NetworkCharacterMovement.cs

示例13: OnPhotonSerializeView

    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;
            }
        }
    }
开发者ID:Avatarchik,项目名称:FPS_Multiplayer_Game,代码行数:29,代码来源:NetworkCharacter.cs

示例14: OnPhotonSerializeView

    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;
            }
        }
    }
开发者ID:jkwendorf,项目名称:ProjectHERO,代码行数:26,代码来源:NetCharacter.cs

示例15: OnPhotonSerializeView

    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;
            }

        }
    }
开发者ID:Goodyjake,项目名称:zombinc,代码行数:32,代码来源:NetworkCharacter.cs


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