• 大小: 0.26M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-04-25
  • 语言: C#
  • 标签: 纸牌  游戏  

资源简介

纸牌游戏,winform 随机,随机点击。

资源截图

代码片段和文件信息

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace zhipai
{
    public partial class Form1 : Form
    {
        PictureBox[] pic = new PictureBox[16];//纸牌集合
        ArrayList arrl = new ArrayList();//0-15排列前
        int[] num = new int[16];//0-15随机排列后

        int count = 0;//计数器,所翻牌的数量
        int t2 = 0;//计时器

        public Form1()
        {
            InitializeComponent();
        }
        //初始化纸牌
        void start()
        {
            pic[0] = pictureBox1;
            pic[1] = pictureBox2;
            pic[2] = pictureBox3;
            pic[3] = pictureBox4;
            pic[4] = pictureBox5;
            pic[5] = pictureBox6;
            pic[6] = pictureBox7;
            pic[7] = pictureBox8;
            pic[8] = pictureBox9;
            pic[9] = pictureBox10;
            pic[10] = pictureBox11;
            pic[11] = pictureBox12;
            pic[12] = pictureBox13;
            pic[13] = pictureBox14;
            pic[14] = pictureBox15;
            pic[15] = pictureBox16;
        }

        private void 关于ToolStripMenuItem_Click(object sender EventArgs e)
        {
            MessageBox.Show(“游戏名称:\n作者:\n时间:“);
        }

        private void 开始ToolStripMenuItem1_Click(object sender EventArgs e)
        {
            //获取顺序数字集合0-15
            for (int i = 0; i < 16; i++)
            {
                arrl.Add(i);
            }
            //随机排列0-15数字,取一个后将其移除,
            //取数字的索引并非数字,按索引来获取数字
            for (int j = 0; j < 16; j++)
            {
                Random rd = new Random();
                int n = rd.Next(arrl.Count);//索引最大值小于元素个数
                num[j] = Convert.ToInt32(arrl[n]);//按索引取随机数
                arrl.Remove(arrl[n]);//获取后移除
            }
            //随机排列的数字即图片索引,顺序按索引取数字即随机排列0-15
            //按取出的数字即图片索引来获取图片,并赋值给纸牌,形成图片随机排列
            for (int k = 0; k < 16; k++)
            {
                pic[k].Image = imageList1.Images[num[k]];
            }
            timer1.Enabled = true;
        }

        private void 退出ToolStripMenuItem_Click(object sender EventArgs e)
        {
            this.Close();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            //初始化纸牌
            start();
            //纸牌显示默认图片,即未匹配图片
            for (int i = 0; i < 16; i++)
            {
                pic[i].Image = imageList2.Images[0];
            }
        }
        int t = 0;
        private void timer1_Tick(object sender EventArgs e)
        {
            t++;
            if (t == 3)
            {
                for (int i = 0; i < 16; i++)
                {
                    pic[i].Image = imageList2.Images[0];
                }
                timer1.Enabled = false;
                t = 0;
            }
 

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

     文件     185344  2012-05-11 18:15  zhipai\zhipai\bin\Debug\zhipai.exe

     文件      38400  2012-05-11 18:15  zhipai\zhipai\bin\Debug\zhipai.pdb

     文件      11600  2012-05-11 18:17  zhipai\zhipai\bin\Debug\zhipai.vshost.exe

     文件        490  2010-03-17 22:39  zhipai\zhipai\bin\Debug\zhipai.vshost.exe.manifest

     文件       5273  2011-09-05 11:23  zhipai\zhipai\Form1.cs

     文件      21494  2011-09-05 10:41  zhipai\zhipai\Form1.Designer.cs

     文件     260242  2011-09-05 10:41  zhipai\zhipai\Form1.resx

     文件       4440  2012-04-22 21:30  zhipai\zhipai\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6178  2012-05-11 18:15  zhipai\zhipai\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        488  2012-03-05 21:03  zhipai\zhipai\obj\x86\Debug\GenerateResource.read.1.tlog

     文件       1262  2012-03-05 21:03  zhipai\zhipai\obj\x86\Debug\GenerateResource.write.1.tlog

     文件       7897  2012-05-11 18:15  zhipai\zhipai\obj\x86\Debug\ResolveAssemblyReference.cache

     文件       1578  2012-05-11 18:17  zhipai\zhipai\obj\x86\Debug\zhipai.csproj.FileListAbsolute.txt

     文件     185344  2012-05-11 18:15  zhipai\zhipai\obj\x86\Debug\zhipai.exe

     文件     169196  2012-03-05 21:03  zhipai\zhipai\obj\x86\Debug\zhipai.Form1.resources

     文件      38400  2012-05-11 18:15  zhipai\zhipai\obj\x86\Debug\zhipai.pdb

     文件        180  2012-03-05 21:03  zhipai\zhipai\obj\x86\Debug\zhipai.Properties.Resources.resources

     文件        487  2011-09-05 08:10  zhipai\zhipai\Program.cs

     文件       1344  2011-09-05 08:10  zhipai\zhipai\Properties\AssemblyInfo.cs

     文件       2862  2011-09-05 08:10  zhipai\zhipai\Properties\Resources.Designer.cs

     文件       5612  2011-09-05 08:10  zhipai\zhipai\Properties\Resources.resx

     文件       1091  2011-09-05 08:10  zhipai\zhipai\Properties\Settings.Designer.cs

     文件        249  2011-09-05 08:10  zhipai\zhipai\Properties\Settings.settings

     文件       3671  2011-09-05 08:13  zhipai\zhipai\zhipai.csproj

     文件        860  2011-09-05 08:10  zhipai\zhipai.sln

    ..A..H.     17920  2012-05-11 18:17  zhipai\zhipai.suo

     目录          0  2011-09-05 08:10  zhipai\zhipai\obj\x86\Debug\TempPE

     目录          0  2012-05-11 18:15  zhipai\zhipai\obj\x86\Debug

     目录          0  2011-09-05 17:21  zhipai\zhipai\bin\Debug

     目录          0  2011-09-05 17:21  zhipai\zhipai\obj\x86

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

评论

共有 条评论