public void SecondGameRequest(Task task) { Task first_Request = null; string gameName = task.GetDetails(); foreach (Task t in pending_requests) { if (t.GetDetails() == gameName) { first_Request = t; break; } } if (first_Request != null) { MultiplayArgs args = new MultiplayArgs(first_Request, task, gameName); current_games.Add(args); MultiplayReady(this, args); } pending_requests.Remove(first_Request); pending_requests.Remove(task); //first_Request.Finished (first_Request, first_Request.Get_Task_Info ().GetJson ()); //task.Finished (task, task.Get_Task_Info ().GetJson ()); }
public void MultiplayReady(object source, MultiplayArgs a) { MultiplayManager manag = (MultiplayManager)source; if (a.t1 == this || a.t2 == this) { manag.MultiplayReady -= this.MultiplayReady; string json = info.GetJson(); FinishedTaskEventArgs finalInfo = new FinishedTaskEventArgs(json, false); Finished(this, finalInfo); } }
public void EndGame(object source, MultiplayArgs a) { MultiplayManager manag = (MultiplayManager)source; if (a.t1 == this || a.t2 == this) { manag.PlayerMoved -= this.PlayerMoved; manag.EndGame -= this.EndGame; FinishedTaskEventArgs info = new FinishedTaskEventArgs("", true); Finished(this, info); } }
public void CloseRequest(Task task) { string gameName = task.Get_Task_Info().GetGameName(); MultiplayArgs args = null; foreach (MultiplayArgs mult in current_games) { if (gameName == mult.t1.Get_Task_Info().GetGameName()) { args = mult; current_games.Remove(mult); break; } } if (args != null) { EndGame(this, args); } }