資源簡介
網絡對戰五子棋采用c#編程語言實現,基于(c/s)模式編寫。網絡工程專業學生實訓項目源代碼,僅用于學習用途。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.Drawing.Drawing2D;
using?System.Collections;
namespace?Gobang
{
????public?struct?CobbleLocation
????{
????????public?int?row;
????????public?int?column;
????}
????public?partial?class?Form1?:?Form
????{
????????//以下數據設置比例與窗體Size有關,單位是像素,當前Size為(506583)
????????int?LINE_SPACE?=?32;
????????int?LINE_COUNT?=?15;
????????int?CENTER_RADIUS?=?3;?//天元位置小圓點的半徑
????????int?COBBLE_RADIUS?=?15;//棋子半徑
????????//本客戶端用戶棋子顏色標記
????????bool?IS_WHITE_LOCAL_COBBLE_COLOR?=?true;
????????//棋盤交叉點矩形區域
????????Rectangle[]?crossPointRects;
????????//棋盤信息變量
????????int?BoardCenterX;
????????int?BoardCenterY;
????????int?BoardLineLength;
????????int?BoardLeft;
????????int?BoardTop;
????????Rectangle?BoardRect;
????????//用戶鼠標位置
????????int?mouseCurrentX;
????????int?mouseCurrentY;
????????//canPut用以判斷是否可以落子
????????bool?canPut?;
????????//黑白子重畫
????????ArrayList??blackswhites;
????????//焦點棋子
????????CobbleLocation?focusCobble;
????????//套接字
????????TcpClient?tcpClient;
????????//標記是否游戲正在進行
????????bool?playing?=?false;
????????//聯珠五子
????????ArrayList?winFive;
???????
????????public?Form1()
????????{
????????????InitializeComponent();
????????????BoardCenterX?=?ClientSize.Width?/?2;
????????????BoardCenterY?=?ClientSize.Height?/?2?+?toolStrip1.Height;
????????????BoardLineLength?=?LINE_SPACE?*?(LINE_COUNT?-?1);
????????????BoardLeft?=?BoardCenterX?-?LINE_SPACE?*?((LINE_COUNT?-?1)?/?2);
????????????BoardTop?=?BoardCenterY?-?LINE_SPACE?*?((LINE_COUNT?-?1)?/?2);
????????????BoardRect?=?new?Rectangle(BoardLeft?BoardTop?BoardLineLength?BoardLineLength);
????????????crossPointRects?=?new?Rectangle[LINE_COUNT?LINE_COUNT];
????????????initializePointsArray();
????????????blacks?=?new?ArrayList();
????????????whites?=?new?ArrayList();
????????????winFive?=?new?ArrayList();
????????????Setstyle(Controlstyles.UserPaint?|?Controlstyles.DoubleBuffer?|?Controlstyles.AllPaintingInWmPaint?true);
???????}
????????private?void?newGobang()
????????{
????????????blacks.Clear();
????????????whites.Clear();
????????????winFive.Clear();
????????????Refresh();
????????????focusCobble.row?=?-1;
????????????focusCobble.column?=?-1;
????????????if(IS_WHITE_LOCAL_COBBLE_COLOR)?canPut=false;
????????????else?canPut=true;
????????????playing?=?true;
????????????if?(IS_WHITE_LOCAL_COBBLE_COLOR)
????????????{
????????????????tcpClient.Send(“請執黑先行“);
????????????}
????????????else
????????????????MessageBox.Show(“執黑先行“);
????????????timer1.Tick?+=?new?EventHandler(waitPut);
????????????timer1.Enabled?=?true;
????????}
????????private?void?Form1_Paint(object?sender?PaintEventArgs?e)
????????{
????????????//畫棋盤的方法
????????????drawBoard(e.Graphics);
????????????//畫黑子的方法
????????????drawBlacks(e.Gr
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????828118??2006-05-05?20:46??GobangServer\GobangServer\BackGround.bmp
?????文件????1691648??2006-05-09?00:17??GobangServer\GobangServer\bin\Debug\GobangServer.exe
?????文件??????46592??2006-05-09?00:17??GobangServer\GobangServer\bin\Debug\GobangServer.pdb
?????文件???????5632??2005-11-11?22:25??GobangServer\GobangServer\bin\Debug\GobangServer.vshost.exe
?????文件???????2518??2006-05-06?12:14??GobangServer\GobangServer\Deli
?????文件??????18786??2006-05-09?00:39??GobangServer\GobangServer\Form1.cs
?????文件???????8159??2006-05-09?00:39??GobangServer\GobangServer\Form1.Designer.cs
?????文件????1249222??2006-05-09?00:39??GobangServer\GobangServer\Form1.resx
?????文件???????3508??2006-05-06?12:34??GobangServer\GobangServer\GobangServer.csproj
?????文件???????2406??2006-05-06?09:50??GobangServer\GobangServer\li
?????文件????????934??2006-05-07?20:10??GobangServer\GobangServer\obj\Debug\GobangServer.csproj.GenerateResource.Cache
?????文件????1691648??2006-05-09?00:17??GobangServer\GobangServer\obj\Debug\GobangServer.exe
?????文件?????828952??2006-05-07?20:10??GobangServer\GobangServer\obj\Debug\GobangServer.Form1.resources
?????文件??????46592??2006-05-09?00:17??GobangServer\GobangServer\obj\Debug\GobangServer.pdb
?????文件?????833030??2006-05-06?12:55??GobangServer\GobangServer\obj\Debug\GobangServer.Properties.Resources.resources
?????文件???????5120??2006-05-06?12:34??GobangServer\GobangServer\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件????????303??2006-05-09?00:18??GobangServer\GobangServer\obj\GobangServer.csproj.FileList.txt
?????文件????????471??2006-05-06?11:39??GobangServer\GobangServer\Program.cs
?????文件???????1174??2006-05-06?11:39??GobangServer\GobangServer\Properties\AssemblyInfo.cs
?????文件???????3603??2006-05-06?12:34??GobangServer\GobangServer\Properties\Resources.Designer.cs
?????文件???????6657??2006-05-06?12:34??GobangServer\GobangServer\Properties\Resources.resx
?????文件???????1108??2006-05-06?11:47??GobangServer\GobangServer\Properties\Settings.Designer.cs
?????文件????????249??2006-05-06?11:39??GobangServer\GobangServer\Properties\Settings.settings
?????文件???????2744??2006-05-09?00:17??GobangServer\GobangServer\TcpServer.cs
?????文件????????925??2006-05-06?11:39??GobangServer\GobangServer.sln
????..A..H.?????16896??2006-05-09?00:39??GobangServer\GobangServer.suo
?????文件?????????74??2006-05-06?09:19??GobangClient\Backup\Gobang\app.config
?????文件?????828118??2006-05-05?20:46??GobangClient\Backup\Gobang\BackGround.bmp
?????文件???????2518??2006-05-06?12:14??GobangClient\Backup\Gobang\Deli
?????文件??????19019??2006-05-07?23:14??GobangClient\Backup\Gobang\Form1.cs
............此處省略80個文件信息
評論
共有 條評論