• 大小: 9.41MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-25
  • 语言: C#
  • 标签: C#  

资源简介

使用C#Winform实现五子棋人机及局域网功能,二维数组画棋盘。

资源截图

代码片段和文件信息

using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Fivestones
{

    class Chessboard
    {
        //arrchessboard为棋盘情况数组,arrchessboard[ij]=2表示此处无子,arrchessboard[ij]=0表示此处为黑子,arrchessboard[ij]=1表示此处为白子
        public int[] arrchessboard = new int[15 15];
        //绘制的对象
        public Graphics mg;
        //棋子对象
        public Stone stone;
        ////电脑对象
        private Computer computer;
        //判断当前棋子是黑(true)是白(false)
        public bool stoneflag = true;
        //判断先手玩家(是电脑(true)还是人(false),先手下黑棋)
        private bool mplayfirstflag = false;
        //历史记录堆栈
        private Stack mStarckHistory = new Stack();
        public bool a = true;//判断只有点击开始时才可进行落子
        //Form2 form2 = new Form2();

        public Chessboard(Graphics g)
        {

            Initialization();
            mg = g;
        }

        /// 
        /// 画棋盘
        /// 

        public void Draw()
        {

            Image img = Properties.Resources.chessboard; //获取棋盘图片 大小600*600像素
            mg.DrawImage(img 0 0 img.Width img.Height);
            for (int i = 0; i < 15; i++)
            {
                for (int j = 0; j < 15; j++)
                {
                    if (arrchessboard[i j] == 0)
                    {
                        stone.DrawStone(i j true);
                    }
                    if (arrchessboard[i j] == 1)
                    {
                        stone.DrawStone(i j false);
                    }
                }
            }
        }
        public void DownStone(int m int n)
        {
            stone.DrawStone(m n stoneflag);
            //记录情况
            if (stoneflag)
            {
                arrchessboard[m n] = 0;
            }
            else
            {
                arrchessboard[m n] = 1;
            }

            //判断结果

            if (rules.Result(m n arrchessboard) < 6)
            {
                switch (rules.Result(m n arrchessboard))
                {
                    case 1:
                        MessageBox.Show(“黑棋双三禁手失败!“);
                        a = false;
                        break;
                    case 2:
                        MessageBox.Show(“黑棋双四禁手失败!“);
                        a = false;
                        break;
                    case 3:
                        MessageBox.Show(“黑棋长连禁手失败!“);

                        break;

                    case 4:
                        if (stoneflag)
                        {
                            MessageBox.Show(“黑棋胜利!“);
                        }
                        else
                        {
                            MessageBox.Show(“白棋胜利!“);
                        }
                        break;
          

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1340  2018-04-16 15:23  Fivestones\Fivestones\Properties\AssemblyInfo.cs

     文件        249  2018-04-16 15:23  Fivestones\Fivestones\Properties\Settings.settings

     文件       1097  2018-04-16 15:23  Fivestones\Fivestones\Properties\Settings.Designer.cs

     文件       6707  2018-04-16 18:31  Fivestones\Fivestones\Properties\Resources.resx

     文件       3994  2018-04-16 18:31  Fivestones\Fivestones\Properties\Resources.Designer.cs

     文件       1682  2018-04-16 15:24  Fivestones\Fivestones\Properties\whitestone.gif

     文件       1723  2018-04-16 15:24  Fivestones\Fivestones\Properties\blackstone.gif

     文件     161859  2018-04-16 15:24  Fivestones\Fivestones\Properties\chessboard.gif

     文件        187  2018-04-16 15:23  Fivestones\Fivestones\App.config

     文件       2036  2018-05-29 11:52  Fivestones\Fivestones\Form1.cs

     文件       3486  2018-05-16 18:09  Fivestones\Fivestones\Form1.Designer.cs

     文件        523  2018-06-06 13:58  Fivestones\Fivestones\Program.cs

     文件       7854  2018-06-06 13:56  Fivestones\Fivestones\Fivestones.csproj

     文件       5817  2018-05-16 18:09  Fivestones\Fivestones\Form1.resx

     文件       6487  2018-05-31 20:23  Fivestones\Fivestones\chessboard.cs

     文件       1692  2018-06-05 21:50  Fivestones\Fivestones\Stone.cs

     文件       1723  2018-04-16 15:24  Fivestones\Fivestones\blackstone.gif

     文件     161859  2018-04-16 15:24  Fivestones\Fivestones\chessboard.gif

     文件       1682  2018-04-16 15:24  Fivestones\Fivestones\whitestone.gif

     文件       1723  2018-04-16 18:30  Fivestones\Fivestones\Resources\blackstone.gif

     文件     161859  2018-04-16 18:30  Fivestones\Fivestones\Resources\chessboard.gif

     文件       1682  2018-04-16 18:30  Fivestones\Fivestones\Resources\whitestone.gif

     文件      13441  2018-05-22 14:40  Fivestones\Fivestones\rules.cs

     文件      14918  2018-06-06 12:21  Fivestones\Fivestones\Form2.cs

     文件       4487  2018-05-28 11:32  Fivestones\Fivestones\Form2.Designer.cs

     文件       5817  2018-05-16 17:33  Fivestones\Fivestones\Form2.resx

     文件        641  2018-04-25 05:08  Fivestones\Fivestones\Fivestones.csproj.user

     文件       1488  2018-05-23 16:47  Fivestones\Fivestones\creatroom.cs

     文件       6227  2018-05-10 22:05  Fivestones\Fivestones\creatroom.Designer.cs

     文件       5817  2018-05-10 22:05  Fivestones\Fivestones\creatroom.resx

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

评论

共有 条评论