public void Setup(GridLevelData.Goal goal) { icon.sprite = goal.data.icon; titleText.text = M8.Localize.Get(goal.data.nameTextRef); mSB.Clear(); mSB.Append("· "); mSB.Append(M8.Localize.Get(volumeReqTextRef)); var editCtrl = GridEditController.instance; var goalVolume = goal.volume * editCtrl.levelData.unitVolume; //goalVolume.SimplifyImproper(); //goalVolume.Simplify(); goalVolume.FractionToWhole(); var goalHeight = goal.unitHeightRequire * editCtrl.levelData.sideMeasure; goalHeight.SimplifyImproper(); if (goalHeight.fValue > 0f) { mSB.Append('\n'); mSB.Append("· "); mSB.Append(M8.Localize.Get(heightReqTextRef)); } descText.text = mSB.ToString(); mSB.Clear(); mSB.Append(UnitMeasure.GetVolumeText(goal.measureType, goalVolume)); if (goalHeight.fValue > 0f) { mSB.Append('\n'); mSB.Append(UnitMeasure.GetMeasureText(goal.measureType, goalHeight)); } valueText.text = mSB.ToString(); }
void Awake() { var sb = new System.Text.StringBuilder(); //apply header display sb.AppendLine(M8.Localize.Get(sidesTextRef)); sb.Append(M8.Localize.Get(volumeTextRef)); headerText.text = sb.ToString(); //apply info display var editCtrl = GridEditController.instance; var measureType = editCtrl.levelData.measureType; var side = editCtrl.levelData.sideMeasure; var volume = side * side * side; sb.Clear(); sb.AppendLine(UnitMeasure.GetMeasureText(measureType, side)); sb.Append(UnitMeasure.GetVolumeText(measureType, volume)); infoText.text = sb.ToString(); }
private void RefreshDisplay() { var editCtrl = GridEditController.instance; var curEval = editCtrl.goalEvaluations[mCurrentEvaluateIndex]; var curGoal = editCtrl.levelData.goals[mCurrentEvaluateIndex]; var goalVolume = curGoal.volume * editCtrl.levelData.unitVolume; //goalVolume.SimplifyImproper(); goalVolume.Simplify(); var goalHeight = curGoal.unitHeightRequire * editCtrl.levelData.sideMeasure; goalHeight.SimplifyImproper(); //header icon.sprite = curGoal.data.icon; titleText.text = M8.Localize.Get(curGoal.data.nameTextRef); //total volume mSB.Clear(); if (curEval.isValid) { //mSB.Append(UnitMeasure.GetVolumeText(editCtrl.levelData.measureType, curEval.volume)); mSB.Append(UnitMeasure.GetVolumeText(editCtrl.levelData.measureType, curEval.volume.simplified)); } else { mSB.Append("-- " + UnitMeasure.GetVolumeText(editCtrl.levelData.measureType)); } volumeText.text = mSB.ToString(); var isVolumeMet = curEval.GoalIsVolumeMet(curGoal); var isHeightMet = curEval.GoalIsHeightMet(curGoal); //volume req mSB.Clear(); mSB.Append(UnitMeasure.GetVolumeText(curGoal.measureType, goalVolume)); reqs[0].Setup(mSB.ToString(), isVolumeMet, isVolumeMet ? reqCorrectColor : reqIncorrectColor); //height req if (goalHeight.fValue > 0f) { mSB.Clear(); mSB.Append(UnitMeasure.GetMeasureText(curGoal.measureType, goalHeight)); reqs[1].Setup(mSB.ToString(), isHeightMet, isHeightMet ? reqCorrectColor : reqIncorrectColor); reqs[1].rootGO.SetActive(true); } else { reqs[1].rootGO.SetActive(false); } if (isVolumeMet && isHeightMet) //valid, show efficiency { var s = curEval.GoalEfficiencyScale(curGoal); var percent = Mathf.RoundToInt(s * 100f); mSB.Clear(); mSB.Append(M8.Localize.Get(efficiencyTextRef)); mSB.Append(' '); mSB.Append(percent); mSB.Append('%'); efficiencyText.text = mSB.ToString(); efficiencyText.gameObject.SetActive(true); errorText.gameObject.SetActive(false); errorText2.gameObject.SetActive(false); //volumeGO.SetActive(true); } else //error, show message { if (!curEval.isValid) { errorText.text = M8.Localize.Get(errorNoMatchTextRef); LoLManager.instance.SpeakText(errorNoMatchTextRef); } else { int speakQueue = 0; if (!isVolumeMet) { errorText.text = M8.Localize.Get(errorVolumeTextRef); LoLManager.instance.SpeakTextQueue(errorVolumeTextRef, speechGroup, speakQueue); speakQueue++; } if (!isHeightMet) //Each object's height must be {0} tall! { if (isVolumeMet) { errorText.text = M8.Localize.Get(errorHeightTextRef);//string.Format(M8.Localize.Get(errorHeightTextRef), UnitMeasure.GetMeasureText(curGoal.measureType, goalHeight)); } else { errorText2.text = M8.Localize.Get(errorHeightTextRef); errorText2.gameObject.SetActive(true); } LoLManager.instance.SpeakTextQueue(errorHeightTextRef, speechGroup, speakQueue); } } efficiencyText.gameObject.SetActive(false); errorText.gameObject.SetActive(true); //volumeGO.SetActive(false); } volumeGO.SetActive(true); if (editCtrl.goalEvaluations.Length == 1) { prevButton.gameObject.SetActive(false); nextButton.gameObject.SetActive(false); } else if (mCurrentEvaluateIndex <= 0) { prevButton.gameObject.SetActive(false); nextButton.gameObject.SetActive(true); } else if (mCurrentEvaluateIndex >= editCtrl.goalEvaluations.Length - 1) { prevButton.gameObject.SetActive(true); nextButton.gameObject.SetActive(false); } //check if we have all goals met if (editCtrl.isAllGoalsMet) { //check if we are at the last index if (mCurrentEvaluateIndex >= editCtrl.goalEvaluations.Length - 1) { var prevBuildActive = buildReadyGO.activeSelf; buildReadyGO.SetActive(true); if (!prevBuildActive && buildReadyGO.activeSelf) { if (!string.IsNullOrEmpty(sfxBuildReady)) { M8.SoundPlaylist.instance.Play(sfxBuildReady, false); } } } } else { buildReadyGO.SetActive(false); } }