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");
        }
    }
Exemplo n.º 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);
    }
Exemplo n.º 4
0
    public void Signal(string name, string message, Transform source)
    {
        var  d       = this.Dist(source);
        bool didHear = d < SoundDistance;
        bool clearly = d < HearingDistance;

        if (debug)
        {
            var logMsg = didHear ? "{0} heard {1} ({2:#.00}m)"
                                                                 : "{0} did not hear {1} ({2:#.00}m)";
            print(string.Format(logMsg, this.Name(), source.Name(), d));
        }
        if (isLocalPlayer)
        {
            MessagesUI.OnMessage(name, message, didHear, clearly);
        }
    }
Exemplo n.º 5
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);
     }
 }
Exemplo n.º 6
0
	void Start(){
		instance = this;
	}