Loss









How do I use Loss
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonLagSimulationGui.cs Copy
57     private void NetSimWindow(int windowId)
58     {
59         GUILayout.Label(string.Format("Rtt:{0,4} +/-{1,3}", this.Peer.RoundTripTime, this.Peer.RoundTripTimeVariance));
60
61         bool simEnabled = this.Peer.IsSimulationEnabled;
62         bool newSimEnabled = GUILayout.Toggle(simEnabled, "Simulate");
63         if (newSimEnabled != simEnabled)
64         {
65             this.Peer.IsSimulationEnabled = newSimEnabled;
66         }
67
68         float inOutLag = this.Peer.NetworkSimulationSettings.IncomingLag;
69         GUILayout.Label("Lag " + inOutLag);
70         inOutLag = GUILayout.HorizontalSlider(inOutLag, 0, 500);
71
72         this.Peer.NetworkSimulationSettings.IncomingLag = (int)inOutLag;
73         this.Peer.NetworkSimulationSettings.OutgoingLag = (int)inOutLag;
74
75         float inOutJitter = this.Peer.NetworkSimulationSettings.IncomingJitter;
76         GUILayout.Label("Jit " + inOutJitter);
77         inOutJitter = GUILayout.HorizontalSlider(inOutJitter, 0, 100);
78
79         this.Peer.NetworkSimulationSettings.IncomingJitter = (int)inOutJitter;
80         this.Peer.NetworkSimulationSettings.OutgoingJitter = (int)inOutJitter;
81
82         float loss = this.Peer.NetworkSimulationSettings.IncomingLossPercentage;
83         GUILayout.Label("Loss " + loss);
84         loss = GUILayout.HorizontalSlider(loss, 0, 10);
85
86         this.Peer.NetworkSimulationSettings.IncomingLossPercentage = (int)loss;
87         this.Peer.NetworkSimulationSettings.OutgoingLossPercentage = (int)loss;
88
89         // if anything was clicked, the height of this window is likely changed. reduce it to be layouted again next frame
90         if (GUI.changed)
91         {
92             this.WindowRect.height = 100;
93         }
94
95         GUI.DragWindow();
96     }
File name: PhotonNetwork.cs Copy
909     {
910         get { return networkingPeer.PacketLossByCrc; }
911     }
File name: Player.cs Copy
233   public void LoseFood (int loss)
234   {
235    //Set the trigger for the player animator to transition to the playerHit animation.
236    animator.SetTrigger ("playerHit");
237
238    //Subtract lost food points from the players total.
239    food -= loss;
240
241    //Update the food display with the new total.
242    foodText.text = "-"+ loss + " Food: " + food;
243
244    //Check to see if game has ended.
245    CheckIfGameOver ();
246   }
File name: Wall.cs Copy
25   public void DamageWall (int loss)
26   {
27    //Call the RandomizeSfx function of SoundManager to play one of two chop sounds.
28    SoundManager.instance.RandomizeSfx (chopSound1, chopSound2);
29
30    //Set spriteRenderer to the damaged wall sprite.
31    spriteRenderer.sprite = dmgSprite;
32
33    //Subtract loss from hit point total.
34    hp -= loss;
35
36    //If hit points are less than or equal to zero:
37    if(hp <= 0)
38     //Disable the gameObject.
39     gameObject.SetActive (false);
40   }

Download file with original file name:Loss

Loss 134 lượt xem

Gõ tìm kiếm nhanh...