版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 象棋 enum player blank, red, blue, ; enum chesstype blank, jiang, che, ma, pao, xiang, zu, shi ; struct chess public
2、 player side; public chesstype type; ; /下載于 struct block public PictureBox container; public chess item; ; public partial class Form1 : Form public Form1() InitializeComponent(); pictureboxlist = new List<PictureBox>(81); Matrix=new block10; int i,j; for (i = 0; i < 10;i+ ) Matrixi = new bl
3、ock9; for(i=0;i<10;i+) for(j=0;j<9;j+) Control col = this.Controls.Find("pictureBox" + (i*9+j+1), false); Matrixij.container=col0 as PictureBox; Matrixij.container.Location = new Point(60 * j, 60 * i); redcoll = new collecter(); bluecool = new collecter(); for (i = 91; i < 107;i+
4、) Control col = this.Controls.Find("pictureBox" + i, false); bluecool.add(col0 as PictureBox); for (i = 107; i < 123;i+ ) Control col = this.Controls.Find("pictureBox" + i, false); redcoll.add(col0 as PictureBox); resetground(); List<PictureBox> pictureboxlist; block Mat
5、rix; collecter redcoll; collecter bluecool; int chozenX; int chozenY; player currentside; bool beenchozen; bool clickswitch; private void click1(object sender, EventArgs e) if(!clickswitch) resetground(); return; string name = (sender as PictureBox).Name; string number = name.Substring(10); int inde
6、x = Convert.ToInt32(number); int i,j; bool flag = false; i=(index-1)/9; j=(index-1)%9; /下載于 if (beenchozen) MatrixchozenXchozenY.container.BorderStyle = BorderStyle.None; MatrixchozenXchozenY.container.BackColor = Color.Transparent; beenchozen = false; if(MatrixchozenXchozenY.item.side=Matrixij.item
7、.side) return; if (MatrixchozenXchozenY.item.side != player.blank) if(Matrixij.item.type= chesstype.jiang) flag=true; if(!movechess(i, j) return; if(flag) if (currentside = player.red) MessageBox.Show("紅方勝利!點(diǎn)擊任意處重新開(kāi)局"); else MessageBox.Show("藍(lán)方勝利!點(diǎn)擊任意處重新開(kāi)局"); clickswitch = false;
8、 if (currentside = player.red) currentside = player.blue; label1.Text = "藍(lán)方" label1.ForeColor = Color.Blue; else currentside = player.red; label1.Text = "紅方" label1.ForeColor = Color.Red; else if(Matrixij.item.side= currentside) Matrixij.container.BorderStyle = BorderStyle.FixedS
9、ingle; Matrixij.container.BackColor = Color.Brown; chozenX = i; chozenY = j; beenchozen = true; private void resetground() int i, j; for (i = 0; i < 10;i+ ) for(j=0;j<9;j+) Matrixij.container.Image = null; Matrixij.item.side = player.blank; Matrixij.item.type = chesstype.blank; beenchozen = fa
10、lse; clickswitch = true; currentside = player.red; label1.Text = "紅方" label1.ForeColor = Color.Red; redcoll.clear(); bluecool.clear(); Matrix00.container.Image = global:象棋.Properties.Resources.藍(lán)車(chē); Matrix01.container.Image = global:象棋.Properties.Resources.藍(lán)馬; Matrix02.container.Image = glob
11、al:象棋.Properties.Resources.藍(lán)象; Matrix03.container.Image = global:象棋.Properties.Resources.藍(lán)士; Matrix04.container.Image = global:象棋.Properties.Resources.藍(lán)將; Matrix05.container.Image = global:象棋.Properties.Resources.藍(lán)士; Matrix06.container.Image = global:象棋.Properties.Resources.藍(lán)象; Matrix07.container.Im
12、age = global:象棋.Properties.Resources.藍(lán)馬; Matrix08.container.Image = global:象棋.Properties.Resources.藍(lán)車(chē); Matrix21.container.Image = global:象棋.Properties.Resources.藍(lán)炮; Matrix27.container.Image = global:象棋.Properties.Resources.藍(lán)炮; Matrix30.container.Image = global:象棋.Properties.Resources.藍(lán)卒; Matrix32.co
13、ntainer.Image = global:象棋.Properties.Resources.藍(lán)卒; Matrix34.container.Image = global:象棋.Properties.Resources.藍(lán)卒; Matrix36.container.Image = global:象棋.Properties.Resources.藍(lán)卒; Matrix38.container.Image = global:象棋.Properties.Resources.藍(lán)卒; Matrix60.container.Image = global:象棋.Properties.Resources.紅卒; M
14、atrix62.container.Image = global:象棋.Properties.Resources.紅卒; Matrix64.container.Image = global:象棋.Properties.Resources.紅卒; Matrix66.container.Image = global:象棋.Properties.Resources.紅卒; Matrix68.container.Image = global:象棋.Properties.Resources.紅卒; Matrix71.container.Image = global:象棋.Properties.Resou
15、rces.紅炮; Matrix77.container.Image = global:象棋.Properties.Resources.紅炮; Matrix90.container.Image = global:象棋.Properties.Resources.紅車(chē); Matrix91.container.Image = global:象棋.Properties.Resources.紅馬; Matrix92.container.Image = global:象棋.Properties.Resources.紅象; Matrix93.container.Image = global:象棋.Proper
16、ties.Resources.紅士; Matrix94.container.Image = global:象棋.Properties.Resources.紅將; Matrix95.container.Image = global:象棋.Properties.Resources.紅士; Matrix96.container.Image = global:象棋.Properties.Resources.紅象; Matrix97.container.Image = global:象棋.Properties.Resources.紅馬; Matrix98.container.Image = global
17、:象棋.Properties.Resources.紅車(chē); /下載于 Matrix00.item.side = player.blue; Matrix01.item.side = player.blue; Matrix02.item.side = player.blue; Matrix03.item.side = player.blue; Matrix04.item.side = player.blue; Matrix05.item.side = player.blue; Matrix06.item.side = player.blue; Matrix07.item.side = player.
18、blue; Matrix08.item.side = player.blue; Matrix21.item.side = player.blue; Matrix27.item.side = player.blue; Matrix30.item.side = player.blue; Matrix32.item.side = player.blue; Matrix34.item.side = player.blue; Matrix36.item.side = player.blue; Matrix38.item.side = player.blue; Matrix60.item.side = p
19、layer.red; Matrix62.item.side = player.red; Matrix64.item.side = player.red; Matrix66.item.side = player.red; Matrix68.item.side = player.red; Matrix71.item.side = player.red; Matrix77.item.side = player.red; Matrix90.item.side = player.red; Matrix91.item.side = player.red; Matrix92.item.side = play
20、er.red; Matrix93.item.side = player.red; Matrix94.item.side = player.red; Matrix95.item.side = player.red; Matrix96.item.side = player.red; Matrix97.item.side = player.red; Matrix98.item.side = player.red; Matrix00.item.type = chesstype.che; Matrix01.item.type = chesstype.ma; Matrix02.item.type = ch
21、esstype.xiang; Matrix03.item.type = chesstype.shi; Matrix04.item.type = chesstype.jiang; Matrix05.item.type = chesstype.shi; Matrix06.item.type = chesstype.xiang; Matrix07.item.type = chesstype.ma; Matrix08.item.type = chesstype.che; Matrix21.item.type = chesstype.pao; Matrix27.item.type = chesstype
22、.pao; Matrix30.item.type = chesstype.zu; Matrix32.item.type = chesstype.zu; Matrix34.item.type = chesstype.zu; Matrix36.item.type = chesstype.zu; Matrix38.item.type = chesstype.zu; Matrix60.item.type = chesstype.zu; Matrix62.item.type = chesstype.zu; Matrix64.item.type = chesstype.zu; Matrix66.item.
23、type = chesstype.zu; Matrix68.item.type = chesstype.zu; Matrix71.item.type = chesstype.pao; Matrix77.item.type = chesstype.pao; Matrix90.item.type = chesstype.che; Matrix91.item.type = chesstype.ma; Matrix92.item.type = chesstype.xiang; Matrix93.item.type = chesstype.shi; Matrix94.item.type = chesst
24、ype.jiang; Matrix95.item.type = chesstype.shi; Matrix96.item.type = chesstype.xiang; Matrix97.item.type = chesstype.ma; Matrix98.item.type = chesstype.che; private bool movechess(int X,int Y) int i, j, k, n=0; switch(MatrixchozenXchozenY.item.type) case chesstype.che: if(chozenX=X) i = chozenY <
25、Y ? chozenY : Y; j = chozenY > Y ? chozenY : Y; for(k=i+1;k<j;k+) if(MatrixXk.item.side!= player.blank) return false; if (chozenY = Y) i = chozenX < X ? chozenX : X; j = chozenX > X ? chozenX : X; for (k = i + 1; k < j; k+) if (MatrixkY.item.side != player.blank) return false; setmove
26、(X, Y); return true; case chesstype.jiang: if(MatrixXY.item.type= chesstype.jiang&&chozenY=Y) i = chozenX < X ? chozenX : X; j = chozenX > X ? chozenX : X; for (k = i + 1; k < j; k+) if (MatrixkY.item.side != player.blank) return false; setmove(X, Y); return true; if (MatrixchozenXc
27、hozenY.item.side= player.blue) if(Y<3|Y>5|X>2) return false; else if(Y<3|Y>5|X<7) return false; if(chozenX-X)*(chozenX-X)+(chozenY-Y)*(chozenY-Y)!=1) return false; setmove(X, Y); return true; case chesstype.ma: if (Math.Abs(chozenX - X) = 1 && Math.Abs(chozenY - Y) = 2) if
28、(MatrixchozenXchozenY + (Y - chozenY) / Math.Abs(Y - chozenY).item.side!= player.blank) return false; else if (Math.Abs(chozenX - X) = 2 && Math.Abs(chozenY - Y) = 1) if (MatrixchozenX + (X - chozenX) / Math.Abs(X - chozenX)chozenY.item.side != player.blank) return false; else return false;
29、setmove(X, Y); return true; case chesstype.pao: n = 0; if(chozenX=X) i = chozenY < Y ? chozenY : Y; j = chozenY > Y ? chozenY : Y; n = 0; for(k=i+1;k<j;k+) if(MatrixXk.item.side!= player.blank) n+; if(n>1) return false; else if (chozenY = Y) i = chozenX < X ? chozenX : X; j = chozenX
30、> X ? chozenX : X; n = 0; for (k = i + 1; k < j; k+) if (MatrixkY.item.side != player.blank) n+; if (n > 1) return false; else return false; if(n=0&&MatrixXY.item.side!= player.blank) return false; if(n=1&&MatrixXY.item.side= player.blank) return false; setmove(X, Y); return true; case chesstype.shi: if (MatrixchozenXchozenY.item.side= player.
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 門(mén)診輸液室護(hù)士工作總結(jié)
- 幼教行業(yè)助理工作總結(jié)
- 電影行業(yè)技巧提升總結(jié)
- 國(guó)家課程:《機(jī)械制造裝備設(shè)計(jì)》第一章
- 2025-2030全球管式爐行業(yè)調(diào)研及趨勢(shì)分析報(bào)告
- 2025-2030全球工業(yè)應(yīng)用移動(dòng)機(jī)器人行業(yè)調(diào)研及趨勢(shì)分析報(bào)告
- 2025年全球及中國(guó)電動(dòng)低升降托盤(pán)車(chē)行業(yè)頭部企業(yè)市場(chǎng)占有率及排名調(diào)研報(bào)告
- 2025年全球及中國(guó)塑料3D打印長(zhǎng)絲行業(yè)頭部企業(yè)市場(chǎng)占有率及排名調(diào)研報(bào)告
- 2025-2030全球工業(yè)膠囊填充機(jī)行業(yè)調(diào)研及趨勢(shì)分析報(bào)告
- 2025年全球及中國(guó)微米級(jí)氧化鋯行業(yè)頭部企業(yè)市場(chǎng)占有率及排名調(diào)研報(bào)告
- 2024年北京東城社區(qū)工作者招聘筆試真題
- 《敏捷項(xiàng)目管理》課件
- 統(tǒng)編版(2024新版)七年級(jí)上學(xué)期道德與法治期末綜合測(cè)試卷(含答案)
- 黑龍江省哈爾濱市2024屆中考數(shù)學(xué)試卷(含答案)
- 前程無(wú)憂測(cè)評(píng)題庫(kù)及答案
- 高三日語(yǔ)一輪復(fù)習(xí)助詞「と」的用法課件
- 物業(yè)管理服務(wù)房屋及公用設(shè)施維修養(yǎng)護(hù)方案
- 五年級(jí)上冊(cè)小數(shù)遞等式計(jì)算200道及答案
- 帶拼音生字本模板(可A4打印)
- 超高大截面框架柱成型質(zhì)量控制
- 森林法講解課件
評(píng)論
0/150
提交評(píng)論