public override void ResolveCollision(LinkCollisionResponse other) { if (!done) { Link link = (Link)other.entity; LinkInventory linkInventory = link.GetComponent <LinkInventory>(); // update item inventory numbers switch (currentItem.GetItemType()) { case "bow": linkInventory.AddUseableItem((int)ItemInventory.UseInventory.BOW); // Console.WriteLine("Bow = " + linkInventory.GetUseableItemCount((int)ItemInventory.UseInventory.BOW)); LevelManager.backdrop.Bow.GetComponent <Sprite>().SetVisible(true); break; case "raft": linkInventory.AddPassiveItem((int)ItemInventory.PassiveIventory.RAFT); // Console.WriteLine("Raft = " + linkInventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.RAFT)); break; case "ladder": linkInventory.AddPassiveItem((int)ItemInventory.PassiveIventory.LADDER); // Console.WriteLine("Ladder = " + linkInventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.LADDER)); break; case "powerBand": linkInventory.AddPassiveItem((int)ItemInventory.PassiveIventory.POWER_BAND); // Console.WriteLine("Power Band = " + linkInventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.POWER_BAND)); break; default: break; } Sprite itemSprite = entity.GetComponent <Sprite>(); int itemSpriteWidth = itemSprite.sprite.frames[itemSprite.sprite.currentFrame].Width; LinkBehavior linkBehavior = link.GetComponent <LinkBehavior>(); linkBehavior.picking_up_item = true; linkBehavior.linkHands = 1; Transform linkTrans = link.GetComponent <Transform>(); linkTrans.position += new Vector2(-itemSpriteWidth / 2, 0); Sprite linkSprite = link.GetComponent <Sprite>(); int linkSpriteHeight = linkSprite.sprite.frames[linkSprite.sprite.currentFrame].Height; entity.GetComponent <Transform>().position += new Vector2(0, -linkSpriteHeight); entity.GetComponent <ItemDeletionTimer>().startTimer = true; done = true; } }
public override void ResolveCollision(LinkCollisionResponse other) { if (!done) { Link link = (Link)other.entity; LinkInventory linkInventory = link.GetComponent <LinkInventory>(); // update item inventory numbers switch (currentItem.GetItemType()) { case "heartContainer": Scene.Find("link").GetComponent <LinkHealthManagement>().health = Constants.LINK_STARTING_HEALTH; Sound.PlaySound(Sound.SoundEffects.Get_Heart, false); break; case "triforce": linkInventory.AddPassiveItem((int)ItemInventory.PassiveIventory.TRIFORCE); // Console.WriteLine("Triforce = " + linkInventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.TRIFORCE)); break; default: break; } // animation for picking up item LinkBehavior linkBehavior = link.GetComponent <LinkBehavior>(); linkBehavior.picking_up_item = true; linkBehavior.linkHands = 2; Sprite linkSprite = entity.GetComponent <Sprite>(); int linkSpriteHeight = linkSprite.sprite.frames[linkSprite.sprite.currentFrame].Height; int linkSpriteWidth = linkSprite.sprite.frames[linkSprite.sprite.currentFrame].Width; Sprite itemSprite = entity.GetComponent <Sprite>(); int itemSpriteHeight = itemSprite.sprite.frames[itemSprite.sprite.currentFrame].Height; int itemSpriteWidth = itemSprite.sprite.frames[itemSprite.sprite.currentFrame].Width; Transform linkTrans = link.GetComponent <Transform>(); linkTrans.position += new Vector2(0, itemSpriteHeight); Transform itemPos = entity.GetComponent <Transform>(); itemPos.position += new Vector2(0, -itemSpriteHeight); currentItem.GetComponent <ItemDeletionTimer>().startTimer = true; // if triforce we should quit the game? make black screen? credits? done = true; if (currentItem.GetItemType() == "triforce") { LevelManager.Victory(); } } }
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); } }