IEnumerator getDelay(UnitSupply unitSupply) { yield return(new WaitForSeconds(pickupDelay)); if (supplyStash.MannaAmount >= unitSupply.mannaCapacity) { supplyStash.MannaAmount -= unitSupply.mannaCapacity; unitSupply.mannaAmount = unitSupply.mannaCapacity; } else { unitSupply.mannaAmount = supplyStash.MannaAmount; supplyStash.MannaAmount = 0; } unitSupply.supplyChainInteract = null; unitSupply.StartBehaviour(); }
IEnumerator setDelay(Interactable interactor, UnitSupply unitSupply) { yield return(new WaitForSeconds(dropDelay)); UnitSupply supplier = unitSupply; if (supplier == null) { Debug.LogError("Builders Unit Supply component missing!"); yield return(null); } if (supplier.mannaAmount <= 0) { supplier.StartBehaviour(); } CmdUpdateManna(interactor.GetComponent <NetworkIdentity> (), supplier.mannaAmount); supplier.mannaAmount = 0; supplier.StartBehaviour(); }
public override void Interact(Interactable interactor) { base.Interact(interactor); UnitSupply unitSupply = interactor.GetComponent <UnitSupply> (); if (unitSupply == null) { Debug.LogError("Unit Supply Component was not found on Interactor"); } unitSupply.supplyInteract = this; if (supplyStash.MannaAmount <= 0) { //add SEARCH to a new supply stash here supplyStash.MannaAmount = 0; unitSupply.stopInteractions(); Debug.LogError("Unit Supply is empty"); return; } StartCoroutine(getDelay(unitSupply)); }