Ejemplo n.º 1
0
        public bool CreateItem(Vector2 startingPos, Vector2 direction)
        {
            ProjectileHandler projectileHandler = ProjectileHandler.Instance;

            InventoryManager.ItemType type = InventoryManager.Instance.ItemSlot;
            if (type == InventoryManager.ItemType.None)
            {
                return(false);
            }
            InventoryManager.ItemType decType = type;
            if (type == InventoryManager.ItemType.Arrow)
            {
                decType = InventoryManager.ItemType.Rupee;
            }
            if (InventoryManager.Instance.ItemCount(decType) == 0)
            {
                return(false);
            }
            InventoryManager.Instance.RemoveFromInventory(decType);
            switch (type)
            {
            case InventoryManager.ItemType.Arrow:
                projectileHandler.CreateArrowItem(batch, startingPos, direction);
                break;

            case InventoryManager.ItemType.Boomerang:
                if (!RoomProjectiles.Instance.projectiles.Contains(boomerang))
                {
                    boomerang = projectileHandler.CreateBoomerangItem(batch, linkState.Sprite, direction);
                }
                else
                {
                    return(false);
                }
                break;

            case InventoryManager.ItemType.Bomb:
                projectileHandler.CreateBombItem(batch, startingPos);
                break;

            case InventoryManager.ItemType.MagicalRod:
                if (InventoryManager.Instance.ItemCount(InventoryManager.ItemType.MagicBook) > 0)
                {
                    CreateMagicFireball(startingPos, direction);
                }
                else
                {
                    CreateMagicBeam(startingPos, direction);
                }
                break;

            case InventoryManager.ItemType.BluePotion:
                linkState.Health = linkState.TotalHealth;
                break;

            default:
                return(false);
            }
            return(true);
        }