/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnJoinGame_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtServerIP.Text)) { ClientRequest.strIP = txtServerIP.Text; } if (!String.IsNullOrEmpty(txtNickName.Text)) { game.PlayerNickName = txtNickName.Text; } game.IsHost = false; if (lstWaitGuest.SelectedItems.Count != 1) { return; } var strWait = lstWaitGuest.SelectedItem.ToString(); Card.CardUtility.Init(txtCardPath.Text); String GameId = Card.Client.ClientRequest.JoinGame(int.Parse(strWait.Substring(0, strWait.IndexOf("("))), game.PlayerNickName); game.GameId = int.Parse(GameId); game.IsFirst = Card.Client.ClientRequest.IsFirst(game.GameId.ToString(GameServer.GameIdFormat), game.IsHost); game.Init(); var t = new BattleField(); t.game = game; t.ShowDialog(); this.Close(); }
private static void Wait() { while (!Card.Client.ClientRequest.IsGameStart(game.GameId.ToString(GameServer.GameIdFormat))) { Thread.Sleep(3000); } game.IsFirst = Card.Client.ClientRequest.IsFirst(game.GameId.ToString(GameServer.GameIdFormat), game.IsHost); game.Init(); var t = new BattleField(); t.game = game; t.ShowDialog(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnJoinGame_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtServerIP.Text)) ClientUtlity.strIP = txtServerIP.Text; if (!String.IsNullOrEmpty(txtNickName.Text)) game.PlayerNickName = txtNickName.Text; game.IsHost = false; if (lstWaitGuest.SelectedItems.Count != 1) return; var strWait = lstWaitGuest.SelectedItem.ToString(); Card.CardUtility.Init(txtCardPath.Text); String GameId = Card.Server.ClientUtlity.JoinGame(int.Parse(strWait.Substring(0, strWait.IndexOf("("))), game.PlayerNickName); game.GameId = int.Parse(GameId); game.IsFirst = Card.Server.ClientUtlity.IsFirst(game.GameId.ToString(GameServer.GameIdFormat), game.IsHost); game.Init(); var t = new BattleField(); t.game = game; t.ShowDialog(); this.Close(); }
/// <summary> /// 开始游戏的请求 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCreateGame_Click(object sender, EventArgs e) { //新建游戏的时候,已经决定游戏的先后手 if (!String.IsNullOrEmpty(txtServerIP.Text)) ClientUtlity.strIP = txtServerIP.Text; if (!String.IsNullOrEmpty(txtNickName.Text)) game.PlayerNickName = txtNickName.Text; game.IsHost = true; String GameId = Card.Server.ClientUtlity.CreateGame(game.PlayerNickName); Card.CardUtility.Init(txtCardPath.Text); game.GameId = int.Parse(GameId); btnJoinGame.Enabled = false; btnRefresh.Enabled = false; btnCreateGame.Enabled = false; while (!Card.Server.ClientUtlity.IsGameStart(GameId)) { Thread.Sleep(3000); } game.IsFirst = Card.Server.ClientUtlity.IsFirst(game.GameId.ToString(GameServer.GameIdFormat), game.IsHost); game.Init(); var t = new BattleField(); t.game = game; t.ShowDialog(); this.Close(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnJoinGame_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtServerIP.Text)) ClientRequest.strIP = txtServerIP.Text; if (!String.IsNullOrEmpty(txtNickName.Text)) game.PlayerNickName = txtNickName.Text; if (String.IsNullOrEmpty(cmbCardDeck.Text)) { MessageBox.Show("请选择套牌"); return; } game.IsHost = false; if (lstWaitGuest.SelectedItems.Count != 1) return; var strWait = lstWaitGuest.SelectedItem.ToString(); Engine.Utility.CardUtility.Init(txtCardPath.Text); String GameId = Engine.Client.ClientRequest.JoinGame(int.Parse(strWait.Substring(0, strWait.IndexOf("("))), game.PlayerNickName); var CardList = GetCardDeckList(); Engine.Client.ClientRequest.SendDeck(int.Parse(GameId), game.IsHost, CardList); game.GameId = int.Parse(GameId); game.IsFirst = Engine.Client.ClientRequest.IsFirst(game.GameId.ToString(GameServer.GameIdFormat), game.IsHost); game.Init(); var t = new BattleField(); t.game = game; t.ShowDialog(); this.Close(); }