首页

c#扫雷经典版(wpf)

c#

2020-9-10

1、正常扫雷功能,游戏计时,
2、两种模式:①点击开始游戏直接开始普通模式,过一关游戏雷数增加,行和列增加;
②菜单栏选择初级难度、中级难度和高级难度;
3、右键点击插旗功能
4、游戏失败后点击重新开始刷新地图重新开始
5、通关后点击下一关进入下一关

void CountMine(int i,int j,Image img)
        {
            
           
            if (bomOrgo[i,j]==true)
            {
                return;
            }
           
            bomOrgo[i,j] = true;
            //创建一个变量来接收地雷数
            int count = 0;
            //判断当前位置四周的八个方向是否为雷,如果是则count  
            if (IsBoom(i - 1, j - 1))
            {
                count  ;
            }
            if (IsBoom(i-1,j))
            {
                count  ;
            }
            if (IsBoom(i - 1, j 1))
            {
                count  ;
            }
            if (IsBoom(i, j-1))
            {
                count  ;
            }
            if (IsBoom(i , j 1))
            {
                count  ;
            }
            if (IsBoom(i  1, j-1))
            {
                count  ;
            }
            if (IsBoom(i   1, j))
            {
                count  ;
            }
            if (IsBoom(i   1, j 1))
            {
                count  ;
            }
            //递归思想:判断如果当前位置的8个方向都没有雷,则再以八个方向为中心重复调用自己这个方法往外判断
            if (count==0)
            {
                GameBG.Children.Remove(img);
                //外部if保证数组不超出索引
                if (i>0)
                {
                    CountMine(i - 1, j,images[i-1,j]);
                    if (j>0)
                    {
                        CountMine(i-1,j-1, images[i - 1, j-1]);
                    }
                }
                if (i<maps.GetLength(0)-1)
                {
                    CountMine(i   1, j,images[i   1, j]);
                }
                if (i>0&&j<maps.GetLength(1)-1)
                {
                    CountMine(i - 1, j   1, images[i - 1, j 1]);
                }
                if (j<maps.GetLength(1)-1)
                {
                    CountMine(i , j 1, images[i, j 1]);
                }
                if (j>0)
                {
                    CountMine(i, j - 1, images[i , j-1]);
                }
                if (i < maps.GetLength(1)-1&&j>0)
                {
                    CountMine(i   1, j - 1, images[i   1, j-1]);
                }
                if (i < maps.GetLength(0)-1&& j < maps.GetLength(1)-1)
                {
                    CountMine(i   1, j 1, images[i   1, j 1]);
                }
            }
            else
            {
                //移除该处图片
                GameBG.Children.Remove(img);
                //实例化label
                Label lb = new Label();
                lb.Content = count.ToString();
                //将label设置网格的相应位置处
                Grid.SetRow(lb, i);
                Grid.SetColumn(lb, j);
                lb.FontSize = 24;
                //设置label水平居中
                lb.HorizontalContentAlignment = HorizontalAlignment.Center;
                //设置label竖直居中
                lb.VerticalContentAlignment = VerticalAlignment.Center;
                GameBG.Children.Add(lb);
            }
        }
资源下载此资源下载价格为3D币(VIP免费),请先
资源文件列表
App.xaml , 366
App.xaml.cs , 333
bin/Release/练习.exe , 829440
bin/Release/练习.exe.config , 189
bin/Release/练习.pdb , 42496
file/chuji.txt , 16
file/初级记录.txt , 51
filestream.cs , 70
img/bg.jpg , 146704
img/bg1.jpg , 134392
img/CustomerOrder.ico , 3158
img/exit.ico , 318
img/lei.gif , 5812
img/logo.ico , 16958
img/main.png , 465296
img/menu.png , 17332
img/menu2.png , 2509
img/mrp.ico , 766
img/qizi.gif , 5337
img/SysIco.ico , 7886
img/zhuan.gif , 3810
MainWindow.xaml , 4186
MainWindow.xaml.cs , 18131
obj/Release/App.g.cs , 2345
obj/Release/App.g.i.cs , 2345
obj/Release/DesignTimeResolveAssemblyReferences.cache , 664
obj/Release/DesignTimeResolveAssemblyReferencesInput.cache , 7259
obj/Release/MainWindow.baml , 2444
obj/Release/MainWindow.g.cs , 8386
obj/Release/MainWindow.g.i.cs , 8386
obj/Release/排行.baml , 1115
obj/Release/排行.g.cs , 4578
obj/Release/排行.g.i.cs , 4578
obj/Release/练习.csproj.FileListAbsolute.txt , 1143
obj/Release/练习.csproj.GenerateResource.cache , 954
obj/Release/练习.csprojAssemblyReference.cache , 424
obj/Release/练习.exe , 829440
obj/Release/练习.g.resources , 814691
obj/Release/练习.pdb , 42496
obj/Release/练习.Properties.Resources.resources , 180
obj/Release/练习_Content.g.i.cs , 523
obj/Release/练习_MarkupCompile.cache , 244
obj/Release/练习_MarkupCompile.i.cache , 244
obj/Release/练习_MarkupCompile.i.lref , 123
obj/Release/练习_MarkupCompile.lref , 123
Properties/AssemblyInfo.cs , 2300
Properties/Resources.Designer.cs , 2825
Properties/Resources.resx , 5612
Properties/Settings.Designer.cs , 1093
Properties/Settings.settings , 201
排行.xaml , 780
排行.xaml.cs , 1952
练习.csproj , 5116
练习.csproj.user , 231
没有账号? 忘记密码?

社交账号快速登录