本文整理汇总了C#中ExitGames.Client.Photon.Hashtable.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# Hashtable.ContainsKey方法的具体用法?C# Hashtable.ContainsKey怎么用?C# Hashtable.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExitGames.Client.Photon.Hashtable
的用法示例。
在下文中一共展示了Hashtable.ContainsKey方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetActorPropertiesForActorNr
private Hashtable GetActorPropertiesForActorNr(Hashtable actorProperties, int actorNr)
{
if (actorProperties.ContainsKey(actorNr))
{
return (Hashtable)actorProperties[actorNr];
}
return actorProperties;
}
示例2: DoInstantiate
internal GameObject DoInstantiate(Hashtable evData, PhotonPlayer photonPlayer, GameObject resourceGameObject)
{
// some values always present:
string prefabName = (string)evData[(byte)0];
int serverTime = (int)evData[(byte)6];
int instantiationId = (int)evData[(byte)7];
Vector3 position;
if (evData.ContainsKey((byte)1))
{
position = (Vector3)evData[(byte)1];
}
else
{
position = Vector3.zero;
}
Quaternion rotation = Quaternion.identity;
if (evData.ContainsKey((byte)2))
{
rotation = (Quaternion)evData[(byte)2];
}
int group = 0;
if (evData.ContainsKey((byte)3))
{
group = (int)evData[(byte)3];
}
short objLevelPrefix = 0;
if (evData.ContainsKey((byte)8))
{
objLevelPrefix = (short)evData[(byte)8];
}
int[] viewsIDs;
if (evData.ContainsKey((byte)4))
{
viewsIDs = (int[])evData[(byte)4];
}
else
{
viewsIDs = new int[1] { instantiationId };
}
object[] incomingInstantiationData;
if (evData.ContainsKey((byte)5))
{
incomingInstantiationData = (object[])evData[(byte)5];
}
else
{
incomingInstantiationData = null;
}
// SetReceiving filtering
if (group != 0 && !this.allowedReceivingGroups.Contains(group))
{
return null; // Ignore group
}
// load prefab, if it wasn't loaded before (calling methods might do this)
if (resourceGameObject == null)
{
if (!NetworkingPeer.UsePrefabCache || !NetworkingPeer.PrefabCache.TryGetValue(prefabName, out resourceGameObject))
{
resourceGameObject = (GameObject)Resources.Load(prefabName, typeof(GameObject));
if (NetworkingPeer.UsePrefabCache)
{
NetworkingPeer.PrefabCache.Add(prefabName, resourceGameObject);
}
}
if (resourceGameObject == null)
{
Debug.LogError("PhotonNetwork error: Could not Instantiate the prefab [" + prefabName + "]. Please verify you have this gameobject in a Resources folder.");
return null;
}
}
// now modify the loaded "blueprint" object before it becomes a part of the scene (by instantiating it)
PhotonView[] resourcePVs = resourceGameObject.GetPhotonViewsInChildren();
if (resourcePVs.Length != viewsIDs.Length)
{
throw new Exception("Error in Instantiation! The resource's PhotonView count is not the same as in incoming data.");
}
for (int i = 0; i < viewsIDs.Length; i++)
{
// NOTE instantiating the loaded resource will keep the viewID but would not copy instantiation data, so it's set below
// so we only set the viewID and instantiationId now. the instantiationData can be fetched
resourcePVs[i].viewID = viewsIDs[i];
resourcePVs[i].prefix = objLevelPrefix;
resourcePVs[i].instantiationId = instantiationId;
}
this.StoreInstantiationData(instantiationId, incomingInstantiationData);
// load the resource and set it's values before instantiating it:
GameObject go = (GameObject)GameObject.Instantiate(resourceGameObject, position, rotation);
//.........这里部分代码省略.........
示例3: DeltaCompressionRead
/// <summary>
/// reads incoming messages created by "OnSerialize"
/// </summary>
private bool DeltaCompressionRead(PhotonView view, Hashtable data)
{
if (data.ContainsKey((byte)1))
{
// we have a full list of data (cause key 1 is used), so return "we have uncompressed all"
return true;
}
// Compression was applied as data[(byte)2] exists (this is the data with some fields being compressed to null)
// now we also need a previous "full" list of values to restore values that are null in this msg
if (view.lastOnSerializeDataReceived == null)
{
return false; // We dont have a full match yet, we cannot work with missing values: skip this message
}
object[] compressedContents = data[(byte)2] as object[];
if (compressedContents == null)
{
// despite expectation, there is no compressed data in this msg. shouldn't happen. just a null check
return false;
}
int[] indexesThatAreChangedToNull = data[(byte)3] as int[];
if (indexesThatAreChangedToNull == null)
{
indexesThatAreChangedToNull = new int[0];
}
object[] lastReceivedData = view.lastOnSerializeDataReceived;
for (int index = 0; index < compressedContents.Length; index++)
{
if (compressedContents[index] == null && !indexesThatAreChangedToNull.Contains(index))
{
// we replace null values in this received msg unless a index is in the "changed to null" list
object lastValue = lastReceivedData[index];
compressedContents[index] = lastValue;
}
}
data[(byte)1] = compressedContents; // compressedContents are now uncompressed...
return true;
}
示例4: InternalCacheProperties
/// <summary>
/// Caches custom properties for this player.
/// </summary>
internal void InternalCacheProperties(Hashtable properties)
{
if (properties == null || properties.Count == 0 || this.customProperties.Equals(properties))
{
return;
}
if (properties.ContainsKey(ActorProperties.PlayerName))
{
this.nameField = (string)properties[ActorProperties.PlayerName];
}
if (properties.ContainsKey(ActorProperties.IsInactive))
{
// TODO: implement isinactive
}
this.customProperties.MergeStringKeys(properties);
this.customProperties.StripKeysWithNullValues();
}
示例5: ExecuteRPC
// PHOTONVIEW/RPC related
/// <summary>
/// Executes a received RPC event
/// </summary>
public void ExecuteRPC(Hashtable rpcData, PhotonPlayer sender)
{
if (rpcData == null || !rpcData.ContainsKey((byte)0))
{
Debug.LogError("Malformed RPC; this should never occur. Content: " + SupportClass.DictionaryToString(rpcData));
return;
}
// ts: updated with "flat" event data
int netViewID = (int)rpcData[(byte)0]; // LIMITS PHOTONVIEWS&PLAYERS
int otherSidePrefix = 0; // by default, the prefix is 0 (and this is not being sent)
if (rpcData.ContainsKey((byte)1))
{
otherSidePrefix = (short)rpcData[(byte)1];
}
string inMethodName;
if (rpcData.ContainsKey((byte)5))
{
int rpcIndex = (byte)rpcData[(byte)5]; // LIMITS RPC COUNT
if (rpcIndex > PhotonNetwork.PhotonServerSettings.RpcList.Count - 1)
{
Debug.LogError("Could not find RPC with index: " + rpcIndex + ". Going to ignore! Check PhotonServerSettings.RpcList");
return;
}
else
{
inMethodName = PhotonNetwork.PhotonServerSettings.RpcList[rpcIndex];
}
}
else
{
inMethodName = (string)rpcData[(byte)3];
}
object[] inMethodParameters = null;
if (rpcData.ContainsKey((byte)4))
{
inMethodParameters = (object[])rpcData[(byte)4];
}
if (inMethodParameters == null)
{
inMethodParameters = new object[0];
}
PhotonView photonNetview = this.GetPhotonView(netViewID);
if (photonNetview == null)
{
int viewOwnerId = netViewID/PhotonNetwork.MAX_VIEW_IDS;
bool owningPv = (viewOwnerId == this.mLocalActor.ID);
bool ownerSent = (viewOwnerId == sender.ID);
if (owningPv)
{
Debug.LogWarning("Received RPC \"" + inMethodName + "\" for viewID " + netViewID + " but this PhotonView does not exist! View was/is ours." + (ownerSent ? " Owner called." : " Remote called.") + " By: " + sender.ID);
}
else
{
Debug.LogWarning("Received RPC \"" + inMethodName + "\" for viewID " + netViewID + " but this PhotonView does not exist! Was remote PV." + (ownerSent ? " Owner called." : " Remote called.") + " By: " + sender.ID + " Maybe GO was destroyed but RPC not cleaned up.");
}
return;
}
if (photonNetview.prefix != otherSidePrefix)
{
Debug.LogError(
"Received RPC \"" + inMethodName + "\" on viewID " + netViewID + " with a prefix of " + otherSidePrefix
+ ", our prefix is " + photonNetview.prefix + ". The RPC has been ignored.");
return;
}
// Get method name
if (inMethodName == string.Empty)
{
Debug.LogError("Malformed RPC; this should never occur. Content: " + SupportClass.DictionaryToString(rpcData));
return;
}
if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
Debug.Log("Received RPC: " + inMethodName);
// SetReceiving filtering
if (photonNetview.group != 0 && !allowedReceivingGroups.Contains(photonNetview.group))
{
return; // Ignore group
}
Type[] argTypes = new Type[0];
if (inMethodParameters.Length > 0)
{
argTypes = new Type[inMethodParameters.Length];
int i = 0;
for (int index = 0; index < inMethodParameters.Length; index++)
//.........这里部分代码省略.........
示例6: InternalCacheProperties
/// <summary>
/// Caches custom properties for this player.
/// </summary>
internal void InternalCacheProperties(Hashtable properties)
{
if (properties == null || properties.Count == 0 || this.customProperties.Equals(properties))
{
return;
}
if (properties.ContainsKey(ActorProperties.PlayerName))
{
this.nameField = (string)properties[ActorProperties.PlayerName];
}
if (properties.ContainsKey(ActorProperties.UserId))
{
this.userId = (string)properties[ActorProperties.UserId];
}
if (properties.ContainsKey(ActorProperties.IsInactive))
{
this.isInactive = (bool)properties[ActorProperties.IsInactive]; //TURNBASED new well-known propery for players
}
this.customProperties.MergeStringKeys(properties);
this.customProperties.StripKeysWithNullValues();
}
示例7: DoInstantiate
internal GameObject DoInstantiate(Hashtable evData, PhotonPlayer photonPlayer, GameObject resourceGameObject)
{
// some values always present:
string prefabName = (string)evData[(byte)0];
int serverTime = (int)evData[(byte)6];
int instantiationId = (int)evData[(byte)7];
Vector3 position;
if (evData.ContainsKey((byte)1))
{
position = (Vector3)evData[(byte)1];
}
else
{
position = Vector3.zero;
}
Quaternion rotation = Quaternion.identity;
if (evData.ContainsKey((byte)2))
{
rotation = (Quaternion)evData[(byte)2];
}
int group = 0;
if (evData.ContainsKey((byte)3))
{
group = (int)evData[(byte)3];
}
short objLevelPrefix = 0;
if (evData.ContainsKey((byte)8))
{
objLevelPrefix = (short)evData[(byte)8];
}
int[] viewsIDs;
if (evData.ContainsKey((byte)4))
{
viewsIDs = (int[])evData[(byte)4];
}
else
{
viewsIDs = new int[1] { instantiationId };
}
object[] incomingInstantiationData;
if (evData.ContainsKey((byte)5))
{
incomingInstantiationData = (object[])evData[(byte)5];
}
else
{
incomingInstantiationData = null;
}
// SetReceiving filtering
if (group != 0 && !this.allowedReceivingGroups.Contains(group))
{
return null; // Ignore group
}
// load prefab, if it wasn't loaded before (calling methods might do this)
if (resourceGameObject == null)
{
if (!NetworkingPeer.UsePrefabCache || !NetworkingPeer.PrefabCache.TryGetValue(prefabName, out resourceGameObject))
{
resourceGameObject = (GameObject)Resources.Load(prefabName, typeof(GameObject));
if (NetworkingPeer.UsePrefabCache)
{
NetworkingPeer.PrefabCache.Add(prefabName, resourceGameObject);
}
}
if (resourceGameObject == null)
{
Debug.LogError("PhotonNetwork error: Could not Instantiate the prefab [" + prefabName + "]. Please verify you have this gameobject in a Resources folder.");
return null;
}
}
// now modify the loaded "blueprint" object before it becomes a part of the scene (by instantiating it)
PhotonView[] resourcePVs = resourceGameObject.GetPhotonViewsInChildren();
if (resourcePVs.Length != viewsIDs.Length)
{
throw new Exception("Error in Instantiation! The resource's PhotonView count is not the same as in incoming data.");
}
for (int i = 0; i < viewsIDs.Length; i++)
{
// NOTE instantiating the loaded resource will keep the viewID but would not copy instantiation data, so it's set below
// so we only set the viewID and instantiationId now. the instantiationData can be fetched
resourcePVs[i].viewID = viewsIDs[i];
resourcePVs[i].prefix = objLevelPrefix;
resourcePVs[i].instantiationId = instantiationId;
}
this.StoreInstantiationData(instantiationId, incomingInstantiationData);
// load the resource and set it's values before instantiating it:
GameObject go = (GameObject)GameObject.Instantiate(resourceGameObject, position, rotation);
//.........这里部分代码省略.........
示例8: CacheProperties
/// <summary>Caches properties for new Players or when updates of remote players are received. Use SetCustomProperties() for a synced update.</summary>
/// <remarks>
/// This only updates the CustomProperties and doesn't send them to the server.
/// Mostly used when creating new remote players, where the server sends their properties.
/// </remarks>
public virtual void CacheProperties(Hashtable properties)
{
if (properties == null || properties.Count == 0 || this.CustomProperties.Equals(properties))
{
return;
}
if (properties.ContainsKey(ActorProperties.PlayerName))
{
string nameInServersProperties = (string)properties[ActorProperties.PlayerName];
if (nameInServersProperties != null)
{
if (this.IsLocal)
{
// the local playername is different than in the properties coming from the server
// so the local nickName was changed and the server is outdated -> update server
// update property instead of using the outdated nickName coming from server
if (!nameInServersProperties.Equals(this.nickName))
{
this.SetPlayerNameProperty();
}
}
else
{
this.NickName = nameInServersProperties;
}
}
}
if (properties.ContainsKey(ActorProperties.IsInactive))
{
this.IsInactive = (bool)properties[ActorProperties.IsInactive]; //TURNBASED new well-known propery for players
}
this.CustomProperties.MergeStringKeys(properties);
}
示例9: ReadEvMove
/// <summary>Reads the "custom content" Hashtable that is sent as position update.</summary>
/// <returns>Hashtable for event "move" to update others</returns>
public void ReadEvMove(Hashtable evContent)
{
if (evContent.ContainsKey((byte)1))
{
byte[] posArray = (byte[])evContent[(byte)1];
this.PosX = posArray[0];
this.PosY = posArray[1];
}
else if (evContent.ContainsKey("1"))
{
// js client event support (those can't send with byte-keys)
var posArray = (object[])evContent["1"]; // NOTE: this is subject to change while we update the serialization in JS/Server
this.PosX = System.Convert.ToByte(posArray[0]);
this.PosY = System.Convert.ToByte(posArray[1]);
}
this.LastUpdateTimestamp = GameLogic.Timestamp;
}
示例10: ReadEvColor
/// <summary>Reads the "custom content" Hashtable that is sent as color update.</summary>
/// <returns>Hashtable for event "color" to update others</returns>
public void ReadEvColor(Hashtable evContent)
{
if (evContent.ContainsKey((byte)1))
{
this.Color = (int)evContent[(byte)1];
}
else if (evContent.ContainsKey("1"))
{
// js client event support (those can't send with byte-keys)
this.Color = System.Convert.ToInt32(evContent["1"]);
}
this.LastUpdateTimestamp = GameLogic.Timestamp;
}