Hey guys,
okay i’m looking for days and cant find a solution:
I have a server which has a list of alle connected Players. I have designed my own Players with the basic information like team, nation, color and stuff like that.
Each player is able to modiefy the settings of his own player.
So the problem is, i have no idea how to synchronize this list. I need the list on every client to show some kind of multiplayer-lobby like in warcraft3.
So basicly there are 2 questions:
-
How is it possible to create such a list?
-
How can I syncronize the data of each player? there are more complex structures in it.
I’m using c# so i have lots of different classes to synchronize.
I really shouldn’t do this
[RequireComponent(typeof(NetworkView))]
public class ProfileService : MonoBehaviour {
public class Profile {
public string GamerTag;
public string Team;
}
public string GamerName;
public string Team;
public Dictionary<NetworkPlayer, Profile> NetworkProfiles = new Dictionary<NetworkPlayer, Profile>();
void OnConnectedToServer()
{
networkView.RPC("OnProfile", RPCMode.AllBuffered, networkView.owner, GamerName, Team);
}
void OnPlayerDisconnected(NetworkPlayer player)
{
networkView.RPC("OnRemove", RPCMode.AllBuffered, player);
}
[RPC]
void OnProfile(NetworkPlayer player, string gName, string gTeam)
{
NetworkProfiles.Add(player, new Profile { GamerTag = gName, Team = gTeam });
}
[RPC]
void OnRemove(NetworkPlayer player)
{
NetworkProfiles.Remove(player);
}
}