本文整理汇总了C#中ExitGames.Client.Photon.Hashtable类的典型用法代码示例。如果您正苦于以下问题:C# Hashtable类的具体用法?C# Hashtable怎么用?C# Hashtable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hashtable类属于ExitGames.Client.Photon命名空间,在下文中一共展示了Hashtable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearTileClickEvForTurn
public void ClearTileClickEvForTurn(int turnToDelete)
{
Debug.Log("Clean Tile Click for Turn " + turnToDelete);
Hashtable content = new Hashtable();
content[(byte)1] = turnToDelete;
this.loadBalancingPeer.OpRaiseEvent(EvTileClick, content, true, new RaiseEventOptions() { CachingOption = EventCaching.RemoveFromRoomCache });
this.lastTilesClicked[turnToDelete].Clear();
}
示例2: PhotonPlayer
/// <summary>
/// Internally used to create players from event Join
/// </summary>
protected internal PhotonPlayer(bool isLocal, int actorID, Hashtable properties)
{
this.customProperties = new Hashtable();
this.isLocal = isLocal;
this.actorID = actorID;
this.InternalCacheProperties(properties);
}
示例3: Player
/// <summary>
/// Creates a player instance.
/// To extend and replace this Player, override LoadBalancingPeer.CreatePlayer().
/// </summary>
/// <param name="nickName">NickName of the player (a "well known property").</param>
/// <param name="actorID">ID or ActorNumber of this player in the current room (a shortcut to identify each player in room)</param>
/// <param name="isLocal">If this is the local peer's player (or a remote one).</param>
/// <param name="playerProperties">A Hashtable of custom properties to be synced. Must use String-typed keys and serializable datatypes as values.</param>
protected internal Player(string nickName, int actorID, bool isLocal, Hashtable playerProperties)
{
this.IsLocal = isLocal;
this.actorID = actorID;
this.NickName = nickName;
this.CustomProperties = new Hashtable();
this.CacheProperties(playerProperties);
}
示例4: Room
protected internal Room(string roomName, Hashtable roomProperties, bool isVisible, bool isOpen, byte maxPlayers, string[] propsListedInLobby)
: base(roomName, roomProperties)
{
// base sets name and (custom)properties. here we set "well known" properties
this.isVisible = isVisible;
this.isOpen = isOpen;
this.maxPlayers = maxPlayers;
this.PropsListedInLobby = propsListedInLobby;
}
示例5: ParticlePlayer
public ParticlePlayer(string nickName, int actorID, bool isLocal, Hashtable actorProperties)
: base(nickName, actorID, isLocal, actorProperties)
{
if (isLocal)
{
// we pick a random color when we create a local player
this.RandomizeColor();
}
}
示例6: OpCreateRoom
/// <summary>
/// Don't use this method directly, unless you know how to cache and apply customActorProperties.
/// The PhotonNetwork methods will handle player and room properties for you and call this method.
/// </summary>
public virtual bool OpCreateRoom(string roomName, RoomOptions roomOptions, TypedLobby lobby, Hashtable playerProperties, bool onGameServer)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.Listener.DebugReturn(DebugLevel.INFO, "OpCreateRoom()");
}
Dictionary<byte, object> op = new Dictionary<byte, object>();
if (!string.IsNullOrEmpty(roomName))
{
op[ParameterCode.RoomName] = roomName;
}
if (lobby != null)
{
op[ParameterCode.LobbyName] = lobby.Name;
op[ParameterCode.LobbyType] = (byte)lobby.Type;
}
if (onGameServer)
{
if (playerProperties != null && playerProperties.Count > 0)
{
op[ParameterCode.PlayerProperties] = playerProperties;
op[ParameterCode.Broadcast] = true; // TODO: check if this also makes sense when creating a room?! // broadcast actor properties
}
if (roomOptions == null)
{
roomOptions = new RoomOptions();
}
Hashtable gameProperties = new Hashtable();
op[ParameterCode.GameProperties] = gameProperties;
gameProperties.MergeStringKeys(roomOptions.customRoomProperties);
gameProperties[GameProperties.IsOpen] = roomOptions.isOpen; // TODO: check default value. dont send this then
gameProperties[GameProperties.IsVisible] = roomOptions.isVisible; // TODO: check default value. dont send this then
gameProperties[GameProperties.PropsListedInLobby] = roomOptions.customRoomPropertiesForLobby;
if (roomOptions.maxPlayers > 0)
{
gameProperties[GameProperties.MaxPlayers] = roomOptions.maxPlayers;
}
if (roomOptions.cleanupCacheOnLeave)
{
op[ParameterCode.CleanupCacheOnLeave] = true; // this is actually setting the room's config
gameProperties[GameProperties.CleanupCacheOnLeave] = true; // this is only informational for the clients which join
}
}
// UnityEngine.Debug.Log("CreateGame: " + SupportClass.DictionaryToString(op));
return this.OpCustom(OperationCode.CreateGame, op, true);
}
示例7: OnEventCustom
/// <summary>
/// Receive events from server
/// </summary>
/// <param name="eventCode"></param>
/// <param name="content"></param>
/// <param name="senderID"></param>
public void OnEventCustom(byte eventCode, object content, int senderID)
{
Debug.Log(string.Format("OnEventRaised: {0}, {1}, {2}", eventCode, content, senderID));
Hashtable hash = new Hashtable();
hash = (Hashtable)content;
switch (eventCode)
{
case EventID.LoadSyncLevel:
string s = (string)hash["Level"];
NextLevel = s;
InvokeRepeating("InvokeLoad", 1, 1);
break;
case EventID.PlayerJoinPre:
//
break;
}
}
示例8: OpCreateRoom
/// <summary>
/// Don't use this method directly, unless you know how to cache and apply customActorProperties.
/// The PhotonNetwork methods will handle player and room properties for you and call this method.
/// </summary>
public virtual bool OpCreateRoom(string gameID, bool isVisible, bool isOpen, byte maxPlayers, bool autoCleanUp, Hashtable customGameProperties, Hashtable customPlayerProperties, string[] customRoomPropertiesForLobby)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.Listener.DebugReturn(DebugLevel.INFO, "OpCreateRoom()");
}
Hashtable gameProperties = new Hashtable();
gameProperties[GameProperties.IsOpen] = isOpen;
gameProperties[GameProperties.IsVisible] = isVisible;
gameProperties[GameProperties.PropsListedInLobby] = customRoomPropertiesForLobby;
gameProperties.MergeStringKeys(customGameProperties);
if (maxPlayers > 0)
{
gameProperties[GameProperties.MaxPlayers] = maxPlayers;
}
Dictionary<byte, object> op = new Dictionary<byte, object>();
op[ParameterCode.GameProperties] = gameProperties;
op[ParameterCode.Broadcast] = true;
if (customPlayerProperties != null)
{
op[ParameterCode.PlayerProperties] = customPlayerProperties;
}
if (!string.IsNullOrEmpty(gameID))
{
op[ParameterCode.RoomName] = gameID;
}
// server's default is 'false', so we actually only need to send this when 'true'
if (autoCleanUp)
{
op[ParameterCode.CleanupCacheOnLeave] = autoCleanUp;
gameProperties[GameProperties.CleanupCacheOnLeave] = autoCleanUp;
}
return this.OpCustom(OperationCode.CreateGame, op, true);
}
示例9: GetActorPropertiesForActorNr
private Hashtable GetActorPropertiesForActorNr(Hashtable actorProperties, int actorNr)
{
if (actorProperties.ContainsKey(actorNr))
{
return (Hashtable)actorProperties[actorNr];
}
return actorProperties;
}
示例10: ReadoutProperties
// gameID can be null (optional). The server assigns a unique name if no name is set
// joins a room and sets your current username as custom actorproperty (will broadcast that)
#endregion
#region Helpers
private void ReadoutProperties(Hashtable gameProperties, Hashtable pActorProperties, int targetActorNr)
{
// Debug.LogWarning("ReadoutProperties gameProperties: " + gameProperties.ToStringFull() + " pActorProperties: " + pActorProperties.ToStringFull() + " targetActorNr: " + targetActorNr);
// read game properties and cache them locally
if (this.mCurrentGame != null && gameProperties != null)
{
this.mCurrentGame.CacheProperties(gameProperties);
SendMonoMessage(PhotonNetworkingMessage.OnPhotonCustomRoomPropertiesChanged, gameProperties);
if (PhotonNetwork.automaticallySyncScene)
{
this.LoadLevelIfSynced(); // will load new scene if sceneName was changed
}
}
if (pActorProperties != null && pActorProperties.Count > 0)
{
if (targetActorNr > 0)
{
// we have a single entry in the pActorProperties with one
// user's name
// targets MUST exist before you set properties
PhotonPlayer target = this.GetPlayerWithID(targetActorNr);
if (target != null)
{
Hashtable props = this.GetActorPropertiesForActorNr(pActorProperties, targetActorNr);
target.InternalCacheProperties(props);
SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged, target, props);
}
}
else
{
// in this case, we've got a key-value pair per actor (each
// value is a hashtable with the actor's properties then)
int actorNr;
Hashtable props;
string newName;
PhotonPlayer target;
foreach (object key in pActorProperties.Keys)
{
actorNr = (int)key;
props = (Hashtable)pActorProperties[key];
newName = (string)props[ActorProperties.PlayerName];
target = this.GetPlayerWithID(actorNr);
if (target == null)
{
target = new PhotonPlayer(false, actorNr, newName);
this.AddNewPlayer(actorNr, target);
}
target.InternalCacheProperties(props);
SendMonoMessage(PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged, target, props);
}
}
}
}
示例11: OpSetPropertyOfRoom
protected void OpSetPropertyOfRoom(byte propCode, object value)
{
Hashtable properties = new Hashtable();
properties[propCode] = value;
this.OpSetPropertiesOfRoom(properties, expectedProperties: null, webForward: false);
}
示例12: OpSetPropertiesOfActor
/// <summary>
/// Sets properties of a player / actor.
/// Internally this uses OpSetProperties, which can be used to either set room or player properties.
/// </summary>
/// <param name="actorNr">The payer ID (a.k.a. actorNumber) of the player to attach these properties to.</param>
/// <param name="actorProperties">The properties to add or update.</param>
/// <param name="expectedProperties">If set, these must be in the current properties-set (on the server) to set actorProperties: CAS.</param>
/// <param name="webForward">Set to true, to forward the set properties to a WebHook, defined for this app (in Dashboard).</param>
/// <returns>If the operation could be sent (requires connection).</returns>
protected internal bool OpSetPropertiesOfActor(int actorNr, Hashtable actorProperties, Hashtable expectedProperties = null, bool webForward = false)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.Listener.DebugReturn(DebugLevel.INFO, "OpSetPropertiesOfActor()");
}
if (actorNr <= 0 || actorProperties == null)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.Listener.DebugReturn(DebugLevel.INFO, "OpSetPropertiesOfActor not sent. ActorNr must be > 0 and actorProperties != null.");
}
return false;
}
Dictionary<byte, object> opParameters = new Dictionary<byte, object>();
opParameters.Add(ParameterCode.Properties, actorProperties);
opParameters.Add(ParameterCode.ActorNr, actorNr);
opParameters.Add(ParameterCode.Broadcast, true);
if (expectedProperties != null && expectedProperties.Count != 0)
{
opParameters.Add(ParameterCode.ExpectedValues, expectedProperties);
}
if (webForward)
{
opParameters[ParameterCode.EventForward] = true;
}
//UnityEngine.Debug.Log(opParameters.ToStringFull());
return this.OpCustom((byte)OperationCode.SetProperties, opParameters, true, 0, false);
}
示例13: OpSetCustomPropertiesOfActor
public bool OpSetCustomPropertiesOfActor(int actorNr, Hashtable actorProperties)
{
return this.OpSetPropertiesOfActor(actorNr, actorProperties.StripToStringKeys(), null);
}
示例14: OnPhotonCustomRoomPropertiesChanged
/// <summary>
/// Called when a room's custom properties changed. The propertiesThatChanged contains all that was set via Room.SetCustomProperties.
/// </summary>
/// <remarks>
/// Since v1.25 this method has one parameter: Hashtable propertiesThatChanged.<br/>
/// Changing properties must be done by Room.SetCustomProperties, which causes this callback locally, too.
/// </remarks>
/// <param name="propertiesThatChanged"></param>
public virtual void OnPhotonCustomRoomPropertiesChanged(Hashtable propertiesThatChanged)
{
}
示例15: OpJoinRandomRoom
/// <summary>NetworkingPeer.OpJoinRandomRoom</summary>
/// <remarks>this override just makes sure we have a mRoomToGetInto, even if it's blank (the properties provided in this method are filters. they are not set when we join the game)</remarks>
public override bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
{
this.mRoomToGetInto = new Room(null, null);
this.mRoomToEnterLobby = null; // join random never stores the lobby. the following join will not affect the room lobby
// if typedLobby is null, the server will automatically use the active lobby or default, which is what we want anyways
this.mLastJoinType = JoinType.JoinRandomGame;
return base.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, playerProperties, matchingType, typedLobby, sqlLobbyFilter);
}