本文整理汇总了C#中ExitGames.Client.Photon.Hashtable.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Hashtable.Add方法的具体用法?C# Hashtable.Add怎么用?C# Hashtable.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExitGames.Client.Photon.Hashtable
的用法示例。
在下文中一共展示了Hashtable.Add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
private Client client; // Socket
void Start()
{
this.client = GameObject.Find("Manager").GetComponent<ClientManager>().Client;
user = User.Instance;
if (user.is_connected)
{
PhotonNetwork.playerName = user.username;
PhotonPeer.RegisterType(typeof(Team), (byte)'T', ObjectToByteArray, ByteToTeam);
PhotonPeer.RegisterType(typeof(Composition), (byte)'C', ObjectToByteArray, ByteToComposition);
PhotonPeer.RegisterType(typeof(Player), (byte)'P', ObjectToByteArray, ByteToPlayer);
PhotonPeer.RegisterType(typeof(User), (byte)'U', ObjectToByteArray, ByteToUser);
PhotonPeer.RegisterType(typeof(List<string>), (byte)'L', ObjectToByteArray, ByteToLS);
PhotonHastable props = new PhotonHastable();
props.Add("Team", Settings.Instance.Selected_Team);
props.Add("User", user);
PhotonNetwork.player.SetCustomProperties(props);
PhotonNetwork.ConnectUsingSettings(game_version_);
this.room_name = user.username + "-" + rand.Next(1000);
}
}
示例2: ReceiveInitialSpawnInfo
void ReceiveInitialSpawnInfo(int id, PhotonPlayer player, Vector3 pos, Quaternion rot, string playerTypeName, int teamNumber, PhotonMessageInfo info)
{
if ((info.sender != PhotonNetwork.masterClient) &&
(info.sender != PhotonNetwork.player))
return;
// initialize the newborn player with the mandatory 'on-join-stats'
ExitGames.Client.Photon.Hashtable stats = new ExitGames.Client.Photon.Hashtable();
stats.Add("Type", playerTypeName);
stats.Add("Team", teamNumber);
stats.Add("Position", pos);
stats.Add("Rotation", rot);
// announce arrival of new player
if (player.ID > PhotonNetwork.player.ID)
vp_MPDebug.Log("Player " + player.name + " joined"
+ ((vp_MPTeamManager.Exists && (teamNumber > 0)) ? " team : " + vp_MPTeamManager.GetTeamName(teamNumber).ToUpper() : "")
);
else if (player.ID == PhotonNetwork.player.ID)
{
vp_Timer.In(0.1f, delegate()
{
//Debug.Log("teamNumber: " + teamNumber);
try
{
vp_MPDebug.Log(
"Welcome to '"
+ PhotonNetwork.room.name
+ "' with "
+ PhotonNetwork.room.playerCount.ToString()
+ ((PhotonNetwork.room.playerCount == 1) ? " player (you)" : " players")
+ "."
);
//vp_MPDebug.Log("Max players for room: " + PhotonNetwork.room.maxPlayers + ".");
//vp_MPDebug.Log("Total players using app: " + PhotonNetwork.countOfPlayers);
if (vp_MPTeamManager.Exists && (teamNumber > 0))
vp_MPDebug.Log("Your team is: " + vp_MPTeamManager.GetTeamName(teamNumber).ToUpper());
}
catch
{
if (PhotonNetwork.room == null)
Debug.Log("PhotonNetwork.room = null");
else if (PhotonNetwork.room.name == null)
Debug.Log("PhotonNetwork.room.name = null");
if (vp_MPTeamManager.Instance == null)
Debug.Log("vp_MPTeamManager.Instance = null");
else if (vp_MPTeamManager.GetTeamName(teamNumber) == null)
Debug.Log("vp_MPMaster.GetTeamName(teamNumber) = null");
}
});
}
InstantiatePlayerPrefab(player, stats);
}
示例3: OnJoinedRoom
/// <summary>
/// Callback used when the player successfully joins a room.
/// </summary>
public void OnJoinedRoom()
{
playersInRoom = new List<PhotonPlayer>(PhotonNetwork.playerList);
myTeam = (TeamTypes)((playersInRoom.Count + 1) % 2);
ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
properties.Add("Team", myTeam.GetHashCode());
properties.Add("Character", myCharacter.GetHashCode());
properties.Add("PlayFabID", PlayFabManager.instance.GetMyPlayerID());
bool containsOwner = false;
for (int i = 0; i < PhotonNetwork.otherPlayers.Length; i++)
{
object ownerName;
if (PhotonNetwork.otherPlayers[i].customProperties.TryGetValue("Owner", out ownerName))
{
containsOwner = true;
break;
}
}
if (!containsOwner)
{
properties.Add("Owner", PhotonNetwork.player.name);
}
PhotonNetwork.player.SetCustomProperties(properties);
myRoomInfo = PhotonNetwork.room;
OnJoinedRoomCallback(PhotonNetwork.room);
}
示例4: SetReady
/// <summary>
/// Updates player status to ready.
/// </summary>
public void SetReady()
{
ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
properties.Add("Ready", true);
PhotonNetwork.player.SetCustomProperties(properties);
networkLayer.OnPropertiesChanged();
}
示例5: ChangeTeam
/// <summary>
/// Rotates player between teams.
/// </summary>
public void ChangeTeam(TeamTypes newTeam, bool syncNetwork)
{
myTeam = newTeam;
ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
properties.Add("Team", myTeam.GetHashCode());
PhotonNetwork.player.SetCustomProperties(properties);
if (syncNetwork)
{
networkLayer.OnPropertiesChanged();
}
}
示例6: ChangePlayerAvatar
/// <summary>
/// Changes player avatar, to the one the player has chosen.
/// </summary>
/// <param name="myType">New character.</param>
/// <param name="syncNetwork">If will send data to the network.</param>
public void ChangePlayerAvatar(CharacterTypes myType, bool syncNetwork)
{
if (myCharacter != myType)
{
myCharacter = myType;
ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
properties.Add("Character", myCharacter.GetHashCode());
PhotonNetwork.player.SetCustomProperties(properties);
if (syncNetwork)
{
networkLayer.OnPropertiesChanged();
}
}
}
示例7: StartGame
/// <summary>
/// Starts game.
/// </summary>
public void StartGame()
{
ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
properties.Add("Ready", false);
PhotonNetwork.player.SetCustomProperties(properties);
networkLayer.ActivateLevel();
//networkLayer.AllocateViewIDAndCallInstantiate(myCharacter, myTeam);
}
示例8: CreateNewRoom
/// <summary>
/// Method to be called when the user wants to create a new room.
/// </summary>
public void CreateNewRoom(int numberOfPlayers,ProjectDelegates.RoomInfoCallback RoomCreatedCallback, int level)
{
OnJoinedRoomCallback = RoomCreatedCallback;
ExitGames.Client.Photon.Hashtable customParams = new ExitGames.Client.Photon.Hashtable();
customParams.Add("C0", level);
RoomOptions options = new RoomOptions();
options.maxPlayers = numberOfPlayers;
TypedLobby typedLobby = new TypedLobby("GameLobby",LobbyType.Default);
//PhotonNetwork.CreateRoom ("",options,typedLobby);
//PhotonNetwork.CreateRoom ("", true, true, numberOfPlayers);
// testing this to git rid of the build warning
PhotonNetwork.CreateRoom("", options, typedLobby);
}
示例9: OnJoinedRoom
// We have two options here: we either joined(by title, list or random) or created a room.
public override void OnJoinedRoom()
{
Debug.Log("OnJoinedRoom");
Hashtable e = new Hashtable();
e.Add("PName", LocalName);
bool master = (PhotonNetwork.player.isMasterClient) ? true : false;
e.Add("Ready", master);
PhotonNetwork.player.SendReady(master);
PhotonNetwork.RaiseEvent(EventID.PlayerJoinPre, e, true, new RaiseEventOptions() { Receivers = ReceiverGroup.All });
}
示例10: Ready
/// <summary>
/// change the state and sync for other players
/// </summary>
public void Ready()
{
isReady = !isReady;
PhotonNetwork.player.SendReady(isReady);
Hashtable e = new Hashtable();
e.Add("PName",LocalName);
e.Add("Ready",isReady);
PhotonNetwork.RaiseEvent(EventID.PlayerJoinPre, e, true, new RaiseEventOptions() { Receivers = ReceiverGroup.All});
}
示例11: LoadSyncLevel
/// <summary>
/// Load and sync level
/// Only masterclient can call this function
/// </summary>
public void LoadSyncLevel()
{
//Start game only when all are ready
if (PhotonNetwork.playerList.AllPlayersReady())
{
Hashtable e = new Hashtable();
e.Add("Level", PhotonNetwork.room.RoomScene());
PhotonNetwork.RaiseEvent(EventID.LoadSyncLevel, e, true, new RaiseEventOptions() { Receivers = ReceiverGroup.All });
}
else
{
Debug.Log("Some players are not ready, wait for hes");
}
}