public void applyCure(ToolBox.Tool tool, BodyPartType part) { // Skip if no tool set if (tool == ToolBox.Tool.None) { return; } // Test out the rule system bool fixesColor = false; bool success = RulesSystem.EvaluateCure(bodyParts, tool, part, bodyColor, ref heartbeat, out fixesColor); // Did color get fixed? if (fixesColor) { bodyColor = BodyPartColor.White; SetupColor(); } // Tell game controller if we did this wrong if (!success) { GameObject gameControllerObject = GameObject.FindGameObjectWithTag("GameController"); GameController gameController = gameControllerObject.GetComponent(typeof(GameController)) as GameController; gameController.FailedCureAttempt(); painLevel = BodyPainLevel.Worse; lastOuch = Time.time; } sound.playBodyEffect(tool, success); }
// Returns true if the patient is fully healed (no more symptoms!) public bool IsFullyHealed() { if (bodyParts == null) { return(false); } foreach (BodyPart bodyPart in bodyParts) { // We still have a problem: not fully healed if (bodyPart.symptom != Symptom.None) { return(false); } } // Is the skin color non-white? if (bodyColor != BodyPartColor.White) { return(false); } // Is the heartbeat cured? if (heartbeat != kTargetHeartbeat) { return(false); } // Graphics change painLevel = BodyPainLevel.Cured; // Fully healed return(true); }
// Update is called once per frame void Update() { if (HeartRateText != null) { HeartRateText.text = heartbeat.ToString(); } if (bodyMesh != null) { //Set the current pain level if (painLevel == BodyPainLevel.Worse) { if (Time.time - lastOuch > ouchTime) { painLevel = BodyPainLevel.Bad; } } Texture newTexture = bodyTextures[(int)painLevel]; bodyMesh.GetComponent <Renderer>().material.mainTexture = newTexture; } }
public void setPainLevel(BodyPainLevel pain) { if (pain == BodyPainLevel.Worse) { lastOuch = Time.time; } painLevel = pain; if (painLevel == BodyPainLevel.Dead || painLevel == BodyPainLevel.Cured) { foreach (BodyPart part in bodyParts) { if (part.BloodSpurt != null) { Destroy(part.BloodSpurt, 2f); } else if (part.PainEffect != null) { Destroy(part.PainEffect, 2f); } } } }
/*** Symptoms Setup ***/ void SetupSymptoms() { //Re-set the pain level: painLevel = BodyPainLevel.Bad; // 50% chance that the heartbeat is abnormal if (Random.Range(0, 2) == 0) { heartbeat = kTargetHeartbeat; } else { heartbeat = Random.Range(85, 121); } // 50% chance of abnormal color int colorCount = System.Enum.GetNames(typeof(BodyPartColor)).Length; if (Random.Range(0, 2) == 0) { bodyColor = BodyPartColor.White; } else { bodyColor = (BodyPartColor)Random.Range(1, colorCount); } // Initialize body parts with no symptom int bodyPartCount = System.Enum.GetNames(typeof(BodyPartType)).Length; bodyParts = new BodyPart[bodyPartCount]; for (int i = 0; i < bodyPartCount; i++) { bodyParts[i] = new BodyPart(); bodyParts[i].bodyPartType = (BodyPartType)i; bodyParts[i].symptom = Symptom.None; } // List rof symptoms we randomly shuffle: we will apply these int kSymptomCount = System.Enum.GetNames(typeof(Symptom)).Length; List <Symptom> symptoms = new List <Symptom>(); for (int i = 0; i < kSymptomCount; i++) { symptoms.Add((Symptom)i); } symptoms.Sort((a, b) => 1 - 2 * Random.Range(0, 1)); // Shitty performance / approach while (symptoms.Count > 0) { // Pick random body part. If it's not yet assigned, assign it now int bodyPartIndex = Random.Range(0, bodyPartCount); if (bodyParts[bodyPartIndex].symptom == Symptom.None) { // Assign a random and unique symptom bodyParts[bodyPartIndex].symptom = symptoms[0]; symptoms.RemoveAt(0); } } // Print out for debugging foreach (BodyPart bodyPart in bodyParts) { // Debug.Log("Body part " + bodyPart.bodyPartType + " has symptom: " + bodyPart.symptom); } }