Why









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

Featured Snippets


File name: NetworkingPeer.cs Copy
2835     internal void RPC(PhotonView view, string methodName, PhotonPlayer player, bool encrypt, params object[] parameters)
2836     {
2837         if (this.blockSendingGroups.Contains(view.group))
2838         {
2839             return; // Block sending on this group
2840         }
2841
2842         if (view.viewID < 1) //TODO: check why 0 should be illegal
2843         {
2844             Debug.LogError("Illegal view ID:" + view.viewID + " method: " + methodName + " GO:" + view.gameObject.name);
2845         }
2846
2847         if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
2848         {
2849             Debug.Log("Sending RPC \"" + methodName + "\" to player[" + player + "]");
2850         }
2851
2852
2853         //ts: changed RPCs to a one-level hashtable as described in internal.txt
2854         Hashtable rpcEvent = new Hashtable();
2855         rpcEvent[(byte)0] = (int)view.viewID; // LIMITS PHOTONVIEWS&PLAYERS
2856         if (view.prefix > 0)
2857         {
2858             rpcEvent[(byte)1] = (short)view.prefix;
2859         }
2860         rpcEvent[(byte)2] = this.ServerTimeInMilliSeconds;
2861
2862         // send name or shortcut (if available)
2863         int shortcut = 0;
2864         if (rpcShortcuts.TryGetValue(methodName, out shortcut))
2865         {
2866             rpcEvent[(byte)5] = (byte)shortcut; // LIMITS RPC COUNT
2867         }
2868         else
2869         {
2870             rpcEvent[(byte)3] = methodName;
2871         }
2872
2873         if (parameters != null && parameters.Length > 0)
2874         {
2875             rpcEvent[(byte) 4] = (object[]) parameters;
2876         }
2877
2878         if (this.mLocalActor == player)
2879         {
2880             this.ExecuteRPC(rpcEvent, player);
2881         }
2882         else
2883         {
2884             RaiseEventOptions options = new RaiseEventOptions() { TargetActors = new int[] { player.ID }, Encrypt = encrypt };
2885             this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
2886         }
2887     }
File name: PhotonClasses.cs Copy
383             {
384                 Debug.LogWarning("Why are you still using networkView? should be PhotonView?");
385                 return PhotonView.Get(this);
386             }
File name: ConnectorScript.cs Copy
91  private Color getConnectorColor(){
92   Color standardColor = new Color(0,0.5f, 0);
93   Color highlightedColor = new Color(0f, 0f, 1f);
94   int block0;
95   int block1;
96   int block2;
97   int blockPosition;
98
99   if (this.axis == "x") {
100    blockPosition = this.x;
101    block0 = this.GetBlockNumber(0,this.y, this.z);
102    block1 = this.GetBlockNumber(1,this.y, this.z);
103    block2 = this.GetBlockNumber(2,this.y, this.z);
104   }
105   else if (this.axis == "y") {
106    blockPosition = this.y;
107    block0 = this.GetBlockNumber(this.x,0, this.z);
108    block1 = this.GetBlockNumber(this.x,1, this.z);
109    block2 = this.GetBlockNumber(this.x,2, this.z);
110   }
111   else if (this.axis == "z") {
112    blockPosition = this.z;
113    block0 = this.GetBlockNumber(this.x,this.y, 0);
114    block1 = this.GetBlockNumber(this.x,this.y, 1);
115    block2 = this.GetBlockNumber(this.x,this.y, 2);
116   }
117   else { //not quite sure why axis isn't set but throwing error
118    return standardColor;
119   }
120
121   //no highlighting needed since connector isn't visible
122   if (blockPosition == 2) return standardColor;
123
124   //middle block is blank and first and second blocks match
125   if (block1 == BlockScript.emptyBlock
126       && block0 != BlockScript.emptyBlock
127       && block0 == block2) return highlightedColor;
128
129   //if this block is empty then return standard color
130   if (blockPosition == BlockScript.emptyBlock) return standardColor;
131
132   //if the next matches
133   if(blockPosition == 0 && block0 == block1 && block0 != BlockScript.emptyBlock) return highlightedColor;
134   if(blockPosition == 1 && block1 == block2 && block1 != BlockScript.emptyBlock) return highlightedColor;
135
136   //set the default color
137   return standardColor;
138  }

Download file with original file name:Why

Why 115 lượt xem

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