public ActionResult JoinToGame(WaitingForPlayerData waitingForPlayerData) { WaitingForPlayerData returned = new WaitingForPlayerData(); try { LockListGameDoesntStart.AcquireReaderLock(timeOut); Game game; if (TryGetGameByGuid(waitingForPlayerData, out game) && ValidatingNewGameForPlayer(game)) { if (game != null) { lock (game) { game.Register(UserFiche.CurentUser); returned.GuidGame = game.IdentifyGuid.ToString(); } } } } catch { } finally { LockListGameDoesntStart.ReleaseReaderLock(); } return(Json(returned)); }
public ActionResult WaitingForPlayer() { WaitingForPlayerData waitingForPlayerData = new WaitingForPlayerData(); Logic.MultiPlayer.User userPlayer; Game currentGame; if (Game.CurentMultiPlayerGame != null) { lock (this) { userPlayer = Game.GetUserBySesionFicheUser(); currentGame = Game.CurentMultiPlayerGame; } if (currentGame != null) { waitingForPlayerData = new WaitingForPlayerData() { GuidGame = currentGame.IdentifyGuid.ToString(), UserCanStart = userPlayer.UserCanStart && !currentGame.IsStarted, GameIsStated = currentGame.IsStarted, GameIsEnd = currentGame.IsGameDeactivate, PlayerResults = currentGame.ListPlayer.Select(X => new PlayerResult() { Name = X.LoginToProcess, Point = X.Point }).ToList() }; } } return(View(waitingForPlayerData)); }
public ActionResult WaitingForPlayer(WaitingForPlayerData data) { DTO.Models.ActionResultData result = null; try { LockListGameDoesntStart.AcquireWriterLock(timeOut); result = (DTO.Models.ActionResultData)Game.CurentMultiPlayerGame.Start(); ListGameDoesntStart.Remove(new Guid(data.GuidGame)); } catch { } finally { LockListGameDoesntStart.ReleaseWriterLock(); } return(Json(result)); }