public void updateMonster() { Monster mini = FactoryM.createMonster(this.X, this.Y, "Mini"); SingleObject.GetSingle().BG.ListMonster.Add(mini); // t= new System.Timers.Timer(3000); }
private void playagain_Click(object sender, EventArgs e) { InitialGame(); SingleObject.GetSingle().Score = 0; lost = false; Cursor.Hide(); }
public override void attackHero() { int offset = this.X - SingleObject.GetSingle().BG.TP.X; if (offset > 0) { if (face == 1) { overturn(img); face = 0; } this.X = this.X - speed; } if (offset < 0) { if (face == 0) { overturn(img); face = 1; } this.X = this.X + speed; } if (this.GetRectangle().IntersectsWith(SingleObject.GetSingle().BG.TP.GetRectangle())) { int life = SingleObject.GetSingle().BG.TP.currentlife; if (life > 0) { SingleObject.GetSingle().BG.TP.currentlife--; attackBack(); } } }
public override void Draw(Graphics g) { int i = SingleObject.GetSingle().BG.TP.score; //g.DrawImage(img, this.X, this.y, this.Width, this.Height); Brush linearGradientBrush = new LinearGradientBrush(new Rectangle(85, 85, 85, 85), Color.Blue, Color.BlueViolet, 45); g.DrawString("Score:" + i.ToString(), new Font("Consolas", 23, FontStyle.Bold), linearGradientBrush, 80, 80); }
public override void Buffer() { if (SingleObject.GetSingle().BG.TP.currentlife < 3) { SingleObject.GetSingle().BG.TP.currentlife++; } SoundPlayer.GetBlood_BGM(); }
private void Form1_Paint(object sender, PaintEventArgs e) { SingleObject.GetSingle().Draw(e.Graphics); string score = SingleObject.GetSingle().Score.ToString(); string life = SingleObject.GetSingle().PH.Life.ToString(); e.Graphics.DrawString(score, new Font("宋体", 20, FontStyle.Bold), Brushes.Red, new Point(0, 0)); e.Graphics.DrawString(life, new Font("consolas", 20, FontStyle.Bold), Brushes.Red, new Point(0, 20)); }
private void Form1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 32) { if (lost == true) { InitialGame(); SingleObject.GetSingle().Score = 0; lost = false; } } }
public override void attackHero() { Move(); if (this.GetRectangle().IntersectsWith(SingleObject.GetSingle().BG.TP.GetRectangle())) { int life = SingleObject.GetSingle().BG.TP.currentlife; if (life > 0) { SingleObject.GetSingle().BG.TP.currentlife--; attackBack(); } } }
public bool in_attack() //英雄是否在怪物的攻击范围内 { int hero_x = SingleObject.GetSingle().BG.TP.X; if (System.Math.Abs(this.X - hero_x) < 130) //攻击范围为100 { return(true); } else { return(false); } }
public void InitialGame() { Cursor.Hide(); SingleObject.GetSingle().AddGameObject(new BackGround(0, -400, 4)); SingleObject.GetSingle().AddGameObject(new PlaneHero(200, 700, 5, 10, Direction.up)); for (int i = 0; i < 4; i++) { SingleObject.GetSingle().AddGameObject(new PlaneEnemy(r.Next(0, 281), r.Next(-400, -100), r.Next(0, 2), false)); if (r.Next(0, 100) > 90) { SingleObject.GetSingle().AddGameObject(new PlaneEnemy(r.Next(0, 281), r.Next(-400, -100), 2, false)); } } }
private void WhenMove() { if (SingleObject.GetSingle().BG.BGunder.Height < this.Y + this.Height) { this.y = SingleObject.GetSingle().BG.BGunder.Height - this.Height - 1; } int asd = SingleObject.GetSingle().BG.BGunder.GetPixel(0, 0).B; int val = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 50, this.Y + this.Height).B; while (val < 10) { this.y--; val = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 50, this.Y + this.Height).B; } }
private void InitialPlaneEnemy() { if (lost == true) { return; } for (int i = 0; i < 4; i++) { SingleObject.GetSingle().AddGameObject(new PlaneEnemy(r.Next(0, 281), r.Next(-400, -100), r.Next(0, 2), false)); if (r.Next(0, 100) > 90) { SingleObject.GetSingle().AddGameObject(new PlaneEnemy(r.Next(0, 281), r.Next(-400, -100), 2, false)); } } }
public void attackBack() //击退英雄 { int face; if (SingleObject.GetSingle().BG.TP.face == 0) { face = -1; } else { face = 1; } SingleObject.GetSingle().BG.TP.X = SingleObject.GetSingle().BG.TP.X + face * 100; SoundPlayer.FireATT_BGM(); }
public void move() { if (this.Y - 100 < 0) { this.Y = 100; } int b_up = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 50, this.Y - 100).B; int b_down = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 50, this.Y + 90 + this.speed).B; int b_left = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 40 - this.speed, this.Y + 90 + this.speed).B; int b_right = SingleObject.GetSingle().BG.BGunder.GetPixel(this.X + 50 + this.speed, this.Y + 90 + this.speed).B; if (K_down) { K_down = false; anm_frame = 0; Weapon w = new Weapon(this.X, this.Y, 20, 20, this); SingleObject.GetSingle().BG.ListWeapon.Add(w); } if (S_down && this.Y < map.Height - 120 && b_down > 250) { this.Y = this.Y + speed; } if (J_down && this.Y - 100 > 0 && b_up > 250) { J_down = false; this.Y = this.Y - 100; } if (A_down && this.X > map.X - 30 && b_left > 250) { if (face != 1) { overturn(); face = 1; } this.X = this.X - speed; } if (D_down && this.X < map.Width - 100 && b_right > 250) { if (face != 0) { overturn(); face = 0; } this.X = this.X + speed; } }
public override void Draw(Graphics g) { for (int i = 0; i < SingleObject.GetSingle().BG.ListMonster.Count; i++) { if (SingleObject.GetSingle().BG.ListMonster[i] is Boss) { Boss boss = SingleObject.GetSingle().BG.ListMonster[i] as Boss; if (boss.X - SingleObject.GetSingle().BG.TP.X < 500) { float life = (float)(boss.Hp / 2) / 100; int w = (int)(img.Width * life); g.DrawImage(imgBack, boss.X + 30 + boss.map.X, boss.Y - 80, imgBack.Width / 2, imgBack.Height / 2); g.DrawImage(img, boss.X + 30 + boss.map.X, boss.Y - 80, w, img.Height / 2); } } } }
public override void Draw(Graphics g) { if (comm.Time() - last_frame_time > frame_internal) { anm_frame++; last_frame_time = comm.Time(); if (anm_frame == img.Length) { anm_frame = 0; } } g.DrawImage(lifeContainer, this.X - 20, this.Y, 250, 100); g.DrawImage(muscle, this.X - 40, this.Y, 120, 100); for (int i = 1; i <= SingleObject.GetSingle().BG.TP.currentlife; i++) { g.DrawImage(img[anm_frame], this.X + i * 40 + 15, this.Y + 45, img[anm_frame].Width / 2, img[anm_frame].Height / 2); } }
public override void Draw(Graphics g) { if (!(SingleObject.GetSingle().BG.TP.GetRectangle().IntersectsWith(this.GetRectangle()))) { index = 0; } if (comm.Time() - last_frame_time > frame_internal) { anm_frame++; last_frame_time = comm.Time(); } if (anm_frame >= img[index].Length) { anm_frame = 0; } // img[index][anm_frame].RotateFlip(RotateFlipType.Rotate180FlipY); g.DrawImage(img[index][anm_frame], this.X + map.X, this.Y + map.Y, this.Width, this.Height); }
private void Form1_KeyPress(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Up: case Keys.Down: SingleObject.GetSingle().PH.Diry = Direction.stop; break; case Keys.Left: case Keys.Right: SingleObject.GetSingle().PH.Dirx = Direction.stop; break; case Keys.ControlKey: break; } }
private void TimerBG_Tick(object sender, EventArgs e) { this.Invalidate(); int count = SingleObject.GetSingle().planeEnemies.Count; if (count <= 1) { InitialPlaneEnemy(); } SingleObject.GetSingle().Collision(); shoottimer += 1; if (lost == true) { colorflash += 1; if (colorflash == 100) { colorflash = 0; } if (colorflash > 50) { playagain.ForeColor = Color.Red; } else { playagain.ForeColor = Color.Green; } playagain.Visible = true; overlabel.Visible = true; pressspace.Visible = true; } else { playagain.Visible = false; overlabel.Visible = false; pressspace.Visible = false; } SingleObject.GetSingle().PH.Move(); SingleObject.GetSingle().PH.Fire(); }
public override void Buffer() { if (Random < 10) { SingleObject.GetSingle().BG.TP.currentlife = SingleObject.GetSingle().BG.TP.origlife;//恢复全部生命 } else if (Random < 20) { SingleObject.GetSingle().BG.TP.currentlife--;//毒苹果 } else if (Random < 30) { Weapon.w += 10; Weapon.h += 10;//子弹变大 } else { Weapon.end *= 2;//子弹射程*2 } SoundPlayer.Eat_BGM(); }
public void Draw(Graphics g) { int i; int x = SingleObject.GetSingle().BG.X; int y = SingleObject.GetSingle().BG.Y; int w = SingleObject.GetSingle().BG.BGImage.Width; int h = SingleObject.GetSingle().BG.BGImage.Height; for (i = 0; i < SingleObject.GetSingle().BG.ListGoods.Count(); i++) { // GameObject god = SingleObject.GetSingle().BG.ListGoods[i]; if (SingleObject.GetSingle().BG.ListGoods[i].GetRectangle().IntersectsWith(SingleObject.GetSingle().BG.TP.GetRectangle())) { SingleObject.GetSingle().BG.ListGoods[i].Buffer(); if ((SingleObject.GetSingle().BG.ListGoods[i] is Fire) || (SingleObject.GetSingle().BG.ListGoods[i] is Torch) || (SingleObject.GetSingle().BG.ListGoods[i] is Door)) { SingleObject.GetSingle().BG.ListGoods[i].map = new Rectangle(x, y, w, h); SingleObject.GetSingle().BG.ListGoods[i].Draw(g); } else if (SingleObject.GetSingle().BG.ListGoods[i] is GoldenBag) { SingleObject.GetSingle().BG.ListGoods.RemoveAt(i); SingleObject.GetSingle().BG.TP.Vector = true; } else { SingleObject.GetSingle().BG.ListGoods.RemoveAt(i); } } else { SingleObject.GetSingle().BG.ListGoods[i].map = new Rectangle(x, y, w, h); SingleObject.GetSingle().BG.ListGoods[i].Draw(g); } } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Up: SingleObject.GetSingle().PH.Diry = Direction.up; break; case Keys.Down: SingleObject.GetSingle().PH.Diry = Direction.down; break; case Keys.Left: SingleObject.GetSingle().PH.Dirx = Direction.left; break; case Keys.Right: SingleObject.GetSingle().PH.Dirx = Direction.right; break; case Keys.ControlKey: break; } }
public override void Buffer() { SingleObject.GetSingle().BG.TP.score += 5; SoundPlayer.GetGold_BGM(); }
public override void Buffer() { SingleObject.GetSingle().BG.TP.score += 150; SoundPlayer.Gulp_GoldBag(); }
public override void Buffer() { SingleObject.GetSingle().BG.TP.currentlife--; attackBack(); }