本文整理汇总了C#中ExitGames.Client.Photon.Hashtable.StripToStringKeys方法的典型用法代码示例。如果您正苦于以下问题:C# Hashtable.StripToStringKeys方法的具体用法?C# Hashtable.StripToStringKeys怎么用?C# Hashtable.StripToStringKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExitGames.Client.Photon.Hashtable
的用法示例。
在下文中一共展示了Hashtable.StripToStringKeys方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpSetCustomPropertiesOfActor
public bool OpSetCustomPropertiesOfActor(int actorNr, Hashtable actorProperties)
{
return this.OpSetPropertiesOfActor(actorNr, actorProperties.StripToStringKeys(), null);
}
示例2: OpSetCustomPropertiesOfRoom
public bool OpSetCustomPropertiesOfRoom(Hashtable gameProperties, bool broadcast, byte channelId)
{
return this.OpSetPropertiesOfRoom(gameProperties.StripToStringKeys(), expectedProperties: null, webForward: false);
}
示例3: SetCustomProperties
/// <summary>
/// Updates and synchronizes the named properties of this Player with the values of propertiesToSet.
/// </summary>
/// <remarks>
/// Any player's properties are available in a Room only and only until the player disconnect or leaves.
/// Access any player's properties by: Player.CustomProperties (read-only!) but don't modify that hashtable.
///
/// New properties are added, existing values are updated.
/// Other values will not be changed, so only provide values that changed or are new.
/// To delete a named (custom) property of this player, use null as value.
/// Only string-typed keys are applied (everything else is ignored).
///
/// Local cache is updated immediately, other players are updated through Photon with a fitting operation.
/// To reduce network traffic, set only values that actually changed.
/// </remarks>
/// <param name="propertiesToSet">Hashtable of props to udpate, set and sync. See description.</param>
public void SetCustomProperties(Hashtable propertiesToSet)
{
if (propertiesToSet == null)
{
return;
}
// merge (delete null-values)
this.customProperties.MergeStringKeys(propertiesToSet); // includes a Equals check (simplifying things)
this.customProperties.StripKeysWithNullValues();
// send (sync) these new values
Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
if (this.actorID > 0 && !PhotonNetwork.offlineMode)
{
PhotonNetwork.networkingPeer.OpSetCustomPropertiesOfActor(this.actorID, customProps, true, 0);
}
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged, this, propertiesToSet);
}
示例4: OpSetCustomPropertiesOfActor
public bool OpSetCustomPropertiesOfActor(int actorNr, Hashtable actorProperties, bool broadcast, byte channelId)
{
return this.OpSetPropertiesOfActor(actorNr, actorProperties.StripToStringKeys(), broadcast, channelId);
}
示例5: OpSetCustomPropertiesOfRoom
public bool OpSetCustomPropertiesOfRoom(Hashtable gameProperties, bool broadcast, byte channelId)
{
return this.OpSetPropertiesOfRoom(gameProperties.StripToStringKeys(), broadcast, channelId);
}
示例6: SetCustomProperties
/// <summary>
/// Updates the this player's Custom Properties with new/updated key-values.
/// </summary>
/// <remarks>
/// Custom Properties are a key-value set (Hashtable) which is available to all players in a room.
/// They can relate to the room or individual players and are useful when only the current value
/// of something is of interest. For example: The map of a room.
/// All keys must be strings.
///
/// The Room and the PhotonPlayer class both have SetCustomProperties methods.
/// Also, both classes offer access to current key-values by: customProperties.
///
/// Always use SetCustomProperties to change values.
/// To reduce network traffic, set only values that actually changed.
/// New properties are added, existing values are updated.
/// Other values will not be changed, so only provide values that changed or are new.
///
/// To delete a named (custom) property of this room, use null as value.
///
/// Locally, SetCustomProperties will update it's cache without delay.
/// Other clients are updated through Photon (the server) with a fitting operation.
///
/// <b>Check and Swap</b>
///
/// SetCustomProperties have the option to do a server-side Check-And-Swap (CAS):
/// Values only get updated if the expected values are correct.
/// The expectedValues can be different key/values than the propertiesToSet. So you can
/// check some key and set another key's value (if the check succeeds).
///
/// If the client's knowledge of properties is wrong or outdated, it can't set values with CAS.
/// This can be useful to keep players from concurrently setting values. For example: If all players
/// try to pickup some card or item, only one should get it. With CAS, only the first SetProperties
/// gets executed server-side and any other (sent at the same time) fails.
///
/// The server will broadcast successfully changed values and the local "cache" of customProperties
/// only gets updated after a roundtrip (if anything changed).
///
/// You can do a "webForward": Photon will send the changed properties to a WebHook defined
/// for your application.
///
/// <b>OfflineMode</b>
///
/// While PhotonNetwork.offlineMode is true, the expectedValues and webForward parameters are ignored.
/// In OfflineMode, the local customProperties values are immediately updated (without the roundtrip).
/// </remarks>
/// <param name="propertiesToSet">The new properties to be set. </param>
/// <param name="expectedValues">At least one property key/value set to check server-side. Key and value must be correct. Ignored in OfflineMode.</param>
/// <param name="webForward">Set to true, to forward the set properties to a WebHook, defined for this app (in Dashboard). Ignored in OfflineMode.</param>
public void SetCustomProperties(Hashtable propertiesToSet, Hashtable expectedValues = null, bool webForward = false)
{
if (propertiesToSet == null)
{
return;
}
Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
Hashtable customPropsToCheck = expectedValues.StripToStringKeys() as Hashtable;
// no expected values -> set and callback
bool noCas = customPropsToCheck == null || customPropsToCheck.Count == 0;
bool inOnlineRoom = this.actorID > 0 && !PhotonNetwork.offlineMode;
if (inOnlineRoom)
{
PhotonNetwork.networkingPeer.OpSetPropertiesOfActor(this.actorID, customProps, customPropsToCheck, webForward);
}
if (!inOnlineRoom || noCas)
{
this.InternalCacheProperties(customProps);
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged, this, customProps);
}
}
示例7: SetCustomProperties
public void SetCustomProperties(Hashtable propertiesToSet, Hashtable expectedValues)
{
if (propertiesToSet == null)
{
return;
}
if (this.actorID > 0 && !PhotonNetwork.offlineMode)
{
Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
Hashtable customPropsToCheck = expectedValues.StripToStringKeys() as Hashtable;
PhotonNetwork.networkingPeer.OpSetPropertiesOfActor(this.actorID, customProps, false, 0, customPropsToCheck);
}
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged, this, propertiesToSet);
}
示例8: SetCustomProperties
/// <summary>
/// Updates the this player's Custom Properties with new/updated key-values.
/// </summary>
/// <remarks>
/// Custom Properties are a key-value set (Hashtable) which is available to all players in a room.
/// They can relate to the room or individual players and are useful when only the current value
/// of something is of interest. For example: The map of a room.
/// All keys must be strings.
///
/// The Room and the PhotonPlayer class both have SetCustomProperties methods.
/// Also, both classes offer access to current key-values by: customProperties.
///
/// Always use SetCustomProperties to change values.
/// To reduce network traffic, set only values that actually changed.
/// New properties are added, existing values are updated.
/// Other values will not be changed, so only provide values that changed or are new.
///
/// To delete a named (custom) property of this room, use null as value.
///
/// Locally, SetCustomProperties will update it's cache without delay.
/// Other clients are updated through Photon (the server) with a fitting operation.
///
/// <b>Check and Swap</b>
///
/// SetCustomProperties have the option to do a server-side Check-And-Swap (CAS):
/// Values only get updated if the expected values are correct.
/// The expectedValues can be different key/values than the propertiesToSet. So you can
/// check some key and set another key's value (if the check succeeds).
///
/// If the client's knowledge of properties is wrong or outdated, it can't set values with CAS.
/// This can be useful to keep players from concurrently setting values. For example: If all players
/// try to pickup some card or item, only one should get it. With CAS, only the first SetProperties
/// gets executed server-side and any other (sent at the same time) fails.
///
/// The server will broadcast successfully changed values and the local "cache" of customProperties
/// only gets updated after a roundtrip (if anything changed).
///
/// You can do a "webForward": Photon will send the changed properties to a WebHook defined
/// for your application.
///
/// <b>OfflineMode</b>
///
/// While PhotonNetwork.offlineMode is true, the expectedValues and webForward parameters are ignored.
/// In OfflineMode, the local customProperties values are immediately updated (without the roundtrip).
/// </remarks>
/// <param name="propertiesToSet">The new properties to be set. </param>
/// <param name="expectedValues">At least one property key/value set to check server-side. Key and value must be correct. Ignored in OfflineMode.</param>
/// <param name="webForward">Set to true, to forward the set properties to a WebHook, defined for this app (in Dashboard). Ignored in OfflineMode.</param>
public void SetCustomProperties(Hashtable propertiesToSet, Hashtable expectedValues = null, bool webForward = false)
{
if (propertiesToSet == null)
{
return;
}
if (this.actorID > 0 && !PhotonNetwork.offlineMode)
{
Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
Hashtable customPropsToCheck = expectedValues.StripToStringKeys() as Hashtable;
PhotonNetwork.networkingPeer.OpSetPropertiesOfActor(this.actorID, customProps, customPropsToCheck, webForward);
}
else
{
Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
this.InternalCacheProperties(customProps);
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged, customProps);
}
}
示例9: SetCustomProperties
/// <summary>
/// Updates and synchronizes this Player's Custom Properties. Optionally, expectedProperties can be provided as condition.
/// </summary>
/// <remarks>
/// Custom Properties are a set of string keys and arbitrary values which is synchronized
/// for the players in a Room. They are available when the client enters the room, as
/// they are in the response of OpJoin and OpCreate.
///
/// Custom Properties either relate to the (current) Room or a Player (in that Room).
///
/// Both classes locally cache the current key/values and make them available as
/// property: CustomProperties. This is provided only to read them.
/// You must use the method SetCustomProperties to set/modify them.
///
/// Any client can set any Custom Properties anytime. It's up to the game logic to organize
/// how they are best used.
///
/// You should call SetCustomProperties only with key/values that are new or changed. This reduces
/// traffic and performance.
///
/// Unless you define some expectedProperties, setting key/values is always permitted.
/// In this case, the property-setting client will not receive the new values from the server but
/// instead update its local cache in SetCustomProperties.
///
/// If you define expectedProperties, the server will skip updates if the server property-cache
/// does not contain all expectedProperties with the same values.
/// In this case, the property-setting client will get an update from the server and update it's
/// cached key/values at about the same time as everyone else.
///
/// The benefit of using expectedProperties can be only one client successfully sets a key from
/// one known value to another.
/// As example: Store who owns an item in a Custom Property "ownedBy". It's 0 initally.
/// When multiple players reach the item, they all attempt to change "ownedBy" from 0 to their
/// actorNumber. If you use expectedProperties {"ownedBy", 0} as condition, the first player to
/// take the item will have it (and the others fail to set the ownership).
///
/// Properties get saved with the game state for Turnbased games (which use IsPersistent = true).
/// </remarks>
/// <param name="propertiesToSet">Hashtable of Custom Properties that changes.</param>
/// <param name="expectedProperties">Provide some keys/values to use as condition for setting the new values.</param>
public void SetCustomProperties(Hashtable propertiesToSet, Hashtable expectedProperties = null)
{
Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
// merge (and delete null-values), unless we use CAS (expected props)
if (expectedProperties == null)
{
this.CustomProperties.Merge(customProps);
this.CustomProperties.StripKeysWithNullValues();
}
// send (sync) these new values if in room
if (this.RoomReference != null && this.RoomReference.IsLocalClientInside)
{
this.LoadBalancingClient.loadBalancingPeer.OpSetPropertiesOfActor(this.actorID, customProps, expectedProperties);
}
}
示例10: SetCustomProperties
/// <summary>
/// Updates and synchronizes the named properties of this Room with the values of propertiesToSet.
/// </summary>
/// <remarks>
/// Any player can set a Room's properties. Room properties are available until changed, deleted or
/// until the last player leaves the room.
/// Access them by: Room.CustomProperties (read-only!).
///
/// New properties are added, existing values are updated.
/// Other values will not be changed, so only provide values that changed or are new.
/// To delete a named (custom) property of this room, use null as value.
/// Only string-typed keys are applied (everything else is ignored).
///
/// Local cache is updated immediately, other clients are updated through Photon with a fitting operation.
/// To reduce network traffic, set only values that actually changed.
/// </remarks>
/// <param name="propertiesToSet">Hashtable of props to udpate, set and sync. See description.</param>
public virtual void SetCustomProperties(Hashtable propertiesToSet)
{
Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
// merge (delete null-values)
this.CustomProperties.Merge(customProps);
this.CustomProperties.StripKeysWithNullValues();
// send (sync) these new values if in room
if (this.IsLocalClientInside)
{
this.LoadBalancingClient.OpSetCustomPropertiesOfRoom(customProps, true);
}
}
示例11: SetCustomProperties
/// <summary>
/// Updates and synchronizes this Room's Custom Properties. Optionally, expectedProperties can be provided as condition.
/// </summary>
/// <remarks>
/// Custom Properties are a set of string keys and arbitrary values which is synchronized
/// for the players in a Room. They are available when the client enters the room, as
/// they are in the response of OpJoin and OpCreate.
///
/// Custom Properties either relate to the (current) Room or a Player (in that Room).
///
/// Both classes locally cache the current key/values and make them available as
/// property: CustomProperties. This is provided only to read them.
/// You must use the method SetCustomProperties to set/modify them.
///
/// Any client can set any Custom Properties anytime. It's up to the game logic to organize
/// how they are best used.
///
/// You should call SetCustomProperties only with key/values that are new or changed. This reduces
/// traffic and performance.
///
/// Unless you define some expectedProperties, setting key/values is always permitted.
/// In this case, the property-setting client will not receive the new values from the server but
/// instead update its local cache in SetCustomProperties.
///
/// If you define expectedProperties, the server will skip updates if the server property-cache
/// does not contain all expectedProperties with the same values.
/// In this case, the property-setting client will get an update from the server and update it's
/// cached key/values at about the same time as everyone else.
///
/// The benefit of using expectedProperties can be only one client successfully sets a key from
/// one known value to another.
/// As example: Store who owns an item in a Custom Property "ownedBy". It's 0 initally.
/// When multiple players reach the item, they all attempt to change "ownedBy" from 0 to their
/// actorNumber. If you use expectedProperties {"ownedBy", 0} as condition, the first player to
/// take the item will have it (and the others fail to set the ownership).
///
/// Properties get saved with the game state for Turnbased games (which use IsPersistent = true).
/// </remarks>
/// <param name="propertiesToSet">Hashtable of Custom Properties that changes.</param>
/// <param name="expectedProperties">Provide some keys/values to use as condition for setting the new values.</param>
public virtual void SetCustomProperties(Hashtable propertiesToSet, Hashtable expectedProperties = null)
{
Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
// merge (and delete null-values), unless we use CAS (expected props)
if (expectedProperties == null || expectedProperties.Count == 0)
{
this.CustomProperties.Merge(customProps);
this.CustomProperties.StripKeysWithNullValues();
}
// send (sync) these new values if in room
if (this.IsLocalClientInside)
{
this.LoadBalancingClient.loadBalancingPeer.OpSetPropertiesOfRoom(customProps, false, expectedProperties);
}
}
示例12: SetCustomProperties
/// <summary>
/// Updates and synchronizes the named properties of this Player with the values of propertiesToSet.
/// </summary>
/// <remarks>
/// Any player's properties are available in a Room only and only until the player disconnect or leaves.
/// Access any player's properties by: Player.CustomProperties (read-only!) but don't modify that hashtable.
///
/// New properties are added, existing values are updated.
/// Other values will not be changed, so only provide values that changed or are new.
/// To delete a named (custom) property of this player, use null as value.
/// Only string-typed keys are applied (everything else is ignored).
///
/// Local cache is updated immediately, other players are updated through Photon with a fitting operation.
/// To reduce network traffic, set only values that actually changed.
/// </remarks>
/// <param name="propertiesToSet">Hashtable of props to udpate, set and sync. See description.</param>
public void SetCustomProperties(Hashtable propertiesToSet)
{
Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
// merge (delete null-values)
this.CustomProperties.Merge(customProps);
this.CustomProperties.StripKeysWithNullValues();
// send (sync) these new values if in room
if (this.RoomReference != null && this.RoomReference.IsLocalClientInside)
{
this.RoomReference.LoadBalancingClient.OpSetCustomPropertiesOfActor(this.actorID, customProps);
}
}