IEnumerator BuildSequence(Item toRemove, float myTime)      // this is a coroutine - a sequence that prevents certain items from happening until others have finished
    {
        Inventory.instance.Remove(toRemove);
        MessagesUI.SetMessage("Building");
        yield return(waitForTimer());

        yield return(StartTimedAction());

        yield return(TimedAction(myTime));

        if (toRemove.name == "Plank")
        {
            planksNeeded = planksNeeded - 1;
        }
        else
        {
            stonesNeeded = stonesNeeded - 1;
        }
        if ((planksNeeded == 0) && (stonesNeeded == 0))
        {
            finished = true;
            print("finished Building");
            startSite.SetActive(false);
            endSite.SetActive(true);
        }
        else
        {
            print("Planks needed: " + planksNeeded + " and Stones needed: " + stonesNeeded);
        }
    }
    void Build()
    {
        print("Buildable - Trying to build");

        if (finished == false)
        {
            if (EquipmentManager.equippedTool.name == "Hammer")
            {
                for (int i = 0; i < InventoryUI.inventory.items.Count; i++)
                {
                    if (InventoryUI.inventory.items[i].name == "Plank" && planksNeeded != 0)
                    {
                        StartCoroutine(BuildSequence(InventoryUI.inventory.items[i], 5.0f));
                        break;
                    }
                    else if (InventoryUI.inventory.items[i].name == "Stone" && stonesNeeded != 0)
                    {
                        StartCoroutine(BuildSequence(InventoryUI.inventory.items[i], 5.0f));
                        break;
                    }
                    MessagesUI.SetMessage("Still Needed: Stones - " + stonesNeeded + " Planks - " + planksNeeded);
                }
            }
            else
            {
                print("Equip a Hammer");
            }
        }
        else
        {
            print("Finished");
        }
    }
Exemple #3
0
    IEnumerator CraftSequence(Item toRemove, Item toAdd, float myTime)      // this is a coroutine - a sequence that prevents certain items from happening until others have finished
    {
        Inventory.instance.Remove(toRemove);
        MessagesUI.SetMessage("Crafting " + toAdd.name);
        yield return(waitForTimer());

        yield return(StartTimedAction());

        yield return(TimedAction(myTime));

        Inventory.instance.Add(toAdd);
    }
Exemple #4
0
 void Collect()
 {
     if (EquipmentManager.equippedTool.name == itemNeeded)
     {
         count = count + 1;
         if (count == actionsNeeded)
         {
             Inventory.instance.Add(item);
             //MessagesUI.SetMessage("Got " + item.name);
             count = 0;
         }
     }
     else
     {
         MessagesUI.SetMessage("Equip a " + itemNeeded);
     }
 }