Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 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));
 }