文档详情

C网络五子棋源码.doc

发布:2018-07-01约1.43万字共10页下载文档
文本预览下载声明
using System; using System.Windows.Forms; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.IO; using System.Net.Sockets; using System.Threading; using System.Diagnostics; using System.Net; using Microsoft.Win32; namespace WuZiQi { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public Button[,] buttons;//棋盘数组 public bool gamer1 = false, gamer2 = false,netcanplay=false ;// 两个玩家是否允下棋,连网状态时是否允许下棋 public bool[] gamer1click = new bool [225];//玩家一所下的棋 public bool[] gamer2click = new bool[225];//玩家二所下的棋 public static int port = 3332;//连接端口 public string myipadd = ;//本机IP public Thread li = null;//创建监听进程 public Thread se = null;//创建发送上线信息进程 public Thread sen = null;//创建发送信息进程 public string sendmessage = ;//要发送的信息 public bool canplay = false;//是否可以开始游戏 private void Form1_Load(object sender, EventArgs e) { cshqp(); } //初始化棋盘 /// /// 初始化棋盘 /// /// 初始化是否成功 public bool cshqp() { groupBox1.Controls.Clear(); buttons = new Button[15,15]; int i = 0; for (int x = 0; x /// 下棋 /// /// 要下棋子的索引 /// public bool xiaqi(int index) { //MessageBox.Show(index.ToString()); foreach (Button b in buttons) { if (b.TabIndex == index ) { bool check = false; if (gamer1click[b.TabIndex] == true) { check = true; } if (gamer2click[b.TabIndex] == true) { check = true; } if (check != true)
显示全部
相似文档