private void bunifuTileButton6_Click(object sender, EventArgs e) { if (canPlay) { string _Opponent = "a"; int istop = 0; if (_Username == "a") { _Opponent = "garillos"; istop = 1; } Client.SendPacket("newMatch " + _Username + " " + istop + " " + _Opponent); } }
private void pawnUp(object sender, MouseEventArgs e) // Relâche { if (onClick) { try { Control controlObject = cursorControl.FindControlAtCursor(panelMain.FindForm()); int x = controlObject.Location.X / 50; int y = controlObject.Location.Y / 50; Client.SendPacket("select " + x + " " + y + " " + xSelected + " " + ySelected); } catch (Exception ex) { } onClick = false; } }
public static void Handler(string packet) { try { string[] packetSpace = packet.Split(' '); SendPacket("ok"); if (packetSpace[0] == "match" && packetSpace.Length == 2) { MyMainUIForm.Invoke((MethodInvoker) delegate() { MyMainUIForm.Hide(); }); MyGameForm.Invoke((MethodInvoker) delegate() { MyGameForm.Show(); }); gameList.Invoke((MethodInvoker) delegate() { string message = "C'est parti ! Contre : " + packetSpace[1]; gameList.Items.Add(message); gameList.SelectedIndex = gameList.Items.Count - 1; }); gamePanel.Invoke((MethodInvoker) delegate() { gamePanel.Enabled = true; }); } if (packetSpace[0] == "set" && packetSpace.Length == 6) { if (More.isDec(packetSpace[1]) && More.isDec(packetSpace[2]) && More.isDec(packetSpace[3]) && More.isDec(packetSpace[4])) { int x = More.s_int(packetSpace[1]); int y = More.s_int(packetSpace[2]); int isExist = More.s_int(packetSpace[3]); int isTop = More.s_int(packetSpace[4]); string imgPawn = packetSpace[5]; Action.setCase(x, y, imgPawn, Convert.ToBoolean(isExist), Convert.ToBoolean(isTop)); } } if (packetSpace[0] == "anime" && packetSpace.Length == 4) // todo : anime -> anim { if (More.isDec(packetSpace[1]) && More.isDec(packetSpace[2]) && More.isDec(packetSpace[3])) { int type = More.s_int(packetSpace[1]); int x = More.s_int(packetSpace[2]); int y = More.s_int(packetSpace[3]); /* Test */ Thread AnimThr = new Thread(() => Animation.makeTransition(type, x, y)); AnimThr.Start(); //Animation.makeTransition(type, x, y); } } if (packetSpace[0] == "msg" && packetSpace.Length >= 2) { string message = ""; for (int i = 1; i < packetSpace.Length; i++) { message += packetSpace[i]; message += " "; } gameList.Invoke((MethodInvoker) delegate() { gameList.Items.Add(message); gameList.SelectedIndex = gameList.Items.Count - 1; }); } if (packetSpace[0] == "msg_final" && packetSpace.Length >= 2) { string message = ""; for (int i = 1; i < packetSpace.Length; i++) { message += packetSpace[i]; message += " "; } MessageBox.Show(message); CloseGameOpenUI(); } if (packetSpace[0] == "req" && packetSpace.Length >= 7) { if (More.isDec(packetSpace[1]) && More.isDec(packetSpace[2]) && More.isDec(packetSpace[3]) && More.isDec(packetSpace[4]) && More.isDec(packetSpace[5])) { int type = More.s_int(packetSpace[1]); int bt = More.s_int(packetSpace[2]); int ic = More.s_int(packetSpace[3]); int x = More.s_int(packetSpace[4]); int y = More.s_int(packetSpace[5]); string message = ""; for (int i = 6; i < packetSpace.Length; i++) { message += packetSpace[i]; message += " "; } DialogResult result = MessageBox.Show(message, "", (MessageBoxButtons)bt, (MessageBoxIcon)ic); if (result == DialogResult.Yes) { string reqResult = "req_result 1 " + x + " " + y; Client.SendPacket(reqResult); } else { Client.SendPacket("req_result 0 -1 -1"); } } } if (packetSpace[0] == "end" && packetSpace.Length == 1) { CloseGameOpenUI(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }