C#网络五子棋源码.doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《C#网络五子棋源码.doc》由会员分享,可在线阅读,更多相关《C#网络五子棋源码.doc(11页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、源码:有点多,哈哈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;names
2、pace 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 bool225;/玩家二所下的棋 public
3、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(); /
4、初始化棋盘 / / 初始化棋盘 / / 初始化是否成功 public bool cshqp() groupBox1.Controls.Clear(); buttons = new Button15,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 (gamer1
5、clickb.TabIndex = true) check = true; if (gamer2clickb.TabIndex = true) check = true; if (check != true) if (gamer1 = true) gamer1clickb.TabIndex = true; b.Image = global:WuZiQi.Properties.Resources.black; canxiaqi(gamer2); if (netpk.Checked = false | Asservice.Checked = true) if (checkwin(gamer1) l
6、abel11.Text = 赢家:玩家一 + player1.Text; MessageBox.Show(恭喜玩家一: + player1.Text + ,你赢了!, 会飞的鱼提醒, MessageBoxButtons.OK, MessageBoxIcon.Information); canxiaqi(); send(win恭喜玩家一: + player1.Text + ,你赢了!); else if (gamer2 = true) gamer2clickb.TabIndex = true; b.Image = global:WuZiQi.Properties.Resources.write;
7、 canxiaqi(gamer1); if (netpk.Checked = false | Asservice.Checked = true) if (checkwin(gamer2) label11.Text = 赢家:玩家二 + player2.Text; MessageBox.Show(恭喜玩家二: + player2.Text + ,你赢了!, 会飞的鱼提醒, MessageBoxButtons.OK, MessageBoxIcon.Information); canxiaqi(); send(win恭喜玩家二: + player2.Text + ,你赢了!); else check
8、 = false; MessageBox.Show(这个位置上不能下棋!, 会飞的鱼提醒, MessageBoxButtons.OK, MessageBoxIcon.Warning); /MessageBox.Show(b.TabIndex.ToString(); return true; return false; /开始游戏 private void start_Click(object sender, EventArgs e) /if (player1.Text = | player2.Text = ) / / MessageBox.Show(请输入你的名字!, 会飞的鱼提醒, Mess
9、ageBoxButtons.OK, MessageBoxIcon.Warning); / /else / if (canplay = true | netpk.Checked = false) if (radioButton1.Checked = true) canxiaqi(gamer1); else canxiaqi(gamer2); groupBox2.Enabled = false; start.Enabled = false; else MessageBox.Show(还没有建立连接或对方还没有准备好!不能开始游戏!, 会飞的鱼提醒, MessageBoxButtons.OK, Me
10、ssageBoxIcon.Warning); / /改变下棋状态 / / 改变下棋状态 / / 可以下棋的人的名字 public void canxiaqi(string s) if (s=gamer1) int sum = 0; for (int i = 0; i / 判断输赢 / / 要判断的玩家的名字 / 是否赢 public bool checkwin(string s) if (s = gamer1) for (int i = 0; i /做为主机 private void Asservice_CheckedChanged_1(object sender, EventArgs e)
11、if (Asservice.Checked = true) waitconnect.Enabled = true; Asclinet.Checked = false; Asclinet.Enabled = false; else waitconnect.Enabled = false; groupBox3.Enabled = true; Asservice.Enabled = true; Asclinet.Enabled = true; /做为客户机 private void Asclinet_CheckedChanged(object sender, EventArgs e) if (Asc
12、linet.Checked = true) connect.Enabled = true; label12.Enabled = true; ip.Enabled = true; Asservice.Checked = false; Asservice.Enabled=false ; else connect.Enabled = false ; label12.Enabled = false; ip.Enabled = false; groupBox3.Enabled = true; Asservice.Enabled = true; Asclinet.Enabled = true; /等待客户
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C# 网络 五子棋 源码
![提示](https://www.deliwenku.com/images/bang_tan.gif)
限制150内