Ejemplo n.º 1
0
    private void TakeHayBale(Player player)
    {
        if (player.currentlyEquippedItem.id == equippableItemID.BAREHANDS)
        {
            GameObject newBale;
            if (fillType == equippableItemID.STRAW)
            {
                newBale = Instantiate(PrefabManager.instance.strawBale, player.equippedItemPos.position, player.equippedItemPos.rotation) as GameObject;
            }
            else                 // if (fillType == equippableItemID.HAY) { is implied but this way newbale is definitely defined
            {
                newBale = Instantiate(PrefabManager.instance.hayBale, player.equippedItemPos.position, player.equippedItemPos.rotation) as GameObject;
            }

            --currentUnits;

            Equippable equippable = newBale.GetComponent <Equippable> ();
            equippable.Initialize();

            player.EquipAnItem(equippable);

            if (currentUnits == 0)
            {
                hayPileRenderer.enabled = false;
            }
        }
    }