void checkInput() { // Charlie: replace this with uh, mouse click I think if (Input.GetMouseButtonUp(0)) { RelayCentre.postMessage(Message.TimeOutCancel); furnitureId = null; StopCoroutine("checkWalking"); RaycastHit hit; Ray ray = mainCam.ScreenPointToRay(cursorPosition); if (Physics.Raycast(ray, out hit)) { if (hit.collider == null) { return; } else if (hit.transform.tag == "Floor" || hit.transform.tag == "Furniture") { agent.SetDestination(hit.point); if (hit.transform.tag == "Furniture") { furnitureId = hit.transform.GetComponent <FurnitureID> (); } StartCoroutine("checkWalking"); } } } }
IEnumerator checkWalking() { //first we need to wait to move while (agent.velocity == Vector3.zero) { yield return(null); } startWalkingSounds(); //now we need to wait till we have stopped while (agent.velocity != Vector3.zero) { RelayCentre.postMessage(Message.TimeOutCancel); yield return(null); } RelayCentre.postMessage(Message.TimeOutCancel); stopWalkingSounds(); if (furnitureId != null) { //now we can interact interactWithFurniture(furnitureId); furnitureId = null; } }
void interactWithFurniture(FurnitureID furniturePiece) { FurnitureType furnitureType; if (furniturePiece == null) { furnitureType = FurnitureType.generic; } else { furnitureType = furniturePiece.furnitureType; } DialogHandler.instance.startDialog(furnitureType); }