Removed
How do I use Removed
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PhotonAnimatorViewEditor.cs
Copy
157 private void CheckIfStoredParametersExist()
158 {
159 for (int i = 0; i < this.m_Target.GetSynchronizedParameters().Count; ++i)
160 {
161 string parameterName = this.m_Target.GetSynchronizedParameters()[i].Name;
162 if (DoesParameterExist(parameterName) == false)
163 {
164 Debug.LogWarning("Parameter '" + this.m_Target.GetSynchronizedParameters()[i].Name +
165 "' doesn't exist anymore. Removing it from the list of synchronized parameters");
166 int numberOfRemovedElements = this.m_Target.GetSynchronizedParameters().RemoveAll(item => item.Name == parameterName);
167 EditorUtility.SetDirty(this.m_Target);
168
169 i -= numberOfRemovedElements;
170
171 if (i < 0)
172 {
173 break;
174 }
175 }
176 }
177 }
File name: NetworkingPeer.cs
Copy
1631 public void OnEvent(EventData photonEvent)
1632 {
1633 if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
1634 Debug.Log(string.Format("OnEvent: {0}", photonEvent.ToString()));
1635
1636 int actorNr = -1;
1637 PhotonPlayer originatingPlayer = null;
1638
1639 if (photonEvent.Parameters.ContainsKey(ParameterCode.ActorNr))
1640 {
1641 actorNr = (int)photonEvent[ParameterCode.ActorNr];
1642 if (this.mActors.ContainsKey(actorNr))
1643 {
1644 originatingPlayer = (PhotonPlayer)this.mActors[actorNr];
1645 }
1646 //else
1647 //{
1648 // // the actor sending this event is not in actorlist. this is usually no problem
1649 // if (photonEvent.Code != (byte)LiteOpCode.Join)
1650 // {
1651 // Debug.LogWarning("Received event, but we do not have this actor: " + actorNr);
1652 // }
1653 //}
1654 }
1655
1656 switch (photonEvent.Code)
1657 {
1658 case PunEvent.OwnershipRequest:
1659 {
1660 int[] requestValues = (int[]) photonEvent.Parameters[ParameterCode.CustomEventContent];
1661 int requestedViewId = requestValues[0];
1662 int currentOwner = requestValues[1];
1663 Debug.Log("Ev OwnershipRequest: " + photonEvent.Parameters.ToStringFull() + " ViewID: " + requestedViewId + " from: " + currentOwner + " Time: " + Environment.TickCount%1000);
1664
1665 PhotonView requestedView = PhotonView.Find(requestedViewId);
1666 if (requestedView == null)
1667 {
1668 Debug.LogWarning("Can't find PhotonView of incoming OwnershipRequest. ViewId not found: " + requestedViewId);
1669 break;
1670 }
1671
1672 Debug.Log("Ev OwnershipRequest PhotonView.ownershipTransfer: " + requestedView.ownershipTransfer + " .ownerId: " + requestedView.ownerId + " isOwnerActive: " + requestedView.isOwnerActive + ". This client's player: " + PhotonNetwork.player.ToStringFull());
1673
1674 switch (requestedView.ownershipTransfer)
1675 {
1676 case OwnershipOption.Fixed:
1677 Debug.LogWarning("Ownership mode == fixed. Ignoring request.");
1678 break;
1679 case OwnershipOption.Takeover:
1680 if (currentOwner == requestedView.ownerId)
1681 {
1682 // a takeover is successful automatically, if taken from current owner
1683 requestedView.ownerId = actorNr;
1684 }
1685 break;
1686 case OwnershipOption.Request:
1687 if (currentOwner == PhotonNetwork.player.ID || PhotonNetwork.player.isMasterClient)
1688 {
1689 if ((requestedView.ownerId == PhotonNetwork.player.ID) || (PhotonNetwork.player.isMasterClient && !requestedView.isOwnerActive))
1690 {
1691 SendMonoMessage(PhotonNetworkingMessage.OnOwnershipRequest, new object[] {requestedView, originatingPlayer});
1692 }
1693 }
1694 break;
1695 default:
1696 break;
1697 }
1698 }
1699 break;
1700
1701 case PunEvent.OwnershipTransfer:
1702 {
1703 int[] transferViewToUserID = (int[]) photonEvent.Parameters[ParameterCode.CustomEventContent];
1704 Debug.Log("Ev OwnershipTransfer. ViewID " + transferViewToUserID[0] + " to: " + transferViewToUserID[1] + " Time: " + Environment.TickCount%1000);
1705
1706 int requestedViewId = transferViewToUserID[0];
1707 int newOwnerId = transferViewToUserID[1];
1708
1709 PhotonView pv = PhotonView.Find(requestedViewId);
1710 pv.ownerId = newOwnerId;
1711
1712 break;
1713 }
1714 case EventCode.GameList:
1715 {
1716 this.mGameList = new Dictionary
1717 Hashtable games = (Hashtable)photonEvent[ParameterCode.GameList];
1718 foreach (DictionaryEntry game in games)
1719 {
1720 string gameName = (string)game.Key;
1721 this.mGameList[gameName] = new RoomInfo(gameName, (Hashtable)game.Value);
1722 }
1723 mGameListCopy = new RoomInfo[mGameList.Count];
1724 mGameList.Values.CopyTo(mGameListCopy, 0);
1725 SendMonoMessage(PhotonNetworkingMessage.OnReceivedRoomListUpdate);
1726 break;
1727 }
1728
1729 case EventCode.GameListUpdate:
1730 {
1731 Hashtable games = (Hashtable)photonEvent[ParameterCode.GameList];
1732 foreach (DictionaryEntry room in games)
1733 {
1734 string gameName = (string)room.Key;
1735 RoomInfo game = new RoomInfo(gameName, (Hashtable)room.Value);
1736 if (game.removedFromList)
1737 {
1738 this.mGameList.Remove(gameName);
1739 }
1740 else
1741 {
1742 this.mGameList[gameName] = game;
1743 }
1744 }
1745 this.mGameListCopy = new RoomInfo[this.mGameList.Count];
1746 this.mGameList.Values.CopyTo(this.mGameListCopy, 0);
1747 SendMonoMessage(PhotonNetworkingMessage.OnReceivedRoomListUpdate);
1748 break;
1749 }
1750
1751 case EventCode.QueueState:
1752 // not used anymore
1753 break;
1754
1755 case EventCode.AppStats:
1756 // Debug.LogInfo("Received stats!");
1757 this.mPlayersInRoomsCount = (int)photonEvent[ParameterCode.PeerCount];
1758 this.mPlayersOnMasterCount = (int)photonEvent[ParameterCode.MasterPeerCount];
1759 this.mGameCount = (int)photonEvent[ParameterCode.GameCount];
1760 break;
1761
1762 case EventCode.Join:
1763 // actorNr is fetched out of event above
1764 Hashtable actorProperties = (Hashtable)photonEvent[ParameterCode.PlayerProperties];
1765 if (originatingPlayer == null)
1766 {
1767 bool isLocal = this.mLocalActor.ID == actorNr;
1768 this.AddNewPlayer(actorNr, new PhotonPlayer(isLocal, actorNr, actorProperties));
1769 this.ResetPhotonViewsOnSerialize(); // This sets the correct OnSerializeState for Reliable OnSerialize
1770 }
1771
1772 if (actorNr == this.mLocalActor.ID)
1773 {
1774 // in this player's 'own' join event, we get a complete list of players in the room, so check if we know all players
1775 int[] actorsInRoom = (int[])photonEvent[ParameterCode.ActorList];
1776 foreach (int actorNrToCheck in actorsInRoom)
1777 {
1778 if (this.mLocalActor.ID != actorNrToCheck && !this.mActors.ContainsKey(actorNrToCheck))
1779 {
1780 this.AddNewPlayer(actorNrToCheck, new PhotonPlayer(false, actorNrToCheck, string.Empty));
1781 }
1782 }
1783
1784 // joinWithCreateOnDemand can turn an OpJoin into creating the room. Then actorNumber is 1 and callback: OnCreatedRoom()
1785 if (this.mLastJoinType == JoinType.JoinOrCreateOnDemand && this.mLocalActor.ID == 1)
1786 {
1787 SendMonoMessage(PhotonNetworkingMessage.OnCreatedRoom);
1788 }
1789 SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom); //Always send OnJoinedRoom
1790
1791 }
1792 else
1793 {
1794 SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerConnected, this.mActors[actorNr]);
1795 }
1796 break;
1797
1798 case EventCode.Leave:
1799 this.HandleEventLeave(actorNr);
1800 break;
1801
1802 case EventCode.PropertiesChanged:
1803 int targetActorNr = (int)photonEvent[ParameterCode.TargetActorNr];
1804 Hashtable gameProperties = null;
1805 Hashtable actorProps = null;
1806 if (targetActorNr == 0)
1807 {
1808 gameProperties = (Hashtable)photonEvent[ParameterCode.Properties];
1809 }
1810 else
1811 {
1812 actorProps = (Hashtable)photonEvent[ParameterCode.Properties];
1813 }
1814
1815 this.ReadoutProperties(gameProperties, actorProps, targetActorNr);
1816 break;
1817
1818 case PunEvent.RPC:
1819 //ts: each event now contains a single RPC. execute this
1820 // Debug.Log("Ev RPC from: " + originatingPlayer);
1821 this.ExecuteRPC(photonEvent[ParameterCode.Data] as Hashtable, originatingPlayer);
1822 break;
1823
1824 case PunEvent.SendSerialize:
1825 case PunEvent.SendSerializeReliable:
1826 Hashtable serializeData = (Hashtable)photonEvent[ParameterCode.Data];
1827 //Debug.Log(serializeData.ToStringFull());
1828
1829 int remoteUpdateServerTimestamp = (int)serializeData[(byte)0];
1830 short remoteLevelPrefix = -1;
1831 short initialDataIndex = 1;
1832 if (serializeData.ContainsKey((byte)1))
1833 {
1834 remoteLevelPrefix = (short)serializeData[(byte)1];
1835 initialDataIndex = 2;
1836 }
1837
1838 for (short s = initialDataIndex; s < serializeData.Count; s++)
1839 {
1840 this.OnSerializeRead(serializeData[s] as Hashtable, originatingPlayer, remoteUpdateServerTimestamp, remoteLevelPrefix);
1841 }
1842 break;
1843
1844 case PunEvent.Instantiation:
1845 this.DoInstantiate((Hashtable)photonEvent[ParameterCode.Data], originatingPlayer, null);
1846 break;
1847
1848 case PunEvent.CloseConnection:
1849 // MasterClient "requests" a disconnection from us
1850 if (originatingPlayer == null || !originatingPlayer.isMasterClient)
1851 {
1852 Debug.LogError("Error: Someone else(" + originatingPlayer + ") then the masterserver requests a disconnect!");
1853 }
1854 else
1855 {
1856 PhotonNetwork.LeaveRoom();
1857 }
1858
1859 break;
1860
1861 case PunEvent.DestroyPlayer:
1862 Hashtable evData = (Hashtable)photonEvent[ParameterCode.Data];
1863 int targetPlayerId = (int)evData[(byte)0];
1864 if (targetPlayerId >= 0)
1865 {
1866 this.DestroyPlayerObjects(targetPlayerId, true);
1867 }
1868 else
1869 {
1870 if (this.DebugOut >= DebugLevel.INFO) Debug.Log("Ev DestroyAll! By PlayerId: " + actorNr);
1871 this.DestroyAll(true);
1872 }
1873 break;
1874
1875 case PunEvent.Destroy:
1876 evData = (Hashtable)photonEvent[ParameterCode.Data];
1877 int instantiationId = (int)evData[(byte)0];
1878 // Debug.Log("Ev Destroy for viewId: " + instantiationId + " sent by owner: " + (instantiationId / PhotonNetwork.MAX_VIEW_IDS == actorNr) + " this client is owner: " + (instantiationId / PhotonNetwork.MAX_VIEW_IDS == this.mLocalActor.ID));
1879
1880
1881 PhotonView pvToDestroy = null;
1882 if (this.photonViewList.TryGetValue(instantiationId, out pvToDestroy))
1883 {
1884 this.RemoveInstantiatedGO(pvToDestroy.gameObject, true);
1885 }
1886 else
1887 {
1888 if (this.DebugOut >= DebugLevel.ERROR) Debug.LogError("Ev Destroy Failed. Could not find PhotonView with instantiationId " + instantiationId + ". Sent by actorNr: " + actorNr);
1889 }
1890
1891 break;
1892
1893 case PunEvent.AssignMaster:
1894 evData = (Hashtable)photonEvent[ParameterCode.Data];
1895 int newMaster = (int)evData[(byte)1];
1896 this.SetMasterClient(newMaster, false);
1897 break;
1898
1899 default:
1900 if (photonEvent.Code < 200 && PhotonNetwork.OnEventCall != null)
1901 {
1902 object content = photonEvent[ParameterCode.Data];
1903 PhotonNetwork.OnEventCall(photonEvent.Code, content, actorNr);
1904 }
1905 else
1906 {
1907 // actorNr might be null. it is fetched out of event on top of method
1908 // Hashtable eventContent = (Hashtable) photonEvent[ParameterCode.Data];
1909 // this.mListener.customEventAction(actorNr, eventCode, eventContent);
1910 Debug.LogError("Error. Unhandled event: " + photonEvent);
1911 }
1912 break;
1913 }
1914
1915 this.externalListener.OnEvent(photonEvent);
1916 }
File name: NetworkingPeer.cs
Copy
3113 public void NewSceneLoaded()
3114 {
3115 if (this.loadingLevelAndPausedNetwork)
3116 {
3117 this.loadingLevelAndPausedNetwork = false;
3118 PhotonNetwork.isMessageQueueRunning = true;
3119 }
3120 // Debug.Log("OnLevelWasLoaded photonViewList.Count: " + photonViewList.Count); // Exit Games internal log
3121
3122 List
3123 foreach (KeyValuePair
3124 {
3125 PhotonView view = kvp.Value;
3126 if (view == null)
3127 {
3128 removeKeys.Add(kvp.Key);
3129 }
3130 }
3131
3132 for (int index = 0; index < removeKeys.Count; index++)
3133 {
3134 int key = removeKeys[index];
3135 this.photonViewList.Remove(key);
3136 }
3137
3138 if (removeKeys.Count > 0)
3139 {
3140 if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
3141 Debug.Log("New level loaded. Removed " + removeKeys.Count + " scene view IDs from last level.");
3142 }
3143 }
File name: RoomInfo.cs
Copy
176 protected internal void CacheProperties(Hashtable propertiesToCache)
177 {
178 if (propertiesToCache == null || propertiesToCache.Count == 0 || this.customPropertiesField.Equals(propertiesToCache))
179 {
180 return;
181 }
182
183 // check of this game was removed from the list. in that case, we don't
184 // need to read any further properties
185 // list updates will remove this game from the game listing
186 if (propertiesToCache.ContainsKey(GameProperties.Removed))
187 {
188 this.removedFromList = (Boolean)propertiesToCache[GameProperties.Removed];
189 if (this.removedFromList)
190 {
191 return;
192 }
193 }
194
195 // fetch the "well known" properties of the room, if available
196 if (propertiesToCache.ContainsKey(GameProperties.MaxPlayers))
197 {
198 this.maxPlayersField = (byte)propertiesToCache[GameProperties.MaxPlayers];
199 }
200
201 if (propertiesToCache.ContainsKey(GameProperties.IsOpen))
202 {
203 this.openField = (bool)propertiesToCache[GameProperties.IsOpen];
204 }
205
206 if (propertiesToCache.ContainsKey(GameProperties.IsVisible))
207 {
208 this.visibleField = (bool)propertiesToCache[GameProperties.IsVisible];
209 }
210
211 if (propertiesToCache.ContainsKey(GameProperties.PlayerCount))
212 {
213 this.playerCount = (int)((byte)propertiesToCache[GameProperties.PlayerCount]);
214 }
215
216 if (propertiesToCache.ContainsKey(GameProperties.CleanupCacheOnLeave))
217 {
218 this.autoCleanUpField = (bool)propertiesToCache[GameProperties.CleanupCacheOnLeave];
219 }
220
221 //if (propertiesToCache.ContainsKey(GameProperties.PropsListedInLobby))
222 //{
223 // // could be cached but isn't useful
224 //}
225
226 // merge the custom properties (from your application) to the cache (only string-typed keys will be kept)
227 this.customPropertiesField.MergeStringKeys(propertiesToCache);
228 }
File name: HorizontalScrollSnap.cs
Copy
119 /// *Note, this is an index address (0-x)
123 public void RemoveChild(int index, out GameObject ChildRemoved)
124 {
125 ChildRemoved = null;
126 if (index < 0 || index > _screensContainer.childCount)
127 {
128 return;
129 }
130 _scroll_rect.horizontalNormalizedPosition = 0;
131
132 Transform child = _screensContainer.transform.GetChild(index);
133 child.SetParent(null);
134 ChildRemoved = child.gameObject;
135
136 DistributePages();
137 if (MaskArea) UpdateVisible();
138
139 if (_currentPage > _screens - 1)
140 {
141 CurrentPage = _screens - 1;
142 }
143
144 SetScrollContainerPosition();
145 }
File name: HorizontalScrollSnap.cs
Copy
151 public void RemoveAllChildren(out GameObject[] ChildrenRemoved)
152 {
153 var _screenCount = _screensContainer.childCount;
154 ChildrenRemoved = new GameObject[_screenCount];
155
156 for (int i = _screenCount - 1; i >= 0; i--)
157 {
158 ChildrenRemoved[i] = _screensContainer.GetChild(i).gameObject;
159 ChildrenRemoved[i].transform.SetParent(null);
160 }
161
162 _scroll_rect.horizontalNormalizedPosition = 0;
163 CurrentPage = 0;
164 InitialiseChildObjectsFromScene();
165 DistributePages();
166 if (MaskArea) UpdateVisible();
167 }
File name: VerticalScrollSnap.cs
Copy
119 /// *Note, this is an index address (0-x)
123 public void RemoveChild(int index, out GameObject ChildRemoved)
124 {
125 ChildRemoved = null;
126 if (index < 0 || index > _screensContainer.childCount)
127 {
128 return;
129 }
130 _scroll_rect.verticalNormalizedPosition = 0;
131
132 Transform child = _screensContainer.transform.GetChild(index);
133 child.SetParent(null);
134 ChildRemoved = child.gameObject;
135 InitialiseChildObjectsFromScene();
136 DistributePages();
137 if (MaskArea) UpdateVisible();
138
139 if (_currentPage > _screens - 1)
140 {
141 CurrentPage = _screens - 1;
142 }
143
144 SetScrollContainerPosition();
145 }
File name: VerticalScrollSnap.cs
Copy
151 public void RemoveAllChildren(out GameObject[] ChildrenRemoved)
152 {
153 var _screenCount = _screensContainer.childCount;
154 ChildrenRemoved = new GameObject[_screenCount];
155
156 for (int i = _screenCount - 1; i >= 0; i--)
157 {
158 ChildrenRemoved[i] = _screensContainer.GetChild(i).gameObject;
159 ChildrenRemoved[i].transform.SetParent(null);
160 }
161
162 _scroll_rect.verticalNormalizedPosition = 0;
163 CurrentPage = 0;
164 InitialiseChildObjectsFromScene();
165 DistributePages();
166 if (MaskArea) UpdateVisible();
167 }
File name: Program.cs
Copy
75 static void Main()
76 {
77 Console.OutputEncoding = Encoding.GetEncoding(1252);
78 Console.CursorVisible = false;
79 Console.Title = "Tetris";
80 Console.WindowWidth = GameWidth;
81 Console.BufferWidth = GameWidth;
82 Console.WindowHeight = GameHeight + 1;
83 Console.BufferHeight = GameHeight + 1;
84
85 StartNewGame();
86 PrintBorders();
87
88 Task.Run(() =>
89 {
90 while (true)
91 {
92 PlaySound();
93 }
94 });
95
96 while(true)
97 {
98 if (Console.KeyAvailable)
99 {
100 var key = Console.ReadKey();
101 if (key.Key == ConsoleKey.LeftArrow)
102 {
103 if (currentFigureCol > 1)
104 {
105 currentFigureCol--;
106 }
107 }
108 else if (key.Key == ConsoleKey.RightArrow)
109 {
110 if (currentFigureCol + currentFigure.GetLength(1) - 1 < TetrisWidth)
111 {
112 currentFigureCol++;
113 }
114 }
115 }
116
117 if (CollisionDetection())
118 {
119 PlaceCurrentFigure();
120 int removedLines = CheckForFullLines();
121
122 if (removedLines > 0)
123 {
124 Score += scorePerLines[removedLines - 1] * Level;
125 }
126
127 Level = Score / 1000 + 1;
128
129 currentFigure = nextFigure;
130 nextFigure = Figures[random.Next(0, Figures.Length)];
131 currentFigureRow = 1;
132 currentFigureCol = 4;
133 }
134 else
135 {
136 currentFigureRow++;
137 }
138
139 PrintInfoPanel();
140
141 PrintGameField();
142
143 PrintBorders();
144
145 PrintFigure(currentFigure,
146 currentFigureRow, currentFigureCol);
147
148 Thread.Sleep(speedPerLevel[Level - 1]);
149 }
150 }
Removed 129 lượt xem
Gõ tìm kiếm nhanh...