• 大小: 3.88MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-01
  • 语言: C#
  • 标签: c#  五子棋  c/s  

资源简介

网络对战五子棋采用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\Delink.bmp

     文件      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\link.bmp

     文件        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\Delink.bmp

     文件      19019  2006-05-07 23:14  GobangClient\Backup\Gobang\Form1.cs

............此处省略80个文件信息

评论

共有 条评论