private async void Handler_SeeHighScore(object sender, EventArgs e) { await DispatcherHelper.RunAsync(() => { var DefaultColor = new LinearGradientBrush(); DefaultColor.StartPoint = new Point(0.5, 0); DefaultColor.EndPoint = new Point(0.5, 1); DefaultColor.GradientStops = new GradientStopCollection(); DefaultColor.GradientStops.Add(new GradientStop() { Color = Windows.UI.Colors.Gray, Offset = 0 }); DefaultColor.GradientStops.Add(new GradientStop() { Color = Windows.UI.Colors.Brown, Offset = 1 }); HighScoreBackGround = DefaultColor; QuestionFieldBackground = DefaultColor; QuestionField = "Tryck på knappen i mitten för att gå till Startsidan."; AlternativeOneBackground = DefaultColor; AlternativeOneField = ""; AlternativeTwoBackground = DefaultColor; ExternalButtons.ButtonTwoPressed += ButtonTwoGoHomePressed; AlternativeTwoField = "Gå till startsida"; AlternativeThreeBackground = DefaultColor; AlternativeThreeField = ""; var index = 1; foreach (var person in handler.GetHighscores()) { HighScoreList.Add("Plats " + index + ":" + "\t" + person.ToString() + " av " + scoreList.Count() + " möjliga."); index++; } }); }
//method to add a highscore, it takes care of the scenario when //list is already full and an existing entry needs to be replaced public void AddHighScore(string name, int flameScore, int score) { //add stuff here HighScoreList entry = new HighScoreList(); entry.playerName = name; entry.flameScore = flameScore; entry.finalScore = score; //check if we have reached max entries if (highScores.Count == maxScoresToBeListed) { //remove the bottom most entry highScores.RemoveAt(highScores.Count - 1); } //now let us find a position for this new entry int pos = GetIndexFor(score); //and insert it in the list if (pos < highScores.Count) { //insert it at the specified position highScores.Insert(pos, entry); } else { //add it at the end highScores.Add(entry); } }
public void AddScoreEntry(int score, string name) {//função que recebe a pontuação e a grava na lista e depois num arquivo HighScore entry = new HighScore { Score = score, Name = name }; BinaryFormatter bf = new BinaryFormatter(); //se o arquivo existir if (File.Exists(Application.persistentDataPath + "/ScoreData.dat")) { FileStream file = File.Open(Application.persistentDataPath + "/ScoreData.dat", FileMode.Open); HighScoreList scoreList = (HighScoreList)bf.Deserialize(file); file.Close(); scoreList.ScoreEntryList.Add(entry); file = File.Create(Application.persistentDataPath + "/ScoreData.dat"); bf.Serialize(file, scoreList); file.Close(); } else {//arquivo sendo criado a primeira vez HighScoreList scoreList = new HighScoreList { ScoreEntryList = new List <HighScore>() }; scoreList.ScoreEntryList.Add(entry); FileStream file = File.Create(Application.persistentDataPath + "/ScoreData.dat"); bf.Serialize(file, scoreList); file.Close(); } }
public bool IsNewFirstPlaceHS(TimeSpan TS) { if (HighScoreList.FirstOrDefault().TimeSpan > TS) { return(true); } return(false); }
public static void SaveHighscores(List <HighScoreObject> highscores) { HighScoreList list = new HighScoreList(highscores); string path = Application.persistentDataPath + "/highscores.txt"; string json = JsonUtility.ToJson(list); File.WriteAllText(path, json); }
//Creates a score board sorted by time public HighScoreBoard(HighScoreList scoreList) { ScoreList = scoreList; if (ScoreList == null) { ScoreList = new HighScoreList(); } }
public static void SaveHighScoreList() { string path = Path.Combine(Application.streamingAssetsPath, "HighScores.json"); var container = new HighScoreList(highScoreList); string json = JsonUtility.ToJson(container); File.WriteAllText(path, json); }
private void Start() { for (int i = 0; i < highscoresText.Length; i++) { highscoresText[i].text = i + 1 + ". Fetching Data..."; } highscoreManager = GetComponent <HighScoreList>(); StartCoroutine(RefreshHighScores()); }
private void displayScores(int playerPosition) { highScoreDisplayObject.SetActive(true); HighScoreList listScript = highScoreDisplayObject.GetComponent <HighScoreList>(); listScript.playerPosition = playerPosition; listScript.populateTable(scores); anyKeyChangeSceneObject.gameObject.SetActive(true); }
public void CreateDefault() { highScores = new HighScoreList(); for (int i = 0; i < 10; i++) { HighScore score = new HighScore(); score.name = "NA"; highScores.highScores.Add(score); } }
void Awake() { if (Instance) { Destroy(this); } else { Instance = this; } }
//for showing highscore list data provided the mode private void PopulateHighScoreListData(GSTJ_Core.GameMode mode) { //need to remove existing rows in the table //index is starting from 0 as sample row is disabled by default and won't //be returned using GetComponentsInChildren HighScoreEntry[] curList = scoreContainer.GetComponentsInChildren <HighScoreEntry>(); for (int i = 0; i < curList.Length; i++) { //destroy the list items Destroy(curList[i].gameObject); } //now let's get the list and req num of entries from the high score meta List <HighScoreList> list = default; if (mode == GSTJ_Core.GameMode.Single) { list = GSTJ_Core.HighScoreList.highScores; } else //for multiplayer mode { list = GSTJ_Core.HighScoreListMP.highScores; } //let's instantiate new rows, populate them with data and add them to the table for (int i = 0; i < list.Count; i++) { //get listing data from the highscore meta object HighScoreList listData = list[i]; //create a new entry using sample entry GameObject entryObj = Instantiate(sampleScoreEntry, sampleScoreEntry.transform.position, sampleScoreEntry.transform.rotation); //move it in proper position and make it visible entryObj.transform.SetParent(sampleScoreEntry.transform.parent); //resetting the scale to make it visible entryObj.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); entryObj.SetActive(true); HighScoreEntry entry = entryObj.GetComponent <HighScoreEntry>(); //let us populate this entry using the data from highscore meta object string rank = ""; if (i <= 8) { rank = "0" + (i + 1).ToString(); } else { rank = i.ToString(); } entry.PopulateEntry(rank, listData.playerName, listData.flameScore, listData.finalScore); } }
public static void AddHighScoreEntry(int score, string name) { // create new high score HighScoreEntry highScoreEntry = new HighScoreEntry(score, name); //load list of previous scores HighScoreList highScore = LoadHighScores(); // add new high score to the list highScore.scoreList.Add(highScoreEntry); // save modified high score list SaveHighScores(highScore.scoreList); }
//Called at at the beginning of the game for options and scores public void LoadFromPlayerPrefs() { if (highScores != null) { highScores = JsonUtility.FromJson <HighScoreList>(PlayerPrefs.GetString("MyData")); print(highScores); } GameManager.instance.isOnePlayer = (PlayerPrefs.GetInt("OnePlayer") != 0); GameManager.instance.isOnePlayer = (PlayerPrefs.GetInt("PS4Controller") != 0); GameManager.instance.isMapOfTheDay = (PlayerPrefs.GetInt("MapOfTheDay") != 0); settingsMenu.currentMusicVolume = (PlayerPrefs.GetFloat("MusicVolume")); settingsMenu.currentSFXVolume = (PlayerPrefs.GetFloat("SFXVolume")); }
// == gets/sets == private void Awake() { entryContainer = transform.Find("ScoreContainer"); entryTemplate = entryContainer.Find("ScoreEntry"); entryTemplate.gameObject.SetActive(false); // load high scores from data highScoreList = SaveSystem.LoadHighScores(); if (highScoreList != null) { //highScoreEntryList = new List<HighScoreEntry>(); highScoreEntryList = highScoreList.getHighScoreList(); } else { // initalise new list with sample data (only happens when program is first run) highScoreEntryList = new List <HighScoreEntry>() { new HighScoreEntry(2500, "KAT"), new HighScoreEntry(3500, "KEN"), new HighScoreEntry(4000, "SAM"), new HighScoreEntry(4500, "JOE"), new HighScoreEntry(5000, "BOB") }; // save score data SaveSystem.SaveHighScores(highScoreEntryList); } // sort list in descending order for (int i = 0; i < highScoreEntryList.Count; i++) { for (int j = i + 1; j < highScoreEntryList.Count; j++) { if (highScoreEntryList[j].score > highScoreEntryList[i].score) { // swap scores HighScoreEntry temp = highScoreEntryList[i]; highScoreEntryList[i] = highScoreEntryList[j]; highScoreEntryList[j] = temp; } } } // create a list of scores and display them in a table highScoreEntryTransformList = new List <Transform>(); foreach (HighScoreEntry highScoreEntry in highScoreEntryList) { CreateHighScoreTransform(highScoreEntry, entryContainer, highScoreEntryTransformList); } }
//adds the name of the players and their score to a list in sorted order public static void AddNameAndScore(string name, int score) { HighScore newHS = new HighScore(name, score); if (IsHighScore(score)) { if (HighScoreList.Count >= 5) { HighScoreList.RemoveAt(HighScoreList.Count - 1); } HighScoreList.Add(newHS); HighScoreList.Sort(); } }
// Load the current score from the high score list stored in the persistentDataPath public static HighScoreList LoadScores() { if (!File.Exists(_savePath)) { return(null); } BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(_savePath, FileMode.Open); HighScores = (HighScoreList)bf.Deserialize(file); file.Close(); return(HighScores); }
void Update() { if (Input.GetKeyDown(KeyCode.P)) { int score = Random.Range(0, 1000); string username = ""; string alphabet = "abcdefghijlkmnopqrstuvwxyz"; for (int i = 0; i < Random.Range(5, 10); i++) { username += alphabet[Random.Range(0, alphabet.Length)]; } HighScoreList.AddNewHighScore(username, score); } }
private void FormatHighscores(string textStream) { string[] entries = textStream.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries); highscoresList = new HighScoreList[entries.Length]; scoreListText.text = ""; for (int i = 1; i < entries.Length; i++) { string[] entryInfo = entries[i].Split(new char[] { '|' }); string playername = entryInfo[1]; int score = int.Parse(entryInfo[2]); highscoresList[i] = new HighScoreList(playername, score); print(highscoresList[i].playername + ": " + highscoresList[i].score); scoreListText.text = scoreListText.text + highscoresList[i].playername + highscoresList[i].score; scoreListText.text = scoreListText.text + "\n"; } }
private int SaveHighScoreList(SQLiteConnection connection, string highScoreList) { //get the lesson var scores = connection.Table <HighScoreList>().FirstOrDefault(x => x.Name == highScoreList); if (null == scores) { scores = new HighScoreList { Name = highScoreList }; connection.Insert(scores); } return(scores.Id); }
public static void SaveHighScores(List <HighScoreEntry> scoreList) { // instantiate binary formatter BinaryFormatter formatter = new BinaryFormatter(); // set string path string path = Application.persistentDataPath + "/highscores.save"; // instantiate file stream FileStream stream = new FileStream(path, FileMode.Create); // instantiate high score data HighScoreList highScore = new HighScoreList(scoreList); // serialize data formatter.Serialize(stream, highScore); //close stream stream.Close(); }
// Write the current score to the high score list stored in the persistentDataPath public static void SaveScore(string currentSong, string playerName, int score, int maxCombo, int hits, int misses) { BinaryFormatter bf = new BinaryFormatter(); //HighScoreList highScores = null; if (File.Exists(_savePath)) { file = new FileStream(_savePath, FileMode.Open); // if(file.Length != 0){ HighScores = bf.Deserialize(file) as HighScoreList; // } } //Debug.Log("(!File.Exists(_savePath) || file.Length == 0): " + (!File.Exists(_savePath) || file.Length == 0)); // if(!File.Exists(_savePath) || file.Length == 0) else { file = new FileStream(_savePath, FileMode.Create); HighScores = new HighScoreList(); } //Debug.Log(_savePath); // Debug.Log("Pre add: highScores.scoreList.Count: " + highScores.scoreList.Count); //Debug.Log("Pre Add: " + HighScores.ToString()); // TODO: Player profile HighScores.AddNewScore(currentSong, playerName, score, maxCombo, hits, misses); //Debug.Log("Post Add: " + HighScores.ToString()); // Debug.Log("Post add: highScores.scoreList.Count: " + highScores.scoreList.Count); bf.Serialize(file, HighScores); //HighScores = (HighScoreList)bf.Deserialize(file); //Debug.Log("Immediately Deserialized: " + HighScores.ToString()); file.Close(); // file = File.Open(_savePath, FileMode.Open); // highScores = (HighScoreList)bf.Deserialize(file); // Debug.Log("Closed and reopened: " + highScores.ToString()); // // Debug.Log("End step: highScores.scoreList.Count: " + highScores.scoreList.Count); // file.Close(); }
public int ScoreLenght = 10;//mostra apenas os 10 maiores pontuadores private void Awake() { ScoreBarContainer = transform.Find("BodyContainer"); ScoreBarBody = ScoreBarContainer.Find("Body"); ScoreBarBody.gameObject.SetActive(false); //se existir lista criada ele já a apresenta na tela if (File.Exists(Application.persistentDataPath + "/ScoreData.dat")) { FileStream file = File.Open(Application.persistentDataPath + "/ScoreData.dat", FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); HighScoreList scoreList = (HighScoreList)bf.Deserialize(file); file.Close(); scoreList.SortIt();//coloca os elementos em ordem EntryTransformList = new List <Transform>(); //le a lista para colocar os elementos foreach (HighScore entry in scoreList.ScoreEntryList) { CreateScore(entry, ScoreBarContainer, EntryTransformList); } } }
private void LoadHighScore() { HighScoreList = ReadWrite.ReadJson <List <HighScoreObj> > (PathSettings, @"\highscore", ".json"); //High Score if (HighScoreList == null) { HighScoreList = new List <HighScoreObj>(); } if (HighScoreList.Count < 6) { int addToFive = 5 - HighScoreList.Count; for (int i = 0; i < addToFive; i++) { HighScoreList.Add(new HighScoreObj { DateTime = DateTime.Now, Handle = "Empty", TimeSpan = new TimeSpan(7, 23, 59, 59) }); } } HighScoreList = HighScoreList.OrderBy(x => x.TimeSpan).ThenBy(y => y.DateTime).ToList(); }
public static HighScoreList LoadHighScores() { string path = Application.persistentDataPath + "/highscores.save"; if (File.Exists(path)) { // instantiate binary formatter BinaryFormatter formatter = new BinaryFormatter(); // instantiate file stream FileStream stream = new FileStream(path, FileMode.Open); // instantiate score data HighScoreList highScore = formatter.Deserialize(stream) as HighScoreList; // close stream stream.Close(); // return data return(highScore); } else { // file not found return(null); } }
private void Awake() { instance = this; hallOfFame = GetComponent <HallOfFame>(); }
// Start is called before the first frame update void Start() { saveData = GameManager.instance.saveData; highScoreList = saveData.highScores; }
//Converts the different types of data for highscores into a JSON string public string HighScoreToString(HighScoreList input) { string temp = JsonUtility.ToJson(input); return(temp); }
void SetHighScores() { string jsonData = File.ReadAllText(filePath); highScores = JsonUtility.FromJson <HighScoreList>(jsonData); }
private void Start() { highScores = new HighScoreList(); filePath = Path.Combine(Application.dataPath, fileName); }