private static void InitEntry(string name, object startValue, RunData.EntryType type, System.Func <object, int> weight = null, System.Func <object, string> format = null) { ScoreBoardInfo info = new ScoreBoardInfo(type, format ?? ((o) => o.ToString()), weight ?? ((_) => 10)); ScoreBoardConfig.Add(name, info); CurrentRun.Set(name, startValue); }
public void playerEntry(ScoreBoardInfo playersInfo) { scoreboardListInfo.Add(playersInfo); sortListByTime(); foreach (ScoreBoardInfo scoreboardEntry in scoreboardListInfo) { highScoreEntry(scoreboardEntry, transformContainer, scoreboardListTransform); } }
public void playerEntry(ScoreBoardInfo playersInfo) { //Add the players info to the list scoreboardListInfo.Add(playersInfo); //sort the list relative to Time (Longer is better) sortListByTime(); //Create an entry for each of the scores info in the list depending on max entrys for (int i = 0; i < maxEntrys; i++) { highScoreEntry(scoreboardListInfo[i], transformContainer, scoreboardListTransform); } }
private void highScoreEntry(ScoreBoardInfo scoreBoardInfo, Transform container, List <Transform> transforms) { Transform entryTransform = Instantiate(entry, container); RectTransform entryrect = entryTransform.GetComponent <RectTransform>(); entryrect.anchoredPosition = new Vector2(0, -(transforms.Count) * heightOfEntry); entryTransform.gameObject.SetActive(true); //Fill with Test Values entryTransform.Find("Name").GetComponent <Text>().text = scoreBoardInfo.name; entryTransform.Find("Time").GetComponent <Text>().text = scoreBoardInfo.time.ToString(); entryTransform.Find("Kills").GetComponent <Text>().text = scoreBoardInfo.enemiesKilled.ToString(); transforms.Add(entryTransform); }
private void sortListByTime() { //Sort the times highest to Time for (int i = 0; i < scoreboardListInfo.Count; i++) { for (int j = i + 1; j < scoreboardListInfo.Count; j++) { if (scoreboardListInfo[j].time > scoreboardListInfo[i].time) { //Swap the placements ScoreBoardInfo tempHolder = scoreboardListInfo[i]; scoreboardListInfo[i] = scoreboardListInfo[j]; scoreboardListInfo[j] = tempHolder; } } } }
private void sortListByTime() { //Sort the times highest to Time for (int i = 0; i < scoreboardListInfo.Count; i++) { for (int j = i + 1; j < scoreboardListInfo.Count; j++) { if (scoreboardListInfo[j].time > scoreboardListInfo[i].time) { //Swap the placements //Temp to hold the info while it is changed over ScoreBoardInfo tempHolder = scoreboardListInfo[i]; //Swaping list info palces scoreboardListInfo[i] = scoreboardListInfo[j]; scoreboardListInfo[j] = tempHolder; } } } }