start of high scores
This commit is contained in:
parent
c7f780a70b
commit
789e474b64
2737
Assets/Scenes/Naomi_HighScoreMenu.unity
Normal file
2737
Assets/Scenes/Naomi_HighScoreMenu.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scenes/Naomi_HighScoreMenu.unity.meta
Normal file
7
Assets/Scenes/Naomi_HighScoreMenu.unity.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4eb415b6d6ead8c41a01f9eca038e0dc
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
58
Assets/Scripts/HighScoreManager.cs
Normal file
58
Assets/Scripts/HighScoreManager.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class HighScoreManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
private Transform entryContainer;
|
||||||
|
private Transform entryTemplate;
|
||||||
|
private List<HighScoreEntry> highScoreEntryList;
|
||||||
|
private List<Transform> highScoreEntryTransformList;
|
||||||
|
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
entryContainer = transform.Find("EntryContainer");
|
||||||
|
entryTemplate = entryContainer.Find("EntryTemplate");
|
||||||
|
entryTemplate.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
highScoreEntryList = new List<HighScoreEntry>()
|
||||||
|
{
|
||||||
|
new HighScoreEntry{score = 1000, time = "60"},
|
||||||
|
new HighScoreEntry{score = 9000, time = "60"},
|
||||||
|
new HighScoreEntry{score = 3000, time = "60"},
|
||||||
|
new HighScoreEntry{score = 8000, time = "60"},
|
||||||
|
};
|
||||||
|
highScoreEntryList.Sort((s1, s2) => s1.score.CompareTo(s2.score));
|
||||||
|
|
||||||
|
highScoreEntryTransformList = new List<Transform>();
|
||||||
|
foreach(HighScoreEntry highScoreEntry in highScoreEntryList)
|
||||||
|
{
|
||||||
|
CreateHighScoreEntryTransform(highScoreEntry, entryContainer, highScoreEntryTransformList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void CreateHighScoreEntryTransform(HighScoreEntry entry, Transform container, List<Transform> transformList)
|
||||||
|
{
|
||||||
|
float templateHeight = 50f;
|
||||||
|
Transform entryTransform = Instantiate(entryTemplate, container);
|
||||||
|
RectTransform entryRectTransform = entryTransform.GetComponent<RectTransform>();
|
||||||
|
entryRectTransform.anchoredPosition = new Vector2(0, -templateHeight * transformList.Count);
|
||||||
|
entryTransform.gameObject.SetActive(true);
|
||||||
|
|
||||||
|
entryTransform.Find("Rank").GetComponent<Text>().text = $"{transformList.Count + 1}";
|
||||||
|
entryTransform.Find("Score").GetComponent<Text>().text = $"{entry.score}";
|
||||||
|
entryTransform.Find("Time").GetComponent<Text>().text = entry.time;
|
||||||
|
|
||||||
|
transformList.Add(entryTransform);
|
||||||
|
}
|
||||||
|
private class HighScoreEntry
|
||||||
|
{
|
||||||
|
public int score;
|
||||||
|
public string time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
11
Assets/Scripts/HighScoreManager.cs.meta
Normal file
11
Assets/Scripts/HighScoreManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: da0be35ca0d6da5469b4cfb8738252e9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user