// Use this for initialization void Start() { bool isDead = false; lPath = ScoreList.getPath("scores.xml"); evaluation = false; }
// Update is called once per frame //void Update () { public void test() { if (!isDead) { isDead = GameObject.Find("Jugador").GetComponent <PrincesavueScript> ().muerte; if (isDead) { try { scoreCollection = ScoreList.Load(lPath); } catch { createXML3(lPath); scoreCollection = ScoreList.Load(lPath); } guiText.text = ""; //CAMBIAR POR OTRO GUI TEXT guiText.text = scoreCollection.getScores(0).Name + ": " + scoreCollection.getScores(0).Points + " ptos\n" + "" + scoreCollection.getScores(1).Name + ": " + scoreCollection.getScores(1).Points + " ptos\n" + "" + scoreCollection.getScores(2).Name + ": " + scoreCollection.getScores(2).Points + " ptos\n" + "" + scoreCollection.getScores(3).Name + ": " + scoreCollection.getScores(3).Points + " ptos\n" + "" + scoreCollection.getScores(4).Name + ": " + scoreCollection.getScores(4).Points + " ptos\n"; } } }
public void PlayerScoreList() { if (File.Exists(FILE_NAME)) { File.Delete(FILE_NAME); } var list = new ScoreList <PlayerScore>(new PlayerScoreFile(FILE_NAME)); list.AddScore(new PlayerScore("Bjärn", 3)); list.AddScore(new PlayerScore("Snudin", 8)); list.AddScore(new PlayerScore("Satan", 6)); list.AddScore(new PlayerScore("Snigel", -4)); list.AddScore(new PlayerScore("Palettblad", 70)); // The expected score list is sorted by score, descending. var expectedList = new List <PlayerScore> { new PlayerScore("Palettblad", 70), new PlayerScore("Snudin", 8), new PlayerScore("Satan", 6), new PlayerScore("Bjärn", 3), new PlayerScore("Snigel", -4), }; Assert.Equal(expectedList, list.Scores); // Load the scores from the file again. var newList = new ScoreList <PlayerScore>(new PlayerScoreFile(FILE_NAME)); Assert.Equal(expectedList, newList.Scores); }
public void RefreshScores() { //loadingImage.SetActive(true); print(PlayerPrefs.GetString("localScore")); ScoreList jsonScores = JsonUtility.FromJson <ScoreList>(PlayerPrefs.GetString("localScore")); Array.Sort(jsonScores.scores, delegate(Score s1, Score s2) { return(s2.score.CompareTo(s1.score)); }); for (int i = 0; i < jsonScores.scores.Length; i++) { Score s = jsonScores.scores[i]; GameObject newEntry = Instantiate(scoreEntry, scorePanel.transform); newEntry.SetActive(true); newEntry.transform.Find("Name").GetComponent <Text>().text = s.name; newEntry.transform.Find("Date").GetComponent <Text>().text = s.date; newEntry.transform.Find("Score").GetComponent <Text>().text = s.score.ToString(); newEntry.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -150 * i - 75); } scorePanel.GetComponent <RectTransform>().sizeDelta = new Vector2(0, jsonScores.scores.Length * 150); StartCoroutine(ScoreRegistry.GetScores("symbol quiz")); }
private void Start() { // list local scores if (GameObject.FindObjectOfType <LayerManag>().layers[5].activeSelf == true) { ScoreList jsonScores = JsonUtility.FromJson <ScoreList>(PlayerPrefs.GetString("highscoreTable")); scorePanel.GetComponent <RectTransform>().sizeDelta = new Vector2(0, jsonScores.highscoreEntryList.Count * 50); scoreEntry.SetActive(false); jsonScores.highscoreEntryList.Sort((x, y) => y.score.CompareTo(x.score)); for (int i = 0; i < jsonScores.highscoreEntryList.Count; i++) { Score s = jsonScores.highscoreEntryList[i]; GameObject newEntry = Instantiate(scoreEntry, scorePanel.transform); newEntry.SetActive(true); newEntry.transform.Find("TextRank").GetComponent <Text>().text = (i + 1).ToString(); newEntry.transform.Find("TextDate").GetComponent <Text>().text = s.date; newEntry.transform.Find("TextScore").GetComponent <Text>().text = s.score.ToString(); newEntry.transform.Find("TextName").GetComponent <Text>().text = s.name; newEntry.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -50 * i - 30); } } // list global scores if (GameObject.FindObjectOfType <LayerManag>().layers[7].activeSelf == true) { StartCoroutine(GameObject.FindObjectOfType <ScoreRegistry>().GetScores("Grid Blink")); } }
/// <summary> /// Lopettaa pelin ja jos pelaaja pääsee top-listalle, antaa kirjoittaa pelaajan nimen /// Näyttää toplistan ja antaa ilmoituksen mahdollisuudesta aloittaa uuden pelin /// </summary> void PeliLoppui() { ScoreList topLista = new ScoreList(LISTANPITUUS, false, LISTALLEMINPISTEET); topLista = DataStorage.TryLoad <ScoreList>(topLista, "pisteet.xml"); HighScoreWindow topIkkuna = new HighScoreWindow( "Parhaat pisteet", "Onneksi olkoon, pääsit listalle pisteillä %p", topLista, Suurempi() ); Add(topIkkuna); topIkkuna.Closed += delegate(Window ikkuna) { DataStorage.Save <ScoreList>(topLista, "pisteet.xml"); }; topIkkuna.Closed += delegate(Window ikkuna) { MessageDisplay.Add("Aloita uusi peli"); }; }
public static IEnumerator GetGameScores(string gameId, float playerScore, List <Score> ScoresOut) { isLoading = true; string gameScoreUrl = BaseUrl + $"api/{ApiVersion}/scores/{gameId}?player_score={playerScore}"; UnityWebRequest request = UnityWebRequest.Get(gameScoreUrl); yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { Debug.LogError(request.error); } else { ScoreList scoreList = new ScoreList(); string json = request.downloadHandler.text; scoreList = JsonUtility.FromJson <ScoreList>(json); if (scoreList.count == 0) { Debug.Log("No scores from game server!"); } else { Debug.Log("Scores loaded: " + scoreList.count); for (int i = 0; i < scoreList.count; i++) { ScoresOut.Add(scoreList.scores[i]); } } isLoading = false; } }
public HighScore(int map, SpriteFont spriteFont) { _spriteFont = spriteFont; _map = map; LoadHighScoreList(); _scoreList = _highScoreList[_map]; }
public void FetchScoreboard() { XmlSerializer ser = new XmlSerializer (typeof(ScoreList)); WWW scoreRequest = new WWW ("http://localhost:3000/api/v1/scores"); while (!scoreRequest.isDone) { HighScoreText.text = string.Format("{0}", scoreRequest.progress); } ScoreList s = new ScoreList(); using (TextReader r = new StringReader(scoreRequest.text)) { s = (ScoreList)ser.Deserialize(r); } HighScoreText.text = ""; int rank = 1; foreach (ScoreItem score in s.Items) { string rankStr = rank++ + ""; string scoreStr = score.score + ""; HighScoreText.text += string.Format("{0}\t\t{1}\t\t{2}\n", rankStr.PadLeft(4, ' '), score.username, scoreStr); } }
/// <summary> /// Highscore window. /// </summary> public void Points() { ScoreList pointlist = new ScoreList(10, false, 0); pointlist = DataStorage.TryLoad(pointlist, "points.xml"); HighScoreWindow pointWindow; if (pointsAdded == false) { pointWindow = new HighScoreWindow("Enemies killed", "Yay, you killed %p! enemies. What is your name:", pointlist, GameManager.KillCount.Value); pointsAdded = true; } else { pointWindow = new HighScoreWindow("Enemies killed", pointlist); } pointWindow.Closed += delegate { DataStorage.Save(pointlist, "points.xml"); End(); pointsAdded = true; }; Add(pointWindow); }
public static void LoadScore() { string xmlText = PlayerPrefs.GetString("Scores"); if (string.IsNullOrEmpty(xmlText) == false) { XmlSerializer xml = new XmlSerializer(typeof(ScoreList)); using (StringReader reader = new StringReader(xmlText)) { try { Scores = xml.Deserialize(reader) as ScoreList; if (Scores == null) { Scores = new ScoreList(); } } catch { PlayerPrefs.SetString("Scores", ""); Scores = new ScoreList(); } } } }
public void DisplayScoresOnScoreboard(Song song) { if ((object)scoreList == null || scoreList.song != song) { scoreList = new ScoreList(song); scoreList.LoadScores(); } for (int i = 0; i < scoreListContent.childCount; i++) { Destroy(scoreListContent.GetChild(i).gameObject); } int contentHeight = 0; foreach (var playthrough in scoreList.GetScores()) { var scorePanel = Instantiate(scorePrefab, scoreListContent); var texts = scorePanel.GetComponentsInChildren <Text>(); var rt = scorePanel.GetComponent <RectTransform>(); //get rect transform rt.anchoredPosition = new Vector2(rt.anchoredPosition.x, -contentHeight); // set elements position texts[0].text = core.playerName; texts[1].text = playthrough.score.ToString(); contentHeight += (int)rt.sizeDelta.y; } scoreListContent.sizeDelta = new Vector2(0, contentHeight); }
void PelaajaKuolema(ScoreList lista) { pelaaja.Destroy(); ClearAll(); Alkuvalikko(); //topLista.Add(pisteLaskuri.Value); // Lisää pistelaskuri }
public IEnumerator GetTopScores(int levelID, Text textbox) { WWWForm form = new WWWForm(); form.AddField("LevelID", levelID); form.AddField("Limit", limit); UnityWebRequest www = UnityWebRequest.Post(TopScoresURL, form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log("an error occured when feching scores from " + levelID + "...\n" + www.error); textbox.text = "\nAn Error occured...\n" + www.error; } else { Debug.Log("sucessfully fetched from " + levelID); string jsonString = www.downloadHandler.text; Debug.Log(jsonString); ScoreList scores = new ScoreList(); scores = ScoreList.CreateFromJSON(jsonString); textbox.text = scores.ToString(); } }
public void ClearTable() { Saver.DeleteFile(_saveName); _scoreList = new ScoreList(); Saver.SaveData(_scoreList, _saveName); FillTable(); }
private new void Awake() { timeCounter = GetComponent <TimerScript>(); instance = this; base.Awake(); // PlayerScoreList = new Hashtable(); foreach (var player in PhotonNetwork.PlayerList) { //PlayerScoreList.Add(player.NickName, 0); if (player.IsMasterClient) { //Hashtable hash = new Hashtable(); //hash.Add("score", 0); //player.CustomProperties = hash; ScoreList.Add(player, 0); } else { //Hashtable hash = new Hashtable(); //hash.Add("score", 100); //player.CustomProperties = hash; ScoreList.Add(player, 100); } Instantiate(roomListItemPrefab, ScoreBoardContent).GetComponent <ScoreBoardItem>().SetUp(player); } }
IEnumerator LoadScoreListFromServer() { WWW request = new WWW("http://54.202.250.15:3000/api/player/score"); yield return(request); if (request.text == "") { connectFailText.SetActive(true); } else { ScoreList scoreList = JsonUtility.FromJson <ScoreList>(request.text); string scoreListStr = ""; string nameListStr = ""; string rankListStr = ""; for (int i = 0; i < scoreList.score_list.Length; i++) { scoreListStr += scoreList.score_list[i].score + "\n"; nameListStr += scoreList.score_list[i].name + "\n"; rankListStr += (i + 1) + "\n"; } GetComponentsInChildren <Text>()[0].text = rankListStr; GetComponentsInChildren <Text>()[1].text = nameListStr; GetComponentsInChildren <Text>()[2].text = scoreListStr; } }
/// <summary> /// Displays the 5 best scores and saves the scores to a file /// </summary> public void WriteScore() { List <UInt64> ScoreList; if (File.Exists("score.xml")) //check if file exists before trying to read { ScoreList = ListIO.ReadList <UInt64>("score.xml"); ScoreList.Add(Data.Score); ScoreList.Sort(); ScoreList.Reverse(); if (ScoreList.Count > 5) //remove the excess scores { ScoreList.RemoveAt(5); } } else //generate new file if it deos not exists { ScoreList = new List <UInt64> { Data.Score }; } byte Line = 3; foreach (UInt64 CurrScore in ScoreList) //write scores { Console.SetCursorPosition(56, Line); Console.Write(CurrScore.ToString()); Line += 1; } ListIO.WriteList <UInt64>("score.xml", ScoreList); ScoreList = null; }
// Update is called once per frame void Update() { if (ScoreList.getList().Count > 0) { if (ScoreList.getList()[0] < playerController.transform.position.z && !highscoreNotificationCreated) { highscoreNotificationCreated = true; instantiateHighscoreNotification(); } } else { instantiateHighscoreNotification(); } // if enter key or button 0 pressed, and in tutorial, launch game if ((Input.GetKeyDown("joystick button 0") || Input.GetKeyDown(KeyCode.Return)) && tutorial) { tutorial = false; Destroy(instructions); Destroy(image); displayInformations(); MusicManager.play(getRandomMusic(), 0.5f, 0.5f); } else if (!tutorial) { speed.text = "Speed: " + Mathf.Round(playerController.getSpeed() * 10f) / 10f + " km/h"; distance.text = "Distance: " + Mathf.Round(playerController.getDistance() * 10f) / 10f + " m"; } }
IEnumerator CreateLeaderboard(string uri) { using (UnityWebRequest webRequest = UnityWebRequest.Get(uri)) { yield return(webRequest.SendWebRequest()); string[] pages = uri.Split('/'); int page = pages.Length - 1; loadedText = webRequest.downloadHandler.text; Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text); ScoreList newList = JsonUtility.FromJson <ScoreList>("{\"players\":" + loadedText + "}"); for (int i = 0; i < newList.players.Length; i++) { playerLeaderboard.Add(newList.players[i].name, newList.players[i].score); } playerLeaderboard.Add("YOU", localRecord); if (localRecord != lastResult) { playerLeaderboard.Add("ALSO YOU", lastResult); } var sortedDictionary = playerLeaderboard.OrderByDescending(player => player.Value); foreach (var playerScore in sortedDictionary) { leaderboardText.text += string.Format("{0} , {1}\n", playerScore.Key, playerScore.Value); } } }
void Start() { calculoEnd = false; saved = false; instance = this; GameObject player_go = GameObject.FindGameObjectWithTag("Player"); if (player_go == null) { Debug.LogError("No se encuentra objeto con tag 'Player'"); } princesa = player_go.GetComponent <PrincesavueScript>(); score = 0; PlayerPrefs.GetInt("highScore", 0); //AQUI INICIO EL COMPARADOR CON EL MAXIMO PUNTAJE GUARDADO O 0 SI NO HAY UN XML (RECIEN INSTALADO) try { var lPath1 = ScoreList.getPath("scores.xml"); var scoreCollection = ScoreList.Load(lPath1); var lScore = scoreCollection.getScores(0); comparator = lScore.Points; //PARA TESTEAR DESCOMENTA LA SIGUIENTE LINEA //comparator = 10; }catch { comparator = 0; } }
public void FetchScoreboard() { XmlSerializer ser = new XmlSerializer(typeof(ScoreList)); WWW scoreRequest = new WWW("http://localhost:3000/api/v1/scores"); while (!scoreRequest.isDone) { HighScoreText.text = string.Format("{0}", scoreRequest.progress); } ScoreList s = new ScoreList(); using (TextReader r = new StringReader(scoreRequest.text)) { s = (ScoreList)ser.Deserialize(r); } HighScoreText.text = ""; int rank = 1; foreach (ScoreItem score in s.Items) { string rankStr = rank++ + ""; string scoreStr = score.score + ""; HighScoreText.text += string.Format("{0}\t\t{1}\t\t{2}\n", rankStr.PadLeft(4, ' '), score.username, scoreStr); } }
/// <summary> /// Luo uuden parhaiden pisteiden ikkunan. /// </summary> /// <param name="fileName">Tiedoston nimi</param> /// <param name="places">Pistesijojen lukumäärä</param> public EasyHighScore(string fileName, int places) { this.score = new ScoreList(places, false, 0); this.fileName = fileName; Game.AssertInitialized(LoadData); Game.AssertInitialized(InitHSWindow); }
// add new local score public void AddHighscore(int score, string name, string date) { // Create HighscoreEntry Score highscoreEntry = new Score { score = score, name = name, date = date }; // Load saved Highscores string jsonString = PlayerPrefs.GetString("highscoreTable"); ScoreList highscores = JsonUtility.FromJson <ScoreList>(jsonString); if (highscores == null) { // There's no stored table, initialize highscores = new ScoreList() { highscoreEntryList = new List <Score>() }; } // Add new entry to Highscores highscores.highscoreEntryList.Add(highscoreEntry); // Save updated Highscores string json = JsonUtility.ToJson(highscores); PlayerPrefs.SetString("highscoreTable", json); PlayerPrefs.Save(); }
/// <summary> /// Aliohjelma, joka käydään läpi ensimmäisenä pelin käynnistyessä. /// </summary> public override void Begin() { //Tallennetaan ikkunan leveys ja korkeus muuttujiin. IkkunanLeveys = Screen.WidthSafe; IkkunanKorkeus = Screen.HeightSafe; //Asetetaan alussa ikkunamuotoon. IsFullScreen = true; Window.AllowAltF4 = true; Window.Title = "tLoP"; Window.AllowUserResizing = false; Camera.StayInLevel = true; //Pikseligrafiikat SmoothTextures = false; adisplay = new MessageDisplay(); adisplay.TextColor = Color.White; adisplay.BackgroundColor = Color.Black; adisplay.MessageTime = TimeSpan.FromSeconds(5); Add(adisplay); //Luo ja hae top pisteet lista muistista topLista = new ScoreList(10, false, 0); topLista = DataStorage.TryLoad <ScoreList>(topLista, "pisteet.xml"); //Luo pelin menu LataaMenunTausta(); Alkuvalikko(); }
/// <summary> /// Luo uuden parhaiden pisteiden ikkunan. /// Tämä versio antaa pelaajan kirjoittaa nimensä listalle jos tulos /// on tarpeeksi hyvä. /// </summary> /// <param name="normalMessage">Normaalisti näytettävä viesti</param> /// <param name="nameMessage">Viesti joka näytetään kun pelaaja pääsee listalle</param> /// <param name="list">Lista</param> /// <param name="newScore">Viimeisimmän pelin pistemäärä</param> public HighScoreWindow(string normalMessage, string nameMessage, ScoreList list, double newScore) : base(normalMessage) { Initialize(list); NameInputWindow.Message.Text = nameMessage; ShowNameInput(newScore); }
private void Awake() { Instance = this; ScoreList = new ScoreList(); LoadScores(); }
private void SaveScoreJsonMsg(string ScoreJsonMsg) { scoreJsonMsg = "{\"scoreList\":" + ScoreJsonMsg + "}"; scoreMsg = JsonUtility.FromJson <ScoreList>(scoreJsonMsg); //foreach (var item in scoreMsg.scoreList) //{ // Debug.Log(item.account+item.score+item.time); //} }
public void ShowComplete(ScoreList scoreList) { scoreList.list = scoreList.list.OrderByDescending(x => int.Parse(x.player_score)).ToArray(); for (int i = 0; i < 5; i++) { listOfText[i].text = scoreList.list[i].player_name + " - " + scoreList.list[i].player_score; } loadingScreen.SetActive(false); }
//OK public void HandleSubmitScore(bool isError, string errorMessage, ScoreList scoreList) { if (!isError) { submitPanel.SetActive(false); showSubmitPanelButton.SetActive(false); } SetUpLeaderboard(isError, errorMessage, scoreList); }
void ShowScores() { ScoreList scores = JsonUtility.FromJson <ScoreList>(results); foreach (var score in scores.Score) { Debug.Log(score.name + " " + score.score); } }
public Playthrough[] GetScores(Song song) { if (scoreList.song != song) { scoreList = new ScoreList(song); } return(scoreList.GetScores()); }
private void OpenScores() { FileStream myStream; try { if (File.Exists("SavedScores.savedS") && (myStream = File.Open("SavedScores.savedS", FileMode.Open)) != null) { using (myStream) { BinaryFormatter bf = new BinaryFormatter(); scores = bf.Deserialize(myStream) as ScoreList; } } else if (!File.Exists("SavedScores.savedS")) { scores = new ScoreList(); } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } }
/// <summary> /// After a successfully ran game, opens score screen and starts the program over after closing it. /// </summary> public void GameEnd() { Pause(); ScoreList scoreList = new ScoreList(10, false, 2500); scoreList = DataStorage.TryLoad<ScoreList>(scoreList, "scorelist.xml"); HighScoreWindow scoreWindow = new HighScoreWindow("High Scores", "You have made the high scores! Please enter your name: ", scoreList, SCOREMETER.Value); scoreWindow.Closed += delegate { DataStorage.Save<ScoreList>(scoreList, "scorelist.xml"); Pause(); ClearAll(); Begin(); }; Add(scoreWindow); }