本文整理汇总了C#中ExitGames.Client.Photon.Hashtable.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# ExitGames.Client.Photon.Hashtable.ContainsKey方法的具体用法?C# ExitGames.Client.Photon.Hashtable.ContainsKey怎么用?C# ExitGames.Client.Photon.Hashtable.ContainsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExitGames.Client.Photon.Hashtable
的用法示例。
在下文中一共展示了ExitGames.Client.Photon.Hashtable.ContainsKey方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetBoardByCustomProperties
protected internal bool SetBoardByCustomProperties(Hashtable customProps, bool calledByEvent)
{
if (!calledByEvent)
{
this.TilesX = 4; // original game had 4x4
this.TilesY = 4;
if (customProps.ContainsKey("tx#"))
{
this.TilesX = (int)customProps["tx#"];
this.TilesY = (int)customProps["ty#"];
}
this.InitializeBoard();
}
int readTiles = 0;
for (int i = 0; i < TileCount; i++)
{
if (customProps.ContainsKey(i.ToString()))
{
byte type = (byte)customProps[i.ToString()];
if (type == TileTypeEmpty)
{
RemoveTileAndQuad((byte) i);
}
else
{
// the type defines the front of a tile and it's material
Tiles[i].Type = type;
int colorIndex = type % colors.Length;
int textureIndex = type % Textures.Length;
Material m = new Material(this.TileBackMaterial);
m.SetColor("_Color", colors[colorIndex]);
m.SetTexture(0, Textures[textureIndex]);
Tiles[i].TileMono.Front.Material = m;
}
readTiles++;
}
}
// init "flipped tiles"
this.FlippedTiles[0] = NotFlippedTile;
this.FlippedTiles[1] = NotFlippedTile;
// read the tiles that are actually, currently flipped (if any)
if (customProps.ContainsKey("flips"))
{
byte[] othersFlippedTiles = (byte[]) customProps["flips"];
for (int i = 0; i < othersFlippedTiles.Length; i++)
{
byte tileId = othersFlippedTiles[i];
if (tileId == NotFlippedTile) continue;
}
this.FlippedTiles = othersFlippedTiles;
}
this.UpdateIsBoardEmpty();
return readTiles == TileCount;
}
示例2: OnPhotonCustomRoomPropertiesChanged
/// <summary>Called by PUN when new properties for the room were set (by any client in the room).</summary>
public void OnPhotonCustomRoomPropertiesChanged(Hashtable propertiesThatChanged)
{
if (propertiesThatChanged.ContainsKey(StartTimeKey))
{
this.roomStartTimestamp = (int)propertiesThatChanged[StartTimeKey];
//Debug.Log("Got prop for roomStartTimestamp: " + roomStartTimestamp);
}
}
示例3: CacheProperties
/// <summary>Copies "well known" properties to fields (isVisible, etc) and caches the custom properties (string-keys only) in a local hashtable.</summary>
/// <param name="propertiesToCache">New or updated properties to store in this RoomInfo.</param>
protected internal virtual void CacheProperties(Hashtable propertiesToCache)
{
if (propertiesToCache == null || propertiesToCache.Count == 0 || this.customProperties.Equals(propertiesToCache))
{
return;
}
// check of this game was removed from the list. in that case, we don't
// need to read any further properties
// list updates will remove this game from the game listing
if (propertiesToCache.ContainsKey(GamePropertyKey.Removed))
{
this.removedFromList = (bool)propertiesToCache[GamePropertyKey.Removed];
if (this.removedFromList)
{
return;
}
}
// fetch the "well known" properties of the room, if available
if (propertiesToCache.ContainsKey(GamePropertyKey.MaxPlayers))
{
this.maxPlayers = (byte)propertiesToCache[GamePropertyKey.MaxPlayers];
}
if (propertiesToCache.ContainsKey(GamePropertyKey.IsOpen))
{
this.isOpen = (bool)propertiesToCache[GamePropertyKey.IsOpen];
}
if (propertiesToCache.ContainsKey(GamePropertyKey.IsVisible))
{
this.isVisible = (bool)propertiesToCache[GamePropertyKey.IsVisible];
}
if (propertiesToCache.ContainsKey(GamePropertyKey.PlayerCount))
{
this.PlayerCount = (int)((byte)propertiesToCache[GamePropertyKey.PlayerCount]);
}
if (propertiesToCache.ContainsKey(GamePropertyKey.PropsListedInLobby))
{
this.propsListedInLobby = propertiesToCache[GamePropertyKey.PropsListedInLobby] as string[];
}
// merge the custom properties (from your application) to the cache (only string-typed keys will be kept)
this.customProperties.MergeStringKeys(propertiesToCache);
}
示例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];
}
this.customProperties.MergeStringKeys(properties);
this.customProperties.StripKeysWithNullValues();
}
示例5: SetBoardByCustomProperties
protected internal bool SetBoardByCustomProperties(Hashtable customProps)
{
int readTiles = 0;
for (int i = 0; i < TileCount; i++)
{
if (customProps.ContainsKey(i.ToString()))
{
TileValues[i] = (byte)customProps[i.ToString()];
readTiles++;
}
}
return readTiles == TileCount;
}
示例6: ReadoutPropertiesForActorNr
/// <summary>
/// Privately used only to read properties for a distinct actor (which might be the hashtable OR a key-pair value IN the actorProperties).
/// </summary>
private Hashtable ReadoutPropertiesForActorNr(Hashtable actorProperties, int actorNr)
{
if (actorProperties.ContainsKey(actorNr))
{
return (Hashtable)actorProperties[actorNr];
}
return actorProperties;
}
示例7: InitStats
/// <summary>
/// this class can be overridden to add additional stats, but
/// NOTE: remember to include base.AddStats in the override.
/// also don't call 'AddStats' from the derived class but
/// leave this to 'Awake' in this class
/// </summary>
public virtual void InitStats()
{
// -------- getters --------
if(NPlayer == null)
{
Debug.LogError("Error ("+this+") Found no vp_MPNetworkPlayer! Aborting ...");
return;
}
Getters.Add("Type", delegate() { return NPlayer.PlayerType.name; });
Getters.Add("Team", delegate() { return NPlayer.TeamNumber; });
Getters.Add("Health", delegate() { return Health; });
Getters.Add("Shots", delegate() { return NPlayer.Shots; });
Getters.Add("Position", delegate() { return NPlayer.Transform.position; });
Getters.Add("Rotation", delegate() { return NPlayer.Transform.root.rotation; });
Getters.Add("Items", delegate()
{
//Debug.Log("--------> GET ITEMS OF " + Inventory.transform.root.gameObject.name);
ExitGames.Client.Photon.Hashtable items = new ExitGames.Client.Photon.Hashtable();
if (Inventory == null)
return items;
foreach (vp_ItemInstance i in Inventory.ItemInstances)
{
if (!items.ContainsKey(i.Type.name))
{
//Debug.Log("ADDING ITEM TO HASHTABLE: " + i.Type.name + ", amount: " + Inventory.GetItemCount(i.Type));
items.Add(i.Type.name, Inventory.GetItemCount(i.Type));
}
}
foreach (vp_UnitBankInstance u in Inventory.UnitBankInstances)
{
//Debug.Log("u: " + u);
//Debug.Log("u.Type: " + u.Type);
//Debug.Log("u.Type.name: " + u.Type.name);
if (!items.ContainsKey(u.Type.name))
{
//Debug.Log("ADDING UNITBANK TO HASHTABLE: " + u.Type.name + ", units: " + u.Count);
items.Add(u.Type.name, u.Count);
}
}
foreach (vp_UnitBankInstance iu in Inventory.InternalUnitBanks)
{
//Debug.Log("iu: " + iu);
//Debug.Log("iu.UnitType: " + iu.UnitType);
//Debug.Log("iu.UnitType.name: " + iu.UnitType.name);
if (iu.Count == 0)
continue;
if (!items.ContainsKey(iu.UnitType.name))
{
//Debug.Log("ADDING UNITS TO HASHTABLE: " +iu.UnitType.name + ", units: " + iu.Count);
items.Add(iu.UnitType.name, iu.Count);
}
}
return items;
});
Getters.Add("Weapon", delegate()
{
if (NPlayer.WeaponHandler == null)
return 0;
return NPlayer.WeaponHandler.CurrentWeaponIndex;
});
// -------- setters --------
Setters.Add("Type", delegate(object val) { NPlayer.PlayerType = vp_MPPlayerSpawner.GetPlayerTypeByName((string)val); });
Setters.Add("Team", delegate(object val) { NPlayer.TeamNumber = (int)val; });
Setters.Add("Health", delegate(object val) { Health = (float)val; });
// NOTE: 'Shots' must never be updated with a lower (lagged) value or
// simulation will go out of sync. however, we should be able
// to set it to zero for game reset purposes (?)
Setters.Add("Shots", delegate(object val) { NPlayer.Shots = (((int)val > 0) ? Mathf.Max(NPlayer.Shots, (int)val) : 0); });
Setters.Add("Position", delegate(object val) { NPlayer.LastMasterPosition = (Vector3)val; NPlayer.SetPosition(NPlayer.LastMasterPosition); });
Setters.Add("Rotation", delegate(object val) { NPlayer.LastMasterRotation = (Quaternion)val; NPlayer.SetRotation(NPlayer.LastMasterRotation); });
Setters.Add("Items", delegate(object val)
{
Debug.Log("--------> TRYING TO SET ITEMS");
ExitGames.Client.Photon.Hashtable items = val as ExitGames.Client.Photon.Hashtable;
if (items == null)
{
Debug.Log("failed to cast items as hashtable");
return;
}
foreach (string s in items.Keys)
{
object amount;
items.TryGetValue(s, out amount);
//.........这里部分代码省略.........
示例8: SetBoardByCustomProperties
protected internal bool SetBoardByCustomProperties(Hashtable customProps, bool calledByEvent)
{
if (!calledByEvent)
{
MainGame.Instance.NewGame();
}
int readTiles = 0;
for (int i = 0; i < cellCount; i++)
{
if (customProps.ContainsKey(i.ToString()))
{
//This needs to set the local player's board with the network board
readTiles++;
}
}
return true;//readTiles == cellCount;
}