c#编的部分植物大战僵尸代码 下载本文

spattack1.Play(); } } }

if (listJiangshi1.Count == 0) {

timerWandou1.Enabled = false; } }

if (listJiangshi1.Count > 0) {

bool bo = (listJiangshi1[0].picJiangshi.Location.X < this.Location.X); if (bo) {

Program.isValidUser1 = true; timerWandou.Enabled = false; timerWandou1.Enabled = false; timerWandou2.Enabled = false; timerWandou3.Enabled = false; timerWandou4.Enabled = false; this.Close(); } } }

int num2 = 0;

SoundPlayer spattack2;

private void timerWandou2_Tick(object sender, EventArgs e) {

num2++;

if (num2 % 10 == 0) {

if (listJiangshi2.Count > 0) {

foreach (Jiangshi i in listJiangshi2) {

i.move += i.life + 5;

i.picJiangshi.Location = this.PointToClient(new Point(i.mjiangshi - i.move, i.njiangshi)); } } }

foreach (ClassWandou k in listpic2) {

k.mWandou += 10;

if (k.mWandou >= this.Location.X + this.Width - 100) {

k.mWandou = k.a; }

k.wandou.Location = this.PointToClient(new Point(k.mWandou, k.nWandou));

if (listJiangshi2.Count > 0) {

if ((k.mWandou >= (listJiangshi2[0].mjiangshi - listJiangshi2[0].move)) && (k.mWandou <= (listJiangshi2[0].mjiangshi - listJiangshi2[0].move + 20))) {

k.mWandou = a;

listJiangshi2[0].life--;

this.label3.Text = listJiangshi2[0].life.ToString();

spattack2 = new SoundPlayer(Properties.Resources.被豌豆打击); spattack2.Play();

if (listJiangshi2[0].life <= 0) {

// listJiangshi[0]应该销毁picture对象 listJiangshi2.Remove(listJiangshi2[0]);

spattack2 = new SoundPlayer(Properties.Resources.僵尸死了); spattack2.Play(); } } }

if (listJiangshi2.Count == 0) {

timerWandou2.Enabled = false; } }

if (listJiangshi2.Count > 0) {

bool bo = (listJiangshi2[0].picJiangshi.Location.X < this.Location.X); if (bo) {

Program.isValidUser1 = true; timerWandou.Enabled = false; timerWandou1.Enabled = false; timerWandou2.Enabled = false; timerWandou3.Enabled = false; timerWandou4.Enabled = false; this.Close(); } }

}

int num3 = 0;

SoundPlayer spattack3;

private void timerWandou3_Tick(object sender, EventArgs e) {

num3++;

if (num3 % 10 == 0) {

if (listJiangshi3.Count > 0) {

foreach (Jiangshi i in listJiangshi3) {

i.move += i.life + 5;

i.picJiangshi.Location = this.PointToClient(new Point(i.mjiangshi - i.move, i.njiangshi)); } } }

foreach (ClassWandou k in listpic3) {

k.mWandou += 10;

if (k.mWandou >= this.Location.X + this.Width-100) {

k.mWandou = k.a; }

k.wandou.Location = this.PointToClient(new Point(k.mWandou, k.nWandou));

if (listJiangshi3.Count > 0) {

if ((k.mWandou >= (listJiangshi3[0].mjiangshi - listJiangshi3[0].move)) && (k.mWandou <= (listJiangshi3[0].mjiangshi - listJiangshi3[0].move + 20))) {

k.mWandou = a;

listJiangshi3[0].life--;

this.label4.Text = listJiangshi3[0].life.ToString();

spattack3 = new SoundPlayer(Properties.Resources.被豌豆打击); spattack3.Play();

if (listJiangshi3[0].life <= 0) {

// listJiangshi[0]应该销毁picture对象 listJiangshi3.Remove(listJiangshi3[0]);

spattack3 = new SoundPlayer(Properties.Resources.僵尸死了); spattack3.Play(); }

} }

if (listJiangshi3.Count == 0) {

timerWandou3.Enabled = false; } }

if (listJiangshi3.Count > 0) {

bool bo = (listJiangshi3[0].picJiangshi.Location.X < this.Location.X); if (bo) {

Program.isValidUser1 = true; timerWandou.Enabled = false; timerWandou1.Enabled = false; timerWandou2.Enabled = false; timerWandou3.Enabled = false; timerWandou4.Enabled = false; this.Close(); } } }

int num4 = 0;

SoundPlayer spattack4;

private void timerWandou4_Tick(object sender, EventArgs e) {

num4++;

if (num4 % 10 == 0) {

if (listJiangshi4.Count > 0) {

foreach (Jiangshi i in listJiangshi4) {

i.move += i.life+ 5;

i.picJiangshi.Location = this.PointToClient(new Point(i.mjiangshi - i.move, i.njiangshi)); } } }

foreach (ClassWandou k in listpic4) {

k.mWandou += 10;

if (k.mWandou >= this.Location.X+this.Width-100) {