public override IEnumerable <GameObject> ProduceObjects() { List <GameObject> producedObjects = new List <GameObject>(); if (this.IsShooting) { var projectile = new Projectile(this.topLeft, new MatrixPosition(1, 0)); projectile.Owner = ProjectileOwner.Alien; producedObjects.Add(projectile); this.IsShooting = false; } Gift producedGift = new Gift(new MatrixPosition(0, 0), new MatrixPosition(0, 0)); if (this.IsDestroyed) { producedGift = GameData.GetGift(); if (producedGift is GiftLife) { producedGift = new GiftLife(new MatrixPosition(this.TopLeft.Row + 1, this.TopLeft.Col), new MatrixPosition(1, 0)); producedObjects.Add(producedGift); } if (producedGift is GiftPoints) { producedGift = new GiftPoints(new MatrixPosition(this.TopLeft.Row + 1, this.TopLeft.Col), new MatrixPosition(1, 0)); producedObjects.Add(producedGift); } } return(producedObjects); }
public static Gift GetGift() { //create a "fake" gift Gift producedGift = new Gift(new MatrixPosition(0, 0), new MatrixPosition(0, 0)); int randomNumber = randomGenerator.Next(101); if (randomNumber <= giftLevel) { switch (randomGenerator.Next(3)) { case 0: producedGift = new GiftLife(new MatrixPosition(0, 0), new MatrixPosition(0, 0)); break; case 1: case 2: producedGift = new GiftPoints(new MatrixPosition(0, 0), new MatrixPosition(0, 0)); break; default: break; } } return(producedGift); }