/// <summary> /// Implements the execution of the sendMousePoint command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(GameService current, GameSessions sessions, string message) { if (null == current.Context.BuddyInstance) { sessions.SendMessage(current, "SendMousePointResponse:Failure;Buddy not found."); return; } else { if (string.IsNullOrEmpty(message)) { sessions.SendMessage(current, "SendMousePointResponse:Failure;Co-ordinates are not found in the request."); return; } string[] location = message.Split(new char[] { ';' }); if (location.Length != 2) { sessions.SendMessage(current, "SendMousePointResponse:Failure;Co-ordinates are in incorrect format."); return; } sessions.SendMessage(current.Context.BuddyInstance, "FixMousePoint:" + location[0] + ";" + location[1]); sessions.SendMessage(current, "SendMousePointResponse:Successful"); } }
/// <summary> /// Implements the execution of SendJigSawCoordinates command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(JigsawGameService current, GameSessions sessions, string message) { if (null == current.Context.PlayerInstance) { sessions.SendMessage(current, "SendJigSawCoordinatesResponse:Failure;PlayerNotFound."); return; } else { if (string.IsNullOrEmpty(message)) { sessions.SendMessage(current, "SendJigSawCoordinatesResponse:Failure;WrongFormat."); return; } string[] location = message.Split(new char[] { ';' }); if (location.Length != 3) { sessions.SendMessage(current, "SendJigSawCoordinatesResponse:Failure;WrongFormat."); return; } sessions.SendMessage(current.Context.PlayerInstance, "FixJigSawCoordinates:" + location[0] + ";" + location[1] + ";" + location[2]); sessions.SendMessage(current, "SendJigSawCoordinatesResponse:Successful"); } }
/// <summary> /// Implements execution of this command. /// </summary> /// <param name="current">Current gameservice instance.</param> /// <param name="sessions">Collection of all sessons.</param> /// <param name="message">Command parameters.</param> public void Execute(JigsawGameService current, GameSessions sessions, string message) { if (null == current.Context.PlayerInstance) { sessions.SendMessage(current, "GameCompleteResponse:Failure;Player does not exist."); return; } else { JigsawGameService playerInstance = current.Context.PlayerInstance; lock (gameCompleteLock) { if (null != playerInstance) { playerInstance.Context.PlayerInstance = null; } if (null != current) { current.Context.PlayerInstance = null; } // Need to send gameComplete response to the current service, gameComplete to playerInstance // and also we need to braodcast gameCompleteResponse to all other sessions. sessions.BroadcastMessage(BroadcastMessageType.GameCompleteResponse, current, playerInstance, "GameCompleteResponse:Successful", "GameComplete"); return; } } }
/// <summary> /// Implements the execution of the sendDotPoint command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(GameService current, GameSessions sessions, string message) { if (null == current.Context.BuddyInstance) { sessions.SendMessage(current, "SendDotPointResponse:Failure;BuddyNotFound."); return; } else { if (string.IsNullOrEmpty(message)) { sessions.SendMessage(current, "SendDotPointResponse:Failure;WrongFormat."); return; } string[] location = message.Split(new char[] { ';' }); if (location.Length != 2) { sessions.SendMessage(current, "SendDotPointResponse:Failure;WrongFormat."); return; } sessions.SendMessage(current.Context.BuddyInstance, "FixDotPoint:" + location[0] + ";" + location[1]); sessions.SendMessage(current, "SendDotPointResponse:Successful"); } }
/// <summary> /// Implements the execution of login command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(GameService current, GameSessions sessions, string message) { if (!string.IsNullOrEmpty(current.Context.LogOnName)) { sessions.SendMessage(current, "LoginResponse:Failure;Loggedin"); return; } if (string.IsNullOrEmpty(message)) { sessions.SendMessage(current, "LoginResponse:Failure;LoginNameEmpty"); return; } var service = sessions.FindSession(message); if (null == service && loggedInUsers < MaxUsers) { Interlocked.Increment(ref loggedInUsers); current.Context.LogOnName = message; // Need to send successful response to the current service and LogOn response to all other sessions. // so that other sessions can also see that this user is logged in. sessions.BroadcastMessage(BroadcastMessageType.LogOnResponse, current, null, "LoginResponse:Successful", null); } else if (MaxUsers == loggedInUsers) { sessions.SendMessage(current, "LoginResponse:Failure;LoginLimitReached"); } else { sessions.SendMessage(current, "LoginResponse:Failure;LoginNameTaken"); } }
/// <summary> /// Implements the execution of the ResetTile command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(JigsawGameService current, GameSessions sessions, string message) { if (null == current.Context.PlayerInstance) { sessions.SendMessage(current, "ResetTileResponse:Failure;PlayerNotFound."); return; } else { if (string.IsNullOrEmpty(message)) { sessions.SendMessage(current, "ResetTileResponse:Failure;WrongFormat."); return; } string[] selectedTile = message.Split(new char[] { ';' }); if (selectedTile.Length != 1) { sessions.SendMessage(current, "ResetTileResponse:Failure;WrongFormat."); return; } sessions.SendMessage(current.Context.PlayerInstance, "ResetTileBack:" + selectedTile[0]); sessions.SendMessage(current, "ResetTileResponse:Successful"); } }
// Use this for initialization void Start() { SetUpMoveBoundaries(); laserPrefabs = laser; gameSessions = FindObjectOfType <GameSessions>(); gameSessions.SetHealth(health); }
/// <summary> /// Implements the execution of the DisableTile command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(JigsawGameService current, GameSessions sessions, string message) { if (null == current.Context.PlayerInstance) { sessions.SendMessage(current, "DisableTileResponse:Failure;PlayerNotFound."); return; } else { if (string.IsNullOrEmpty(message)) { sessions.SendMessage(current, "DisableTileResponse:Failure;WrongFormat."); return; } string[] selectedTile = message.Split(new char[] { ';' }); if (selectedTile.Length != 1) { sessions.SendMessage(current, "DisableTileResponse:Failure;WrongFormat."); return; } sessions.SendMessage(current.Context.PlayerInstance, "DisableTileFromMove:" + selectedTile[0]); sessions.SendMessage(current, "DisableTileResponse:Successful"); } }
public RatingCalculationWorker(ILogger logger, GameSessions gameSessions, ILocalNodeRatingDataAccess localNodeRatingDataAccess) { _logger = logger; _gameSessions = gameSessions; _localNodeRatingDataAccess = localNodeRatingDataAccess; _backgroundSaveHistoryCheckerTimer = new TaskTimer(TimeSpan.FromSeconds(TimeSaveInSeconds), PerformRatingCalculation); Name = "Rating Calculation Worker"; }
public CheckRolePermissionsInvoker(GameSessions gameSessions, IOperationContextHelper operationContextHelper, IOperationInvoker invoker, MethodInfo methodInfo) { _gameSessions = gameSessions; _operationContextHelper = operationContextHelper; _invoker = invoker; _methodInfo = methodInfo; }
public RatingAggregationWorker(ILogger logger, GameSessions gameSessions, IServerDataAccessService serverDataAccessService) { _logger = logger; _gameSessions = gameSessions; _serverDataAccessService = serverDataAccessService; _backgroundSaveHistoryCheckerTimer = new TaskTimer(TimeSpan.FromSeconds(TimeSaveInSeconds), SaveHistoryCheckTask); Name = "Rating Aggregation Worker"; }
public CalculationWorker(ILogger logger, GameSessions gameSessions, PerformanceInfo performanceInfo) { _logger = logger; _gameSessions = gameSessions; _performanceInfo = performanceInfo; _backgroundPerformAutomaticStepsTimer = new TaskTimer(TimeSpan.FromSeconds(1), PerformAutomaticSteps); Name = "Games Calculation worker"; }
// Use this for initialization void Start() { string levelPlayed = "Level "; var tmp = GetComponent <TextMeshProUGUI>(); gameSessions = FindObjectOfType <GameSessions>(); levelPlayed += gameSessions.level.ToString(); levelPlayed += " Played"; tmp.text = levelPlayed; }
/// <summary> /// Implements the execution of getbuddyPlayer command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(GameService current, GameSessions sessions, string message) { var players = string.Empty; players = sessions.GetOtherLoggedInSessionsList(current); // Removes last semicolon from players string. if (!string.IsNullOrEmpty(players)) { players = players.Substring(0, players.Length - 1); } sessions.SendMessage(current, "GetBuddyPlayersResponse:" + players); }
/// <summary> /// Implements the execution of the UILoadComplete command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(JigsawGameService current, GameSessions sessions, string message) { if (null == current.Context.PlayerInstance) { sessions.SendMessage(current, "UILoadCompleteResponse:Failure;PlayerNotFound."); return; } else { sessions.SendMessage(current.Context.PlayerInstance, "CompleteUILoad:" + current.Context.LogOnName); sessions.SendMessage(current, "UILoadCompleteResponse:Successful"); } }
/// <summary> /// Implements execution of this command. /// </summary> /// <param name="current">Current gameservice instance.</param> /// <param name="sessions">Collection of all sessons.</param> /// <param name="message">Command parameters.</param> public void Execute(GameService current, GameSessions sessions, string message) { if (null == current.Context.PlayerInstance) { sessions.SendMessage(current, "WinGameResponse:Failure;PlayerNotFound."); return; } else { sessions.SendMessage(current.Context.PlayerInstance, "WinGame"); sessions.SendMessage(current, "WinGameResponse:Successful"); } }
/// <summary> /// Implements the execution of the UILoadComplete command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(GameService current, GameSessions sessions, string message) { if (null == current.Context.BuddyInstance) { sessions.SendMessage(current, "UILoadCompleteResponse:Failure;Buddy not found."); return; } else { sessions.SendMessage(current.Context.BuddyInstance, "CompleteUILoad:" + current.Context.LogOnName); sessions.SendMessage(current, "UILoadCompleteResponse:Successful"); } }
public ActionResult CreateGame(string UserID) { GameSessions model = new GameSessions(); model.HostUsername = UserID; model.PlayerNames = UserID; model.Type = true; GameDB.GameSession.Add(model); GameDB.Entry(model).State = System.Data.Entity.EntityState.Added; GameDB.SaveChanges(); return(RedirectToAction("Lobby")); }
/// <summary> /// Implements the execution of GetPlayersList command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(JigsawGameService current, GameSessions sessions, string message) { var players = string.Empty; players = sessions.GetOtherLoggedInSessionsList(current); // Removes last semicolon from players string. if (!string.IsNullOrEmpty(players)) { players = players.Substring(0, players.Length - 1); } sessions.SendMessage(current, "GetPlayersListResponse:" + players); }
// Use this for initialization void Start() { highScore = GetComponent <Text>(); gameSessions = FindObjectOfType <GameSessions>(); int highScoreInt; if (gameSessions.level == 1) { highScoreInt = gameSessions.GetHighScorelv1(); } else { highScoreInt = gameSessions.GetHighScorelv2(); } this.highScore.text = highScoreInt.ToString(); }
/// <summary> /// Implements the execution of selectPlayer command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(JigsawGameService current, GameSessions sessions, string message) { if (null != current.Context.PlayerInstance) { sessions.SendMessage(current, "SelectPlayerResponse:Failure;PlayerExist."); return; } else { if (string.IsNullOrEmpty(message)) { sessions.SendMessage(current, "SelectPlayerResponse:Failure;WrongRequest."); return; } var playerInstance = sessions.FindSession(message); if (null == playerInstance) { sessions.SendMessage(current, "SelectPlayerResponse:Failure;PlayerDoesNotExist" + message); return; } else { // Associate both players and then send all responses in the same atomic operation. lock (selectPlayerLock) { if (null == playerInstance.Context.PlayerInstance && null == current.Context.PlayerInstance) { current.Context.PlayerInstance = playerInstance; playerInstance.Context.PlayerInstance = current; // Need to send selectPlayer response to the current service, fixedPlayerresponse to PlayerInstance // and also we need to braodcast selectPlayerResposne to other sessions. sessions.BroadcastMessage(BroadcastMessageType.SelectPlayerResponse, current, playerInstance, "SelectPlayerResponse:Successful", "FixedPlayerResponse:" + current.Context.LogOnName); return; } } // Selected player is already a Player. sessions.SendMessage(current, "SelectPlayerResponse:Failure;BusyPlayer;" + message); } } }
/// <summary> /// Implements the execution of the updateScore command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(JigsawGameService current, GameSessions sessions, string message) { if (null == current.Context.PlayerInstance) { sessions.SendMessage(current, "UpdateScoreResponse:Failure;PlayerNotFound."); return; } else { if (string.IsNullOrEmpty(message)) { sessions.SendMessage(current, "UpdateScoreResponse:Failure;Score is not found."); return; } sessions.SendMessage(current.Context.PlayerInstance, "FixPlayerScore:" + message); sessions.SendMessage(current, "UpdateScoreResponse:Successful"); } }
/// <summary> /// Implements the execution of the updateScore command. /// </summary> /// <param name="current">Current service instance.</param> /// <param name="sessions">Collection of all sessions.</param> /// <param name="message">Command arguments.</param> public void Execute(GameService current, GameSessions sessions, string message) { if (null == current.Context.BuddyInstance) { sessions.SendMessage(current, "UpdateScoreResponse:Failure;Buddy not found."); return; } else { if (string.IsNullOrEmpty(message)) { sessions.SendMessage(current, "UpdateScoreResponse:Failure;Score is not found."); return; } sessions.SendMessage(current.Context.BuddyInstance, "FixBuddyScore:" + message); sessions.SendMessage(current, "UpdateScoreResponse:Successful"); } }
// Use this for initialization void Start() { var tmp = GetComponent <TextMeshProUGUI>(); // tham khảo đối tượng game Sessions gameSessions = FindObjectOfType <GameSessions>(); int highScoreInt; // lấy dữ liệu if (gameSessions.level == 1) { highScoreInt = gameSessions.GetHighScorelv1(); } else { highScoreInt = gameSessions.GetHighScorelv2(); } tmp.text = highScoreInt.ToString(); }
public PersistenceWorker(ILogger logger, GameSessions gameSessions, IGameDataPersisterFactory gameDataPersisterFactory, IHashHelper hashHelper, PerformanceInfo performanceInfo) { _logger = logger; _gameSessions = gameSessions; _gameDataPersisterFactory = gameDataPersisterFactory; _hashHelper = hashHelper; _performanceInfo = performanceInfo; Name = "Games persistence worker"; _gameDataPersisterFactory = gameDataPersisterFactory; for (int i = 0; i < PersistTimeSlotsUsers.Length; i++) { PersistTimeSlotsUsers[i] = new ConcurrentBag <Tuple <string, string, DateTime> >(); } gameSessions.GameStarted += GameSessions_GameStarted; gameSessions.GameRemoved += GameSessions_GameRemoved; gameSessions.AllGamesRemoved += GameSessions_AllGamesRemoved; }
// Use this for initialization public void Awake() { SetUpSingleton(); gameSessions = FindObjectOfType <GameSessions>(); }
// Use this for initialization void Start() { healthDisplay = GetComponent <Text>(); gameSessions = FindObjectOfType <GameSessions>(); // Tìm kiếm và tham khảo đối tượng game Sessions }
public CheckRolePermissionsOperationBehavior(IOperationContextHelper operationContextHelper, GameSessions gameSessions) { _operationContextHelper = operationContextHelper; _gameSessions = gameSessions; }
// Use this for initialization void Awake() { gameSessions = FindObjectOfType <GameSessions>(); }
// Use this for initialization void Start() { scoreDisplay = GetComponent <Text>(); gameSessions = FindObjectOfType <GameSessions>(); }