private void GenerateDrop(Enemy e) { Random random = new Random(); int dropRange = 55; switch (e.EnemyType) { case EnemyType.EASY: if (random.NextDouble() < 0.8) { break; } double r = random.NextDouble(); if (r < 0.5) { otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin, itemFactory.CreateHealthPotion())); } else if (r < 0.8) { otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin, itemFactory.CreateManaPotion())); } else { otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin, itemFactory.CreateRandomItem())); } break; case EnemyType.NORMAL: if (random.NextDouble() < 0.7) { break; } r = random.NextDouble(); if (r < 0.5) { otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin, itemFactory.CreateHealthPotion())); } else if (r < 0.8) { otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin, itemFactory.CreateManaPotion())); } else { otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin, itemFactory.CreateRandomItem())); } break; case EnemyType.ELITE: double potsAmount = random.Next(1, 3); //up to 2 potions for (int i = 0; i < potsAmount; i++) { r = random.NextDouble(); if (r < 0.6) { otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin + new Vector2(random.Next(-dropRange, dropRange), random.Next(-dropRange, dropRange)) , itemFactory.CreateHealthPotion())); } else { otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin + new Vector2(random.Next(-dropRange, dropRange), random.Next(-dropRange, dropRange)) , itemFactory.CreateManaPotion())); } } double itemsAmount = random.Next(1, 4); //up to 3 items for (int i = 0; i < itemsAmount; i++) { //5% better chances for rare+ items r = random.NextDouble(); ItemRarity rarity = ItemRarity.COMMON; if (r > 0.9) { rarity = ItemRarity.LEGENDARY; } else if (r > 0.7) { rarity = ItemRarity.EPIC; } else if (r > 0.35) { rarity = ItemRarity.RARE; } otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin + new Vector2(random.Next(-dropRange, dropRange), random.Next(-dropRange, dropRange)), itemFactory.CreateRandomItem(rarity))); } break; case EnemyType.BOSS: potsAmount = random.Next(2, 5); //up to 4 potions for (int i = 0; i < potsAmount; i++) { r = random.NextDouble(); if (r < 0.6) { otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin + new Vector2(random.Next(-dropRange, dropRange), random.Next(-dropRange, dropRange)) , itemFactory.CreateHealthPotion())); } else { otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin + new Vector2(random.Next(-dropRange, dropRange), random.Next(-dropRange, dropRange)) , itemFactory.CreateManaPotion())); } } //guaranteed legendary item otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin, itemFactory.CreateRandomItem(ItemRarity.LEGENDARY))); itemsAmount = random.Next(2, 6); //between 2 and 5 items RARE or better for (int i = 0; i < itemsAmount; i++) { r = random.NextDouble(); ItemRarity rarity = ItemRarity.RARE; if (r > 0.8) { rarity = ItemRarity.LEGENDARY; } else if (r > 0.45) { rarity = ItemRarity.EPIC; } otherSprites.Add(itemFactory.CreateItemSprite(e.GlobalOrigin + new Vector2(random.Next(-dropRange, dropRange), random.Next(-dropRange, dropRange)) , itemFactory.CreateRandomItem(rarity))); } break; } }