• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PhotonMessageInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PhotonMessageInfo的典型用法代码示例。如果您正苦于以下问题:C# PhotonMessageInfo类的具体用法?C# PhotonMessageInfo怎么用?C# PhotonMessageInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PhotonMessageInfo类属于命名空间,在下文中一共展示了PhotonMessageInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: 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


示例2: 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


示例3: OnPhotonSerializeView

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


示例4: OnPhotonSerializeView

    // this method is called by PUN when this script is being "observed" by a PhotonView (setup in inspector)
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        // Always send transform (depending on reliability of the network view)
        if (stream.isWriting)
        {
            Vector3 pos = transform.localPosition;
            Quaternion rot = transform.localRotation;
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
        }
        // When receiving, buffer the information
        else
        {
            // Receive latest state information
            Vector3 pos = Vector3.zero;
            Quaternion rot = Quaternion.identity;
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);

            lastMovement = (pos - latestCorrectPos) / (Time.time - lastTime);

            lastTime = Time.time;
            latestCorrectPos = pos;

            transform.position = latestCorrectPos;
        }
    }
开发者ID:dgolman,项目名称:Cardboard-Multiplayer,代码行数:28,代码来源:CubeExtra.cs


示例5: OnPhotonSerializeView

    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;
            }
        }
    }
开发者ID:patricio272,项目名称:VoxelVR,代码行数:28,代码来源:BulletNetwork.cs


示例6: OnPhotonSerializeView

    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            Vector3 pos = transform.localPosition;
            Quaternion rot = transform.localRotation;
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
        }
        else
        {
            // Receive latest state information
            Vector3 pos = Vector3.zero;
            Quaternion rot = Quaternion.identity;

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

            this.latestCorrectPos = pos;                // save this to move towards it in FixedUpdate()
            this.onUpdatePos = transform.localPosition; // we interpolate from here to latestCorrectPos
            this.fraction = 0;                          // reset the fraction we alreay moved. see Update()

            transform.localRotation = rot;              // this sample doesn't smooth rotation
        }
    }
开发者ID:apekshadarbari,项目名称:PokerFace,代码行数:25,代码来源:CubeLerp.cs


示例7: OnPhotonSerializeView

    /// <summary>
    /// Serializing the photon views
    /// </summary>
    /// <param name="stream"> the stream of information </param>
    /// <param name="info"> information about the messages </param>
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        // if it's us tell them where we are, else it's everyone else telling use where they are
        if (stream.isWriting)
        {
            // send pos stuff
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);

            // send animation stuff
            stream.SendNext(Mathf.Abs(motor.movement.velocity.x));
            stream.SendNext(motor.grounded);

            // Input info
            stream.SendNext(Input.GetButton("Jump"));
            stream.SendNext(Input.GetButtonUp("Fire1"));
        }
        else
        {
            // recieve pos
            realPos = (Vector3)stream.ReceiveNext();
            realRot = (Quaternion)stream.ReceiveNext();

            // receive anim info
            velocity = (float)stream.ReceiveNext();
            onGround = (bool)stream.ReceiveNext();

            // Input info
            jumping = (bool)stream.ReceiveNext();
            shoot = (bool)stream.ReceiveNext();
        }
    }
开发者ID:CraigChilds94,项目名称:ArenaGame,代码行数:37,代码来源:NetworkCharacter.cs


示例8: 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


示例9: OnPhotonSerializeView

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


示例10: OnPhotonSerializeView

	void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
		if(stream.isWriting) {
			stream.SendNext(transform.position);
		} else {
			position = (Vector3)stream.ReceiveNext();
		}
	}
开发者ID:rthill91,项目名称:Independent-Study,代码行数:7,代码来源:NetworkBullet.cs


示例11: OnPhotonInstantiate

    void OnPhotonInstantiate(PhotonMessageInfo msg)
    {
        // This is our own player
        if (photonView.isMine)
        {
            //camera.main.enabled=false;

            localPlayer = true;

            Destroy(GameObject.Find("LevelCamera"));

            Machinegun gun = transform.GetComponentInChildren < Machinegun>();
            gun.localPlayer = true;

        }
        // This is just some remote controlled player, don't execute direct
        // user input on this. DO enable multiplayer controll
        else
        {
            name += msg.sender.name;

            transform.Find("CrateCamera").gameObject.active = false;

            FPSWalker4 tmp2 = GetComponent<FPSWalker4>() as FPSWalker4;
            tmp2.enabled = false;
            MouseLook tmp5 = GetComponent<MouseLook>() as MouseLook;
            tmp5.enabled = false;
        }
    }
开发者ID:pisipo,项目名称:PUNProja,代码行数:29,代码来源:PlayerScript.cs


示例12: OnPhotonSerializeView

    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            Vector3 pos = transform.localPosition;
            Quaternion rot = transform.localRotation;

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

        }
        else
        {

            Vector3 pos = Vector3.zero;
            Quaternion rot = Quaternion.identity;

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

            latestCorrectPos = pos;
            onUpdatePos = transform.localPosition;
            fraction = 0;

            transform.localRotation = rot;
        }
    }
开发者ID:houseofkohina,项目名称:ProjectDoge,代码行数:27,代码来源:Projectile.cs


