/** * Remove all disease cubes of cured disease in a given city. * Use this helper method for movement actions (Medic power). */ private void treatDiseasesByMedicMovement(GameObject city) { CityScript cityScript = city.GetComponent <CityScript> (); GameObject[] diseaseList = GameObject.FindGameObjectsWithTag("Disease"); foreach (GameObject disease in diseaseList) { DiseaseScript diseaseScript = disease.GetComponent <DiseaseScript> (); DiseaseColour colour = diseaseScript.getColour(); if (diseaseScript.getCured()) { int numCubesRemoved = cityScript.removeAllCubes(colour); diseaseScript.removeCubes(numCubesRemoved); // check for eradication if (diseaseScript.getCubesOnBoard() == 0) { diseaseScript.setEradicated(true); } } } }
public void RpcTreatDisease(GameObject player, GameObject disease) { PlayerScript playerScript = player.GetComponent <PlayerScript> (); Role role = playerScript.getRole().getRoleName(); CityScript cityScript = playerScript.getCurrentCity().GetComponent <CityScript> (); DiseaseScript diseaseScript = disease.GetComponent <DiseaseScript> (); DiseaseColour colour = diseaseScript.getColour(); if (diseaseScript.getCured()) { // remove all cubes of the chosen disease int numCubesRemoved = cityScript.removeAllCubes(colour); diseaseScript.removeCubes(numCubesRemoved); // check for eradication if (diseaseScript.getCubesOnBoard() == 0) { diseaseScript.setEradicated(true); } } else if (role == Role.Medic) { // remove all cubes of the chosen disease int numCubesRemoved = cityScript.removeAllCubes(colour); diseaseScript.removeCubes(numCubesRemoved); } else { cityScript.decrementCubeCount(colour); diseaseScript.removeCubes(1); } playerScript.decrementActionsLeft(); }