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

C# UnityEngine.NetworkMessageInfo类代码示例

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

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



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

示例1: OnNetworkInstantiate

 void OnNetworkInstantiate(NetworkMessageInfo msg)
 {
     if (networkView.isMine)
     {
         this.enabled = false;
     }
 }
开发者ID:silantzis,项目名称:blockotron,代码行数:7,代码来源:NetworkInterpolatedTransform.cs


示例2: OnNetworkInstantiate

    void OnNetworkInstantiate(NetworkMessageInfo info)
    {
        if (networkView.isMine)
        {
            // Disable interpolated transform, we control the movement on this client
            GetComponent<NetworkInterpolatedTransform>().enabled = false;
        }
        else
        {
            name += "Remote";

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

        // we will decide when the object is destroyed
        autoDestroy = false;
    }
开发者ID:silantzis,项目名称:blockotron,代码行数:29,代码来源:NetworkExplosive.cs


示例3: OnSerializeNetworkView2D

    public void OnSerializeNetworkView2D(BitStream stream, NetworkMessageInfo info,
        UnitActionCommand pUnitActionCommand, bool pIsAlive)
    {
        Transform lTransform = characterController.transform;
        Vector3 lData = Vector3.zero;
        //---------------------------------------------------
        if (stream.isWriting)
        {
            lData = lTransform.position;
            lData.z = yVelocity;
        }
        //---------------------------------------------------
        stream.Serialize(ref lData);
        //---------------------------------------------------
        if (stream.isReading)
        {
            yVelocity = lData.z;
            lData.z = 0f;
            lTransform.position = lData;

            var lDeltaTime = (float)(Network.time - info.timestamp);
            if (lDeltaTime > 0.02f)
                update2D(pUnitActionCommand, UnitFace.getValue(pUnitActionCommand.face),
                    pIsAlive, lDeltaTime * Time.timeScale);
            lastUpdateTime = Time.time;

        }
    }
开发者ID:Seraphli,项目名称:TheInsectersWar,代码行数:28,代码来源:Character2D.cs


示例4: OnNetworkInstantiate

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

        /*Debug.Log("cams = " + Camera.allCameras.Length);
        string sender = info.sender.ToString();
        GameObject[] launchers = GameObject.FindGameObjectsWithTag("Launcher");
        Debug.Log ("Number of launchers = " + launchers.Length);
        if (!Network.isServer) {
            if (sender.Equals ("-1")) {
                Camera.allCameras[1].enabled = false;
                Camera.allCameras[0].enabled = true;
            } else {
                Camera.allCameras[Camera.allCameras.Length-1].enabled = false;
                launchers[launchers.Length - 1].SetActive(false);
            }
        }*/
    }
开发者ID:GJL91,项目名称:Epidemic,代码行数:34,代码来源:moveHealer.cs


示例5: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        if (!stream.isWriting)
        {

        }
    }
开发者ID:keaton-freude,项目名称:UnityTowerDefense,代码行数:7,代码来源:WaypointMover.cs


示例6: RecvHealth

 public void RecvHealth(byte[] pckData, NetworkMessageInfo info)
 {
     //ServerCheck
     S2C.SetStructureHealth pck = new S2C.SetStructureHealth();
     pck.DeserializeFromBytes(pckData);
     TileManager.Inst.Get(pck.m_ID).RecvHealth(pck);
 }
开发者ID:rkdrnf,项目名称:fortresswar,代码行数:7,代码来源:TileNetwork.cs


示例7: GiveMeACart

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

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

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

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

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

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

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

        // add it to the lists
        nvs.players.Add(newGuy);
    }
开发者ID:Ronnrein,项目名称:bad-golf-community-edition,代码行数:60,代码来源:networkManagerServer.cs


示例8: OnSerializeNetworkView

    public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 pos = observedTransform.position;
        Quaternion rot = observedTransform.rotation;

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

            reciever.lerpToTarget();

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

            serverStateBuffer[0] = new NetState();
            serverStateBuffer[0].setState((float)info.timestamp, pos, rot);
        }
    }
开发者ID:chrisscherer,项目名称:ISGame,代码行数:25,代码来源:Predictor.cs


示例9: OnSerializeNetworkView

    private void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        if (stream.isWriting)
        {
            Debug.Log("Writing.");

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

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

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

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

            this.transform.position = pos;
            this.transform.eulerAngles = orientation;
        }
    }
开发者ID:Game-Group,项目名称:dog-fighter,代码行数:26,代码来源:NetworkSync.cs


示例10: ReceiveMessage

 void ReceiveMessage(string message, NetworkMessageInfo netInfo)
 {
     //Debug.Log(message);
     string tag = message.Split(':')[0];
     string msg = message.Split(':')[1];
     switch (tag)
     {
         case "Began":
             gesture.Begin(float.Parse(msg.Split(',')[0]), float.Parse(msg.Split(',')[1]));
             break;
         case "Moved":
             gesture.Move(float.Parse(msg.Split(',')[0]), float.Parse(msg.Split(',')[1]));
             break;
         case "Ended":
             gesture.End(float.Parse(msg.Split(',')[0]), float.Parse(msg.Split(',')[1]));
             break;
         case "Choose Candidate":
             lexicon.Accept(int.Parse(msg));
             break;
         case "Keyboard Size Msg":
             lexicon.UpdateSizeMsg(msg);
             break;
         case "Delete":
             //lexicon.Delete();
             break;
         default:
             break;
     }
 }
开发者ID:coolyangzc,项目名称:IndirectGestureKeyboard,代码行数:29,代码来源:Server.cs


示例11: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        //locateMarkersAndLimbs();
        Vector3 tempPos = Vector3.zero;
        Quaternion tempRot = Quaternion.identity;

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

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

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

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

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

        }
    }
