public override void Init() { Color[] backgroundColor = new Color[Game1.ScreenWidth * Game1.ScreenHeight]; for (int i = 0; i < backgroundColor.Length; ++i) { backgroundColor[i] = Color.Black; } blackBackground = new Texture2D(graphicsDevice, Game1.ScreenWidth, Game1.ScreenHeight); blackBackground.SetData(backgroundColor); TmxMap map = new TmxMap("Content/Maps/map_dungeon.tmx"); TileMap = new TileMap(map); itemFactory = new ItemFactoryImpl(); Game1.Player = PlayerIdentitiesDepository.Mage(); Game1.Player.Position = new Vector2(2244, 1205); itemFactory.SetPlayer(Game1.Player); otherSprites = new List <Sprite> { itemFactory.CreateItemSprite(new Vector2(250f), itemFactory.CreateHealthPotion()) }; Game1.Player.Inventory.EquipItem(itemFactory.CreateRandomWeapon(ItemRarity.LEGENDARY)); hittableSprites = new List <Sprite>(); // for (int i = 240; i < 1500; i += 150) // { // Enemy monster3 = EnemyDepository.Zombie(new Vector2(1, i)); // hittableSprites.Add(monster3); // } camera = new Camera(Game1.Player); gui = new GUI(); var songs = new List <Song> { Content.Load <Song>("Sounds/LYbeat"), Content.Load <Song>("Sounds/NE"), Content.Load <Song>("Sounds/RM") }; //backgroundMusic = new BackgroundMusic(songs); }
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; } }