public void HandleInput() { Ray inputRay = _camera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit)) { { if (hit.collider.GetComponent <HexMesh>()) { _hexEditor.HitCell(hit); } if (hit.collider.GetComponent <Collectables>()) { Destroy(hit.transform.gameObject); _nutrientManager.AddSugar(1); } if (hit.collider.GetComponent <TreeBehaviour>()) { hit.transform.gameObject.GetComponent <TreeBehaviour>().CollectSugar(); } } } }
public void CollectSugar() { if (readToCollect) { _nutrientManager.AddSugar(treeSugarValue); _collectableManager.AddCollectable(transform.position, treeSugarValue); FindObjectOfType <AudioManager>().Play("Chime"); treeSugarValue = 0; readToCollect = false; } }