开发者ID:rehabgame,项目名称:fighton,代码行数:33,代码来源:Ball.cs


示例12: OnSerializeNetworkView

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

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

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

            // Prediction : the rotation is "updated" before the new data is received
            syncStartRotation = transform.localRotation;
            syncEndRotation = syncRotation;
        }
    }
开发者ID:Midipil,项目名称:SansDessusDessous,代码行数:27,代码来源:NetworkEnemyController.cs


示例13: OnSerializeNetworkView

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

			//We've just recieved the current servers position of this object in 'posReceive'.
			
			renderer.material.color = colorReceive;
			//To reduce laggy movement a bit you could comment the line above and use position lerping below instead:	
			//transform.position = Vector3.Lerp(transform.position, posReceive, 0.9f); //"lerp" to the posReceive by 90%
			//It would be even better to save the last received server position and lerp to it in Update because it is executed more often than OnSerializeNetworkView
			
		}
	}
开发者ID:mlakhal,项目名称:CollaborativeAugmentedRealityEnvironment,代码行数:31,代码来源:ColorPicker1_scripts.cs


示例14: OnNetworkInstantiate

 void OnNetworkInstantiate(NetworkMessageInfo info)
 {
     if(networkView.isMine)
     {
         StartCoroutine(DestroyAfter(duration));
     }
 }
开发者ID:Zatchmeister,项目名称:Dias,代码行数:7,代码来源:BoxScript.cs


示例15: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 syncPosition = Vector3.zero;
        Quaternion rot = Quaternion.identity;

        if (stream.isWriting)
        {

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

            stream.Serialize(ref syncPosition);

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

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

            syncStartPosition = transform.position;
            syncEndPosition = syncPosition;

            qSrot = transform.rotation;
            qErot = rot;
        }
    }
开发者ID:Dankerprouduct,项目名称:Derp-Bots,代码行数:31,代码来源:DevPerks.cs


示例16: reeling

    /*
    [RPC]
    public void reeling(float angle)
    {

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

        } else {

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

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

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

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

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

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

        }
        }
    }
开发者ID:kurix2,项目名称:FishFishRevolution-PC,代码行数:39,代码来源:NetViewObjectScript.cs


示例17: OnSerializeNetworkView

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 syncDest = Vector3.zero;
        Vector3 syncPos = Vector3.zero;
        if (stream.isWriting && Network.isServer)
        {
            syncDest = destination;
            syncPos = this.gameObject.transform.position;
            stream.Serialize(ref syncDest);
            stream.Serialize(ref syncPos);
        }
        else if (stream.isReading)
        {
            stream.Serialize(ref syncDest);
            stream.Serialize(ref syncPos);

            destination = syncDest;
            if (agent != null)
                agent.SetDestination (destination);

            /*
            Vector3 diffPos = this.gameObject.transform.position - syncPos;
            if (diffPos.sqrMagnitude >= 1){
                this.gameObject.transform.position = syncPos;
            }
            */
        }
    }
开发者ID:vmohan7,项目名称:Assassins,代码行数:28,代码来源:AIPath.cs


示例18: OnSerializeNetworkView

    public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 pos = observedTransform.position;
        Quaternion rot = observedTransform.rotation;

        if (stream.isWriting) {
            //Debug.Log("Server is writing");
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
        }
        else {
            //This code takes care of the local client!
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
            receiver.serverPosition = pos;
            receiver.serverRotation = rot;
            //Smoothly correct clients position
            //receiver.lerpToTarget();

            //Take care of data for interpolating remote objects movements
            // Shift up the buffer
            for ( int i = serverStateBuffer.Length - 1; i >= 1; i-- ) {
                serverStateBuffer[i] = serverStateBuffer[i-1];
            }
            //Override the first element with the latest server info
            serverStateBuffer[0] = new NetworkState((float)info.timestamp, pos, rot);
        }
    }
开发者ID:Final-Parsec,项目名称:TheVenomEvent,代码行数:28,代码来源:Predictor.cs


示例19: OnSerializeNetworkView

 public virtual void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
 {
     if (_animator != null) {
         foreach (AnimatorControllerParameter param in _animator.parameters) {
             AnimatorControllerParameterType paramType = param.type;
             switch (paramType) {
             case AnimatorControllerParameterType.Bool:
                 bool boolParam = _animator.GetBool (param.nameHash);
                 stream.Serialize (ref boolParam);
                 if (stream.isReading) {
                     _animator.SetBool (param.nameHash, boolParam);
                 }
                 break;
             case AnimatorControllerParameterType.Float:
                 float floatParam = _animator.GetFloat (param.nameHash);
                 stream.Serialize (ref floatParam);
                 if (stream.isReading) {
                     _animator.SetFloat (param.nameHash, floatParam);
                 }
                 break;
             case AnimatorControllerParameterType.Int:
                 int intParam = _animator.GetInteger (param.nameHash);
                 stream.Serialize (ref intParam);
                 if (stream.isReading) {
                     _animator.SetInteger (param.nameHash, intParam);
                 }
                 break;
             }
         }
     }
 }
开发者ID:qyzeng,项目名称:IsoNetwork,代码行数:31,代码来源:BaseObjectAnimator.cs


示例20: OnSerializeNetworkView

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

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

            //Set new start and end position for movement interpolation
            syncStartPosition = syncEndPosition;
            syncEndPosition = syncPosition;
            print (syncStartPosition);
            print ("end: "+syncEndPosition);
        }
    }
开发者ID:Lowell92,项目名称:Yer_A_Wizard_Oculus,代码行数:27,代码来源:SyncPlayerB.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.NetworkPlayer类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.NavMeshPath类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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