public Invitation(List<Player> invitedPlayers, Player inviter, int id, int invitationTimeOut, Server server) { _server = server; _invitedPlayers = invitedPlayers; _inviter = inviter; _id = id; _timer.Interval = invitationTimeOut; _accepted = new int[invitedPlayers.Count]; _timer.Elapsed += timeOut; _timer.Start(); for (int i = 0; i < _invitedPlayers.Count; i++) { _accepted[i] = -1; } foreach (Player p in invitedPlayers) { p.Invitation = this; p.Context.receiveInvitation(inviter.Username, invitedPlayers.Count, id); server.updatePortalList(); } }
private void loadDatabase() { List<string[]> objectToLoad; _listOfPlayers = new List<Player>(); try { if (System.IO.File.Exists(Properties.Resources.dataBase)) { System.IO.FileStream stream = System.IO.File.Open(Properties.Resources.dataBase, System.IO.FileMode.Open); System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(List<string[]>)); objectToLoad = (List<string[]>)reader.Deserialize(stream); stream.Close(); foreach (string[] str in objectToLoad) { Player pl = new Player(str[0], str[1]); pl.CorrectGuesses = Int32.Parse(str[2]); pl.TotalGuesses = Int32.Parse(str[3]); _listOfPlayers.Add(pl); } } } catch { } }