void DetectBuilding() { Ray raycast = new Ray(playerCamera.position, playerCamera.forward); RaycastHit hit; if (Physics.Raycast(raycast, out hit, detectionDistance)) { if (detected == false) { detected = true; if (hit.collider.gameObject.CompareTag("Building")) { ui = hit.collider.gameObject.GetComponent <resource>(); ui.SetCloseEnough(true); } if (hit.collider.gameObject.CompareTag("Resource")) { // target is rock ui = hit.collider.gameObject.GetComponent <resource>(); ui.SetCloseEnough(true); res = hit.collider.gameObject.GetComponent <resource>(); } } } else { if (ui != null) { ui.SetCloseEnough(false); ui = null; } if (res != null) { res = null; } detected = false; } }
public void RemoveResourceFromWatch(resource fromWatch) { m_activeResources.Remove(fromWatch); }
public void AddResourceToWatch(resource toWatch) { m_activeResources.Add(toWatch); }