// Called at every point in the code at which an enemy is killed // Controls the "give the player a key when they kill all enemies in a room" public static void EnemyKilled() { currentLevel.numEnemiesLeft--; // If this takes us down to zero, gift the player a key, which they can use to unlock the given door if (Game1.inBossRush && currentLevel.numEnemiesLeft == 0) { LinkInventory inventory = link.GetComponent <LinkInventory>(); inventory.AddDungeonItem((int)ItemInventory.DungeonInventory.KEYS); // change the sprite of the door } else if (currentLevel.DropKey && currentLevel.numEnemiesLeft == 0) { Item.CreateKey(currentLevel.KeyPos); } if (currentLevel.numEnemiesLeft < 0) { Console.WriteLine("ERROR: EnemyKilled() called in a room with 0 enemies in it!"); } }
public override void ResolveCollision(LinkCollisionResponse other) { if (!collided) { collided = true; // Actual item pickup is the fanfare, selecting from inventory is Get_Item Sound.PlaySound(Sound.SoundEffects.Fanfare, entity, !Sound.SOUND_LOOPS); // logic for adding items to HUD depending on type Link link = (Link)other.entity; LinkInventory inventory = link.GetComponent <LinkInventory>(); // update item inventory numbers switch (currentItem.GetItemType()) { case "fairy": // increment health by an amount break; case "bomb": inventory.AddBombs(); // Console.WriteLine("Bombs = " + inventory.GetUseableItemCount((int)ItemInventory.UseInventory.BOMB)); break; case "arrow": inventory.AddPassiveItem((int)ItemInventory.PassiveIventory.ARROWS); // Console.WriteLine("Arrows = " + inventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.ARROWS)); break; case "regularkey": inventory.AddDungeonItem((int)ItemInventory.DungeonInventory.KEYS); // Console.WriteLine("Keys = " + inventory.GetDungeonItemCount((int)ItemInventory.DungeonInventory.KEYS)); break; case "bosskey": inventory.AddDungeonItem((int)ItemInventory.DungeonInventory.BOSS_KEY); // Console.WriteLine("Boss Key = " + inventory.GetDungeonItemCount((int)ItemInventory.DungeonInventory.BOSS_KEY)); break; case "clock": // freeze enemies for a time break; case "compass": inventory.AddDungeonItem((int)ItemInventory.DungeonInventory.COMPASS); // Console.WriteLine("Compass = "******"yellowmap": case "bluemap": inventory.AddDungeonItem((int)ItemInventory.DungeonInventory.MAP); // Console.WriteLine("Map = " + inventory.GetDungeonItemCount((int)ItemInventory.DungeonInventory.MAP)); break; case "rupee": inventory.AddPassiveItem((int)ItemInventory.PassiveIventory.RUPEES, currentItem.value); // Console.WriteLine("Rupees = " + inventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.RUPEES)); Sound.PlaySound(Sound.SoundEffects.Get_Rupee, false); break; default: break; } Entity.Destroy(entity); } }