示例13: OnPhotonSerializeView

    // this method is called by PUN when this script is being "observed" by a PhotonView (setup in inspector)
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            // the controlling player of a cube sends only the position
            Vector3 pos = transform.localPosition;
            stream.Serialize(ref pos);
        }
        else
        {
            // other players (not controlling this cube) will read the position and timing and calculate everything else based on this
            Vector3 updatedLocalPos = Vector3.zero;
            stream.Serialize(ref updatedLocalPos);

            double timeDiffOfUpdates = info.timestamp - this.lastTime;  // the time that passed after the sender sent it's previous update
            this.lastTime = info.timestamp;


            // the movementVector calculates how far the "original" cube moved since it sent the last update.
            // we calculate this based on the sender's timing, so we exclude network lag. that makes our movement smoother.
            this.movementVector = (updatedLocalPos - this.latestCorrectPos) / (float)timeDiffOfUpdates;

            // the errorVector is how far our cube is away from the incoming position update. using this corrects errors somewhat, until the next update arrives.
            // with this, we don't have to correct our cube's position with a new update (which introduces visible, hard stuttering).
            this.errorVector = (updatedLocalPos - transform.localPosition) / (float)timeDiffOfUpdates;

            
            // next time we get an update, we need this update's position:
            this.latestCorrectPos = updatedLocalPos;
        }
    }
开发者ID:CanPayU,项目名称:SuperSwungBall,代码行数:32,代码来源:CubeExtra.cs


示例14: 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


示例15: 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


示例16: 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


示例17: SerializeState

	public void SerializeState( PhotonStream stream, PhotonMessageInfo info )
	{
//		Debug.Log ("Serialized State");
		//We only need to synchronize a couple of variables to be able to recreate a good
		//approximation of the ships position on each client
		//There is a lot of smoke and mirrors happening here
		//Check out Part 1 Lesson 2 http://youtu.be/7hWuxxm6wsA for more detailed explanations
		if( stream.isWriting == true )
		{
			Vector3 pos = transform.position;
			Quaternion rot = transform.rotation;
			stream.SendNext( pos );
			stream.SendNext( rot );
		}
		else
		{
			t=0;
			// achterlopende position naar nieuwe binnenkomende position lerpen
			startPosition = transform.position;
			m_NetworkPosition = (Vector3)stream.ReceiveNext();
			m_NetworkRotation = (Quaternion)stream.ReceiveNext();

			distance = Vector3.Distance(startPosition,m_NetworkPosition);
			time = distance/speed;
			m_LastNetworkDataReceivedTime = info.timestamp;
		}
	}
开发者ID:MiloBuwalda,项目名称:wizard,代码行数:27,代码来源:SpellObserver.cs


示例18: OnPhotonSerializeView

    /// <summary>
    /// serialization method of photon
    /// </summary>
    /// <param name="stream"></param>
    /// <param name="info"></param>
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {

        m_PositionControl.OnPhotonSerializeView(transform.position, stream, info);
        m_RotationControl.OnPhotonSerializeView(transform.rotation, stream, info);
        m_ScaleControl.OnPhotonSerializeView(transform.localScale, stream, info);
        if (isMine == false && m_PositionModel.DrawErrorGizmo == true)
        {
            DoDrawEstimatedPositionError();
        }
        if (stream.isWriting)
        {
            //We own this player: send the others our data
            stream.SendNext(gameObject.name);
            stream.SendNext(HeatTarget.position);
            stream.SendNext(HeatTarget.rotation);
            stream.SendNext(Controller.m_PlayerState);
            stream.SendNext(Controller.grounded);

        }
        else
        {
            //Network player, receive data
            RemotePlayerName = (string)stream.ReceiveNext();
            HeadPos = (Vector3)stream.ReceiveNext();
            HeadRot = (Quaternion)stream.ReceiveNext();
            m_state = (PlayerState)stream.ReceiveNext();
            m_grounded = (bool)stream.ReceiveNext();
            //
            m_ReceivedNetworkUpdate = true;
        }
    }
开发者ID:tegleg,项目名称:mfp,代码行数:37,代码来源:bl_PlayerSync.cs


示例19: OnPhotonSerializeView

 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();
         }
 }
开发者ID:coderDarren,项目名称:TheArchitect,代码行数:28,代码来源:thirdPersonNetwork.cs


示例20: InventoryPlayerPickedUpItem

        void InventoryPlayerPickedUpItem(int ufpsItemID, int ufpsPlayerID, Vector3 itemPosition, Quaternion itemRotation, PhotonMessageInfo info)
        {
            List<vp_ItemPickup> pickups;
            if (!vp_MPPickupManager.Instance.Pickups.TryGetValue(ufpsItemID, out pickups))
                return;

            if (pickups[0].gameObject != null)
                vp_Utility.Activate(pickups[0].gameObject, false);

            Debug.Log("Client looted item with UFPS ID: " + ufpsItemID);
            
            vp_MPNetworkPlayer player;
            if (!vp_MPNetworkPlayer.PlayersByID.TryGetValue(ufpsPlayerID, out player))
                return;

            if (player == null)
                return;

            if (player.Collider == null)
                return;

            foreach (vp_ItemPickup p in pickups)
            {
                var a = p as ObjectTriggererItemUFPS;
                a.TryGiveToPlayer(player.Collider, p.Amount, false);
                Debug.Log("Giving UFPS item to player - ItemID: " + a.ID);
            }
        }
开发者ID:predominant,项目名称:Treasure_Chest,代码行数:28,代码来源:InventoryMPUFPSPickupManager.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PhotonPlayer类代码示例发布时间:2022-05-24
下一篇:
C# PhotoSearchExtras类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap