public void useCurrentToolOnPatient() { Debug.Log("useCurrentToolOnPatient triggered\nCurrent Tool: " + currentTool); if (dirtyHands && currentTool.GetToolType() != Tool.ToolType.DEFIBULATOR) { // Signal this somehow. DoctorEvents.Instance.InformDoctorNeedsToWashHands(0.0f); return; } if (Patient.Instance.transform.parent != null) { Debug.Log("Patient being carried off -- can't operate"); return; } if (currentTool.GetToolType() != Tool.ToolType.DEFIBULATOR && !tutorialSurgeryStepComplete) { DoctorEvents.Instance.InformSurgeryOperation(); inSurgery = true; } else { //play defibulator surge AudioControl.Instance.PlayDefibulatorSurge(); } // Use current tool on patient. if (TutorialEventController.Instance.tutorialActive && currentTool != null && currentTool.GetToolType() != Tool.ToolType.DEFIBULATOR) { TutorialEventController.Instance.InformDoctorAtPatient(GetComponent <DoctorInputController>().playerNum); } surgeryInput = Patient.Instance.receiveOperation(currentTool, GetComponent <DoctorInputController>().playerNum); if (currentTool.GetToolType() != Tool.ToolType.DEFIBULATOR) { currentTool.gameObject.SetActive(false); } }
// returns new surgery input (transfered control) public SurgeryToolInput receiveOperation(Tool tool, int doctorNumber = -1) { SurgeryToolInput newInputController = null; if (tool == null) { return(newInputController); } if (tool.GetToolType() == Tool.ToolType.SUTURE) { //Get Doctor that initiated operation GameObject doc = GameObject.Find("Doctor_" + (doctorNumber + 1).ToString()); if (doc == null) { Debug.Log("couldn't find doctor!"); } //Disable their input component doc.GetComponent <DoctorInputController>().enabled = false; GameObject suture = (GameObject)Instantiate(sutureToolPrefab, toolSpawnPositions[0].transform); suture.transform.parent = toolSpawnPositions[0].transform; suture.transform.localPosition = Vector3.zero; suture.transform.parent = null; newInputController = suture.GetComponent <SurgeryToolInput>(); newInputController.playerNum = doctorNumber; suture.transform.parent = this.transform; Debug.Log("recieving suture operation"); } else if (tool.GetToolType() == Tool.ToolType.SCALPEL) { //Get Doctor that initiated operation GameObject doc = GameObject.Find("Doctor_" + (doctorNumber + 1).ToString()); if (doc == null) { Debug.Log("couldn't find doctor!"); } //Disable their input component doc.GetComponent <DoctorInputController>().enabled = false; //Create tool and give control to Doctor if (!scalpel1Placed) { //Create tool and give control to Doctor GameObject scalpel = (GameObject)Instantiate(scalpelToolPrefab, toolSpawnPositions[0].transform); scalpel.transform.parent = toolSpawnPositions[0].transform; scalpel.transform.localPosition = Vector3.zero; scalpel.transform.parent = null; newInputController = scalpel.GetComponent <SurgeryToolInput>(); newInputController.playerNum = doctorNumber; scalpel1Placed = true; scalpel.transform.parent = this.transform; } else { if (TutorialEventController.Instance.tutorialActive) { GameObject scalpel = (GameObject)Instantiate(duplicateScalpelSurgeryTool, toolSpawnPositions[0].transform); scalpel.transform.parent = toolSpawnPositions[0].transform; scalpel.transform.localPosition = Vector3.zero; scalpel.transform.parent = null; newInputController = scalpel.GetComponent <SurgeryToolInput>(); newInputController.playerNum = doctorNumber; scalpel.transform.parent = this.transform; } else { //Create tool and give control to Doctor GameObject scalpel = (GameObject)Instantiate(scalpelToolPrefab, toolSpawnPositions[0].transform); scalpel.transform.parent = toolSpawnPositions[0].transform; scalpel.transform.localPosition = Vector3.zero; scalpel.transform.parent = null; newInputController = scalpel.GetComponent <SurgeryToolInput>(); newInputController.playerNum = doctorNumber; scalpel1Placed = true; scalpel.transform.parent = this.transform; } } Debug.Log("recieving scalpel operation"); } else if (tool.GetToolType() == Tool.ToolType.GAUZE) { //Get Doctor that initiated operation GameObject doc = GameObject.Find("Doctor_" + (doctorNumber + 1).ToString()); if (doc == null) { Debug.Log("couldn't find doctor!"); } //Disable their input component doc.GetComponent <DoctorInputController>().enabled = false; //Create tool and give control to Doctor GameObject gauze = (GameObject)Instantiate(gauzeToolPrefab, toolSpawnPositions[0].transform); gauze.transform.parent = toolSpawnPositions[0].transform; gauze.transform.localPosition = Vector3.zero; gauze.transform.parent = null; newInputController = gauze.GetComponent <SurgeryToolInput>(); newInputController.playerNum = doctorNumber; gauze.transform.parent = this.transform; Debug.Log("recieving gauze operation"); } else { print("defibulationsRemaining: " + defibulationsRemaining); if (defibulationsRemaining > 0) { if (tool.GetToolType() == Tool.ToolType.DEFIBULATOR) { defibulationsRemaining--; } } if (defibulationsRemaining == 0) { DoctorEvents.Instance.PatientCriticalAdverted(); if (TutorialEventController.Instance.tutorialActive) { TutorialEventController.Instance.InformHeartAttackAdverted(); } } } return(newInputController); }