本文整理汇总了C#中ExitGames.Client.Photon.Hashtable.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ExitGames.Client.Photon.Hashtable.TryGetValue方法的具体用法?C# ExitGames.Client.Photon.Hashtable.TryGetValue怎么用?C# ExitGames.Client.Photon.Hashtable.TryGetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExitGames.Client.Photon.Hashtable
的用法示例。
在下文中一共展示了ExitGames.Client.Photon.Hashtable.TryGetValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
//.........这里部分代码省略.........