static string MakeListOfCounts(Model.PieceCount pieceCount) { StringBuilder builder = new StringBuilder(); builder.Append(pieceCount.m_cannonballCount).Append(" cannonballs\n"); builder.Append(pieceCount.m_parchmentCount).Append(" parchments\n"); builder.Append(pieceCount.m_jewelCount).Append(" jewels\n"); builder.Append(pieceCount.m_bottleCount).Append(" bottles"); return(builder.ToString()); }
void OnCountDoneButtonClick() { m_countSection.SetActive(false); m_endSection.SetActive(true); m_state = State.End; // Read in piece counts from UI Model.PieceCount[] actualPieceCounts = new Model.PieceCount[4] { ReadPieceCounts(m_countSection.transform.Find("EyesPieceInputPanel").gameObject), ReadPieceCounts(m_countSection.transform.Find("HandsPieceInputPanel").gameObject), ReadPieceCounts(m_countSection.transform.Find("EarsPieceInputPanel").gameObject), ReadPieceCounts(m_countSection.transform.Find("MouthPieceInputPanel").gameObject) }; // Were the players correct? int difference = Model.DifferencePieceCounts(m_finalPieceCounts, actualPieceCounts); if (difference == 0) { m_endSection.transform.Find("Explanation").GetComponent <Text>().text = "You were perfect!"; m_endSection.transform.Find("Congratulations").gameObject.SetActive(true); m_endSection.transform.Find("Try Again").gameObject.SetActive(false); } else { m_endSection.transform.Find("Explanation").GetComponent <Text>().text = string.Concat(difference, " pieces were wrong"); m_endSection.transform.Find("Congratulations").gameObject.SetActive(false); m_endSection.transform.Find("Try Again").gameObject.SetActive(true); } // Update star count var starContainer = m_endSection.transform.Find("Stars"); foreach (Transform child in starContainer) { child.gameObject.SetActive(false); } if (difference == 0) { starContainer.GetChild(2).gameObject.SetActive(true); // 3 stars } else if (difference < 5) { starContainer.GetChild(1).gameObject.SetActive(true); // 2 stars } else if (difference < 15) { starContainer.GetChild(0).gameObject.SetActive(true); // 1 stars } // Report errors for (int playerIndex = 0; playerIndex < 4; playerIndex++) { GameObject errorBoxes = GetErrorBoxes((Model.Player)playerIndex); var pieceCountDifference = Model.SubtractPieceCounts(m_finalPieceCounts[playerIndex], actualPieceCounts[playerIndex]); UpdateErrorBox(errorBoxes, "CannonballBox", pieceCountDifference.m_cannonballCount); UpdateErrorBox(errorBoxes, "ParchmentBox", pieceCountDifference.m_parchmentCount); UpdateErrorBox(errorBoxes, "JewelBox", pieceCountDifference.m_jewelCount); UpdateErrorBox(errorBoxes, "BottleBox", pieceCountDifference.m_bottleCount); } }