public void SetPrescription(PrescriptionData prescription) { currentPrescription = prescription; }
public void CreatePrescription() { PrescriptionData resultPrescription = new PrescriptionData (); prescriptionLines.Clear (); int dayIndex = gameEngine.daysCount - 1; int difficultyIndex = (dayIndex >= difficultyLevels.Count ? (difficultyLevels.Count - 1) : dayIndex); DifficultyLevel difficulty = difficultyLevels [difficultyIndex]; int numberOfMedsOnTable = Random.Range( difficulty.minNumberOfMeds, difficulty.maxNumberOfMeds ); int numberOfLines = Random.Range (difficulty.minNumberOfLines, difficulty.maxNumberOfLines); string result = ""; List<int> usedMeds = new List<int> (); List<int> usedSuffixes = new List<int> (); int fontIndex = Random.Range (0, fonts.Count); prescriptionText.font = fonts [fontIndex]; prescriptionText.fontSize = characterSizeByFont [fontIndex]; prescriptionText.GetComponent<Renderer> ().material = fontMaterials [fontIndex]; doctorSignature.text = doctorNames [fontIndex]; doctorSignature.font = fonts [fontIndex]; doctorSignature.fontSize = characterSizeByFont [fontIndex]; doctorSignature.GetComponent<Renderer> ().material = fontMaterials [fontIndex]; for (int i = 0 ; i < numberOfLines ; i++) { string newLine = ""; int medsCount = Random.Range (minMedsCount, maxMedsCount); newLine += medsCount + " "; int medIndex = Random.Range(0,prescriptionMedsSingular.Count); while (usedMeds.Contains(medIndex)) { medIndex = Random.Range(0,prescriptionMedsSingular.Count); } usedMeds.Add(medIndex); if (medsCount <= 1) { newLine += prescriptionMedsSingular[medIndex] + " "; } else { newLine += prescriptionMedsPlural[medIndex] + " "; } int suffixIndex = Random.Range(0,prescriptionSuffixs.Count); while (usedSuffixes.Contains(suffixIndex)) { suffixIndex = Random.Range(0,prescriptionSuffixs.Count); } usedSuffixes.Add(suffixIndex); PrescriptionSuffix suffix = prescriptionSuffixs[suffixIndex]; newLine += suffix.message + "."; string[] stringSplit = newLine.Split(' '); newLine = ""; int characterCount = 0; foreach (string str in stringSplit) { characterCount += str.Length + 1; if (characterCount > maxCharacterCountOnALineByFont[fontIndex]) { newLine += "\n" + str + " "; characterCount = str.Length + 1; } else { newLine += str + " "; } } resultPrescription.AddMedicationData(prescriptionMedsName[medIndex], medsCount, suffix.frequencyByDay, suffix.needMorning, suffix.needNoon, suffix.needEvening, suffix.isRequired); prescriptionLines.Add(newLine); result += newLine + "\n"; } prescriptionText.text = result; List<string> usedMedNames = new List<string>(); foreach (MedicationData data in resultPrescription.listOfMedications) { usedMedNames.Add(data.medicationName); } medsContainerManager.HideAllContainers (); medsContainerManager.ShowContainers (usedMedNames); medsContainerManager.AddRandomContainers (numberOfMedsOnTable - usedMedNames.Count); gameEngine.SetPrescription (resultPrescription); }