Пример #1
0
 private static Image imgEnemyBullet = Resources.bullet;//一样把图先存在字段imgEnemyBullet里
 /// <summary>
 /// 初始化子弹时要知道的参数是飞机的类型,速度,威力值
 /// </summary>
 /// <param name="pf"></param>
 /// <param name="speed"></param>
 /// <param name="power"></param>
 public EnemyBullet(PlaneFather pf, int speed, int power) : base(imgEnemyBullet, pf, power, speed, "BULLET-EnemyBullet")
 {
     //敌机跟机各不同,矫正坐标要在各自的类中改
     //这里让敌机的子弹坐标跟着其自己的前面
     Y = pf.Y + pf.Height / 2 + 20;
     X = pf.X + pf.Width / 2 - 10;
 }
Пример #2
0
 /// <summary>
 /// 子弹的共有属性,图,所属飞机,速度,名,x坐标,y坐标,高,宽,生命,种类
 /// 子弹的x,y坐标与飞机的x,y坐标相绑定,并且有一定的位移偏差,子弹的高与宽都用Image对象的
 /// 属性传进去了,生命直接赋给它零
 /// </summary>
 /// <param name="img"></param>
 /// <param name="pf"></param>
 /// <param name="power"></param>
 /// <param name="speed"></param>
 /// <param name="name"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="height"></param>
 /// <param name="width"></param>
 /// <param name="life"></param>
 /// <param name="vari"></param>
 public Bullet(Image img, PlaneFather pf, int power, int speed, string name)
     : base(name, (pf.X + pf.Width / 2), (pf.Y + pf.Height / 2) - 50, img.Height, img.Width, speed, 0, pf.Vari)
 {
     //把对应的子弹,威力值赋给要实例化的子对象(本机子弹或敌机子弹)
     this.BulletImg = img;
     this.Power     = power;
 }
Пример #3
0
 public HeroBullet(PlaneFather pf, int power, int speed) : base(ImgHeroBullect, pf, power, speed * 3, "BestHeroBullet")
 {
     //由于在继承Bullet已经给本机子弹矫正,这里不需要矫正
 }