/// <summary> /// 产生敌方子弹 /// </summary> public static void ProduceEnbul() { for (int i = 0; i < Fighter.fighters.Count; i++) { if (new Random().Next(10, 20) == 10) { EnemyBullet enbul = new EnemyBullet(Fighter.fighters[i].GetLoc().X + 15, Fighter.fighters[i].GetLoc().Y + 30, new Random().Next(10, 25), MyPlane.x, MyPlane.y); enbullist.Add(enbul); } } }
/// <summary> /// 绘制游戏界面 /// </summary> /// <param name="g"></param> private void DrawGame(Graphics g) //绘制界面上所有图像,避免闪烁 { this.BackMove(g); g.DrawImage(bgrounds[index], pix_x, pix_y, 420, 630); g.DrawImage(bgrounds[index], pix_x, pix_y - 630, 420, 630); //绘制背景 g.DrawImage(avatar, 10, 10); //绘制角色头像 g.DrawRectangle(new Pen(Color.Black), new Rectangle(10, 100, 100, 10)); //绘制血条矩形 g.FillRectangle(Brushes.Red, 10, 101, MyPlane.health, 9); //填充血条矩形 g.DrawRectangle(new Pen(Color.Blue), new Rectangle(10, 120, 100, 10)); g.FillRectangle(Brushes.Green, 11, 121, MyPlane.score, 9); g.DrawString("Player:xjc", new Font("宋体", 9, FontStyle.Bold), Brushes.Yellow, new Point(10, 140)); //显示玩家 g.DrawString("Score:" + MyPlane.score, new Font("宋体", 9, FontStyle.Bold), Brushes.Yellow, new Point(10, 160)); //显示分数 MyPlane.MyPlaneShow(g); MyPlane.MyPlaneMove(); MyBullet.ProduceMybul(); MyBullet.MoveMybul(g); MyBullet.IsHitEnemy(g); Fighter.ProduceFighter(); Fighter.FighterMove(g); EnemyBullet.ProduceEnbul(); EnemyBullet.MoveEnbul(g); EnemyBullet.HitPlane(g); this.ProduceShotGun(); this.ProduceBlood(); if (isDropGun && !MyPlane.isGetGun) //判断是否产生shotgun,并绘制 { g.DrawImage(shotImg, 200, shot_y); } if (MyPlane.isGetGun) { g.DrawImage(shotImg, new Point(0, -500)); } if (isDropBox && !MyPlane.isGetBlood) //判断是否产生bloodbox,并绘制 { g.DrawImage(bloodImg, 350, blood_y); } if (MyPlane.isGetBlood) { g.DrawImage(bloodImg, new Point(0, -500)); } }