public Bullet(BulletProperties properties, Tower tower) { this.properties = properties; Tower = tower; }
public virtual bool Fire(out Bullet[] bullets) { if (TargetAimed != null && TargetAimed.HP > 0 && !InReloading) { if (Range + 32f < DistanceFrom(TargetAimed.PositionX, TargetAimed.PositionY)) { TargetExitRange(TargetAimed); return(Fire(out bullets)); } else { InReloading = true; bullets = new Bullet[BulletNumber]; for (int i = 0; i < BulletNumber; i++) { BulletProperties bulletProperties = new BulletProperties { damage = Damage, elementType = ElementType, isPenetrable = false, positionX = PositionX, positionY = PositionY, speed = Speed, rotation = Convert.ToSingle(Math.Atan2(TargetAimed.PositionY - PositionY, TargetAimed.PositionX - PositionX) * 180.0 / Math.PI - BulletSpanRange * (BulletNumber - 1) / 2.0 + BulletSpanRange * i) }; switch (ElementType) { case ElelmentType.Normal: bullets[i] = new Bullet(bulletProperties, this); break; case ElelmentType.Ice: bullets[i] = new IceBullet(bulletProperties, this, ElementLevel); break; case ElelmentType.Fire: bullets[i] = new FireBullet(bulletProperties, this, ElementLevel); break; case ElelmentType.Thunder: bulletProperties.isPenetrable = true; bullets[i] = new ThunderBullet(bulletProperties, this, ElementLevel); break; case ElelmentType.Wind: bullets[i] = new WindBullet(bulletProperties, this, ElementLevel, TargetAimed); break; case ElelmentType.Poison: bulletProperties.isPenetrable = true; bullets[i] = new PoisonBullet(bulletProperties, this, ElementLevel); break; case ElelmentType.Wood: bullets[i] = new WoodBullet(bulletProperties, this); break; } } return(true); } } else { TargetAimed = null; bullets = null; return(false); } }