/// <summary> /// Добавить второго игрока в игру. /// </summary> /// <param name="beginGame">Информация о втором игроке и сессии к которой он хочет присоединиться.</param> private static void JoinTheGame(Socket handler, BeginGame beginGame) { try { GameSession game = null; lock (sessions) { if (sessions.Any(x => x.SessionName.Equals(beginGame.GameName, StringComparison.OrdinalIgnoreCase))) { game = sessions.Find(x => x.SessionName == beginGame.GameName); game.Player2 = new Player(handler, beginGame.PlayerName); } } if (game?.GameStarted ?? false) { SendOk(handler, false); BeginReceive(handler); } else { SendError(handler, true); } } catch (Exception e) { Console.WriteLine(e); handler?.Close(); } }
private void Start() { monitor_game = GameObject.FindWithTag("MonitorGame").GetComponent <MonitorGame>(); GameObject gameovercontroller = GameObject.FindWithTag("GameOverController"); beginGame = begin_gameObj.GetComponent <BeginGame>(); createMenu = gameovercontroller.GetComponent <CreateMenu>(); }
void OnMessage(object sender, MessageEventArgs e) { var simpleAction = GrabAction(e.Message.Body); switch (simpleAction) { case "OPEN_TABLE": OpenTableMessage openTable = JsonConvert.DeserializeObject <OpenTableMessage>(e.Message.Body); messageHandler.OpenTable(openTable); break; case "TABLE_STATE": TableStateMessage stateMessage = JsonConvert.DeserializeObject <TableStateMessage>(e.Message.Body); messageHandler.TableState(stateMessage); break; case "ELIMINATED": EliminatedMessage eliminated = JsonConvert.DeserializeObject <EliminatedMessage>(e.Message.Body); messageHandler.Eliminated(eliminated); break; case "CLOSE_TABLE": Console.WriteLine(e.Message.Body); break; case "BEGIN_GAME": BeginGame beginGame = JsonConvert.DeserializeObject <BeginGame>(e.Message.Body); messageHandler.BeginGame(beginGame); break; case "DEAL_COMMUNITY_CARDS": DealCommunityCards dealCommunityCards = JsonConvert.DeserializeObject <DealCommunityCards>(e.Message.Body); messageHandler.DealCommunityCards(dealCommunityCards); break; case "SET_ACTIVE_PLAYER": SetActivePlayer setActivePlayer = JsonConvert.DeserializeObject <SetActivePlayer>(e.Message.Body); messageHandler.SetActivePlayer(setActivePlayer); break; case "SET_PLAYER_ACTION": SetPlayerAction setPlayerAction = JsonConvert.DeserializeObject <SetPlayerAction>(e.Message.Body); messageHandler.SetPlayerAction(setPlayerAction); break; case "SET_PLAYERS": SetPlayers setPlayers = JsonConvert.DeserializeObject <SetPlayers>(e.Message.Body); messageHandler.SetPlayers(setPlayers); break; case "CHAT": Console.WriteLine(GrabBody(e.Message.Body)); break; default: break; } //switch } //OnMessage
public void Setup() { // Initilize Xamarin Forms MockForms.Init(); //This is your App.xaml and App.xaml.cs, which can have resources, etc. app = new App(); Application.Current = app; page = new BeginGame(); }
protected override void OnUpdate(GameTime time) { base.OnUpdate(time); titleScreen.Update(time); if (titleScreen.Player != null) { systemState.ReturnToTitle = false; BeginGame?.Invoke(titleScreen.Player); } }
public void Handle(BeginGame command) { _gameLoop = new Thread(GameLoop); _gameLoop.Start(); var message = new GameBegun(); foreach (IListenForGameBegun listener in _gameBegunListeners) { listener.Handle(message); } }
private void Keyboard_KeyPress(object sender, KeyPressEventArgs e) { musicInstance.Stop(); var player = new Player("Davey"); player.MapID = 1; player.X = 126; player.Y = 52; player.StoryData = new LobStory(); player.Items[LobItem.FalconFeather] = 1; BeginGame?.Invoke(player); }
/// <summary> /// Добавляет новую игру в sessions. /// </summary> /// <param name="beginGame">Информация о сессии, которую неоходимо добавить.</param> private static void AddGame(Socket handler, BeginGame beginGame) { bool exist = false; GameSession game = null; try { if (beginGame == null || beginGame?.GameName == null || beginGame?.PlayerName == null) { SendError(handler, false); return; } lock (sessions) { exist = sessions.Count(x => x.SessionName.Equals(beginGame?.GameName, StringComparison.OrdinalIgnoreCase)) > 0 ? true : false; if (!exist) { game = new GameSession(beginGame.GameName); game.Player1 = new Player(handler, beginGame.PlayerName); sessions.Add(game); } } if (exist) { SendError(handler, true); } else { SendOk(handler, false); BeginReceive(handler); } } catch (Exception e) { lock (sessions) { sessions.Remove(game); } Console.WriteLine(e); handler?.Close(); } }
private void Mouse_MouseUp(object sender, MouseButtonEventArgs e) { if (hideTitle) { hideTitle = false; timeSinceMouseMove = 0; return; } if (mousex > 100 - 20 && mousex < 500 && mousey > 100 && mousey < 130) { GameState gameState = gameStateFactory.CreateGameState(); gameState.world = beginningWorld; gameState.level = beginningLevel; BeginGame?.Invoke(gameState); } if (mousex > 100 - 20 && mousex < 500 && mousey > 160 && mousey < 190) { SceneStack.Remove(this); } if (mousex > 100 - 20 && mousex < 500 && mousey > 250 && mousey < 280) { config.BackgroundScroll = !config.BackgroundScroll; game.bgspeed = config.BackgroundScroll ? 50.0f : 0.0f; } if (mousex > 100 - 20 && mousex < 500 && mousey > 280 && mousey < 320) { config.PlayMusic = !config.PlayMusic; if (config.PlayMusic) { StartTitleMusic(); } else { MediaPlayer.Stop(); } } }
public void BeginGame(BeginGame message) { GetBot(message.tableId)?.ResetActions(); }//BeginGame