C#九宫格游戏

C#九宫格游戏

ID:37239345

大小:16.99 KB

页数:7页

时间:2019-05-20

C#九宫格游戏_第1页
C#九宫格游戏_第2页
C#九宫格游戏_第3页
C#九宫格游戏_第4页
C#九宫格游戏_第5页
资源描述:

《C#九宫格游戏》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespacecs_nineplay{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}ColorOnColor=Color.Cora

2、l;ColorOffColor=Color.Yellow;intseconds1,seconds2=999;intcount1,count2=999;int[,]ChangeCells={{-1,-1,-1,-1,-1},{1,2,4,5,-1},{2,1,3,-1,-1},{3,2,5,6,-1},{4,1,7,-1,-1},{5,2,4,6,8},{6,3,9,-1,-1},{7,4,5,8,-1},{8,7,9,-1,-1},{9,5,6,8,-1}};Button[]Buttons=newButton[10];intnum=0;//boolT

3、F=true;structTM{publicintTime,Times;}TM[]tm=newTM[100];privatevoidButton_Click(objectsender,EventArgse){ButtonbtnHit=(Button)sender;intNo=int.Parse(btnHit.Text);for(inti=0;i<5;i++){intX=ChangeCells[No,i];if(X!=-1){if(Buttons[X].BackColor==OffColor)Buttons[X].BackColor=OnColor;e

4、lseButtons[X].BackColor=OffColor;}}count1+=1;lblCount.Text="次数:"+count1.ToString()+"次";intsum=0;for(inti=1;i<=9;i++){if(Buttons[i].BackColor==OnColor)sum+=1;}if(sum==8&&Buttons[5].BackColor==OffColor){btnStart.Enabled=true;btnStop.Enabled=false;tmrTime.Enabled=false;btnStart.Te

5、xt="开始";Clear.Enabled=true;MessageBox.Show("恭喜!过关....");for(inti=1;i<=9;i++)Buttons[i].Enabled=false;if(seconds2>seconds1){cbxTime.SelectedIndexChanged-=newEventHandler(cbxTime_SelectedIndexChanged);cbxTimes.SelectedIndexChanged-=newEventHandler(cbxTimes_SelectedIndexChanged);/

6、/TF=false;cbxTime.Text=seconds1.ToString();cbxTimes.Text=count1.ToString();cbxTime.Items.Add(seconds1);cbxTimes.Items.Add(count1);tm[num].Time=seconds1;tm[num].Times=count1;num++;seconds2=seconds1;count2=count1;Grade.Text="最好成绩:";JL.Text="新纪录";}elseif(seconds2==seconds1&&count2

7、>count1){cbxTime.SelectedIndexChanged-=newEventHandler(cbxTime_SelectedIndexChanged);cbxTimes.SelectedIndexChanged-=newEventHandler(cbxTimes_SelectedIndexChanged);//TF=false;cbxTime.Text=seconds1.ToString();cbxTimes.Text=count1.ToString();cbxTime.Items.Add(seconds1);cbxTimes.It

8、ems.Add(count1);tm[num].Time=seconds1;tm[num].Times=co

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。