private void CheckClose() { Ray ray = new Ray(playerCamera.transform.position, playerCamera.transform.forward); RaycastHit hit; if (Physics.Raycast(playerCamera.transform.position, playerCamera.transform.forward, out hit, 2)) { if (hit.transform.tag == "Hole") { HoleController hole = hit.transform.gameObject.GetComponent <HoleController>(); if (hole.GetOpen() == true) { hole.Close(); } } else if (hit.transform.tag == "Empolyee") { EmpolyeeController empolyee = hit.transform.gameObject.GetComponent <EmpolyeeController>(); if (empolyee.GetHanging() == true) { empolyee.Climb(); } } } }
public void OpenHole() { int tries = 0; while (tries < 4) { int randomNum = Random.Range(0, holes.Length); if (holes.Length != 0) { HoleController compCon = holes[randomNum].GetComponent <HoleController>(); if (compCon.GetOpen() == false) { compCon.Open(); tries = 4; } } tries++; } }