c#±àµÄ²¿·ÖÖ²Îï´óÕ½½©Ê¬´úÂë ÏÂÔØ±¾ÎÄ

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Media; using System.Text;

using System.Threading.Tasks; using System.Windows.Forms;

namespace Ö²Îï´óÕ½½©Ê¬2 {

public partial class Form1 : Form {

bool[,] bo = new bool[9, 5]; public Form1() {

InitializeComponent();

//¼¤»î´°ÌåµÄË«»º³å¼¼Êõ,¿ÉÒÔ×¢Ê͵ô¿´¿´ÊÇʲôЧ¹û SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.UserPaint, true);

SetStyle(ControlStyles.OptimizedDoubleBuffer, true); }

string str = null; int m = 0; int n = 0;

List listpic = new List(); List listpic1 = new List(); List listpic2 = new List(); List listpic3 = new List(); List listpic4 = new List(); List listJiangshi = new List(); List listJiangshi1 = new List(); List listJiangshi2 = new List(); List listJiangshi3 = new List(); List listJiangshi4 = new List();

private void pictureBoxWandou_MouseDown(object sender, MouseEventArgs e) {

if ((e.Button == System.Windows.Forms.MouseButtons.Left)) {

PictureBox pictureBox = sender as PictureBox; str = pictureBox.Tag.ToString();

pictureBox.DoDragDrop(Properties.Resources.Íã¶¹ÉäÊÖ, DragDropEffects.Copy | DragDropEffects.Move);

//ÐγÉÍÏקЧ¹û£¬Òƶ¯+¿½±´µÄ×éºÏЧ¹û }

}

SoundPlayer sp;

private void Form1_DragEnter(object sender, DragEventArgs e) {

e.Effect = DragDropEffects.Copy; }

bool booltimer = true;

private void Form1_DragDrop(object sender, DragEventArgs e) {

LocationTransport(e.X - this.Location.X, e.Y - this.Location.Y, out m, out n); //ÍÏ·ÅÍê±ÏÖ®ºó£¬×Ô¶¯Éú³Éпؼþ

sp = new SoundPlayer(Properties.Resources.ÍÏ·Å);//±ØÐëÊÇ´ø.wavÀ©Õ¹ÃûµÄÒôƵÎļþ

sp.Play(); if (bo[m, n]) {

PictureBox pictureBox = sender as PictureBox; PictureBox btn = new PictureBox();

btn.Size = new System.Drawing.Size(70, 75);

btn.Location = this.PointToClient(new Point(m * 75 + 50 + this.Location.X, n * 70 + 95 + this.Location.Y));

//ÓÃÕâ¸ö·½·¨¼ÆËã³ö¿Í»§¶ËÈÝÆ÷½çÃæµÄX£¬Y×ø±ê¡£·ñÔòÖ±½ÓʹÓÃX£¬YÊÇÆÁÄ»×ø±ê

switch (str) {

case \

btn.Image = Properties.Resources.ÏòÈÕ¿û; break; case \

btn.Image = Properties.Resources.Íã¶¹ÉäÊÖ; a = mWandou = m * 75 + 50 + this.Location.X; nWandou = n * 70 + 95 + this.Location.Y; wandou = new Label();

ClassWandou cwandou = new ClassWandou(mWandou, nWandou, a, wandou);

cwandou.wandou.Size = new System.Drawing.Size(30, 30); cwandou.wandou.Image = Properties.Resources.Íã¶¹;

cwandou.wandou.BackColor = System.Drawing.Color.Transparent; this.Controls.Add(cwandou.wandou);

switch (n) {

case 0:

listpic.Add(cwandou); break; case 1:

listpic1.Add(cwandou); break; case 2:

ÒôƵÎļþ

listpic2.Add(cwandou); break; case 3:

listpic3.Add(cwandou); break; case 4:

listpic4.Add(cwandou); break; }

if (booltimer) {

timerWandou.Enabled = true; timerWandou1.Enabled = true; timerWandou2.Enabled = true; timerWandou3.Enabled = true; timerWandou4.Enabled = true; timer1.Enabled = true; booltimer = false; } break; case \

btn.Image = Properties.Resources.²Ýݮըµ¯; break; }

btn.BackColor = System.Drawing.Color.Transparent;

btn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; btn.BackColor = System.Drawing.Color.Transparent; this.Controls.Add(btn); bo[m, n] = false; } else {

sp = new SoundPlayer(Properties.Resources.ÖØ¸´);//±ØÐëÊÇ´ø.wavÀ©Õ¹ÃûµÄ sp.Play();

} }

private void LocationTransport(double x, double y, out int m1, out int n1) {

m1 = (int)(x - 50) / 75; n1 = ((int)(y - 95) / 70);

if (m1 < 0 || n1 < 0 || m1 > 8 || n1 > 4) {

m1 = 0; n1 = 0; } }

private void Form1_Load(object sender, EventArgs e) {

for (int i = 0; i < 9; i++) {

for (int j = 0; j < 5; j++) {

bo[i, j] = true; } }

for(int l=0;l<10;l++){

int mun = this.Location.X + 700; int suiji = ran.Next(5);

int nun = suiji * 70 + 95 + this.Location.Y; int suijiLife = ran1.Next(10);

Jiangshi jiangshi = new Jiangshi(suijiLife+5, mun, nun, picturejiangshi); jiangshi.picJiangshi.Location=this.PointToClient(new Point(mun,nun)); switch (suiji) {

case 0:

listJiangshi.Add(jiangshi); break; case 1:

listJiangshi1.Add(jiangshi); break; case 2:

listJiangshi2.Add(jiangshi); break; case 3:

listJiangshi3.Add(jiangshi); break; case 4:

listJiangshi4.Add(jiangshi);