public override bool CheckProcPreconditions(GameObject agent) { ResourceSupply sources; sources = WorldInfo.treeStorages; ResourceSupply closest = null; Vector3 position = agent.transform.position; closest = sources; if (closest == null) { //UnityEngine.Debug.LogWarning("Resource supply not found"); return(false); } resourcesNeeded = GetComponent <ExpandStorageAction>().expandExpences; if (closest.resourceCount < ResourceAmountNeeded) { // UnityEngine.Debug.LogWarning("Wood resource amount contains: " + closest.resourceCount + " and didn't have enough (" + ResourceAmountNeeded + ") to upgrade"); return(false); } // TODO: check if it gets to this point in the code. target = closest.gameObject; targetResourceSupply = closest; // Debug.Log("Closest = " + closest); return(closest != null); }
private void FindResourceSupply() { foreach (var item in GetComponentsInChildren <ResourceSupply>()) { if (item.storageType == ResourceSupply.StorageTypes.BerryStorage) { berrySupply = item; } else if (item.storageType == ResourceSupply.StorageTypes.WoodStorage) { woodSupply = item; } } }
public override bool CheckProcPreconditions(GameObject agent) { if (WorldInfo.filledStorage.Count == 0) { // Debug.Log("None to upgrade"); return(false); } //else // Debug.Log("Some to upgrade"); List <ResourceSupply> sources = new List <ResourceSupply>(); sources = WorldInfo.filledStorage; ResourceSupply closest = null; float distance = Mathf.Infinity; Vector3 position = agent.transform.position; if (sources.Count == 0) { Debug.LogError("No resource for " + gameObject.name); } foreach (ResourceSupply source in sources) { Vector3 diff = source.transform.position - position; float curDistance = diff.sqrMagnitude; if (curDistance < distance) { closest = source; distance = curDistance; } } if (closest == null) { UnityEngine.Debug.LogWarning("Resource supply not found for " + gameObject); return(false); } target = closest.gameObject; targetSupplyToExpand = closest; expandExpences = targetSupplyToExpand.UpgradeCost; return(closest != null); }
public override bool CheckProcPreconditions(GameObject agent) { ResourceSupply sources; sources = (CurrGatherType == GatherType.BerryGatherer) ? WorldInfo.berrySorages : WorldInfo.treeStorages; ResourceSupply closest = null; Vector3 position = agent.transform.position; closest = sources; if (closest == null) { UnityEngine.Debug.LogWarning("Resource supply not found"); return(false); } target = closest.gameObject; targetResourceSupply = closest; return(closest != null); }
public override void Reset() { Storage.resourceHolding = 0; hasResource = false; targetResourceSupply = null; }
public override void Reset() { recivedFood = false; targetResourceSupply = null; }
public override void Reset() { Storage.resourceHolding = 0; upgraded = false; targetSupplyToExpand = null; }