void Start() { loadManagerController = GameObject.Find("LoadManagerController").GetComponent<Load_Manager>(); level_Information = GameObject.Find("Level_Information").GetComponent<Level_Information>(); startGameScript = GameObject.Find("Main Camera").GetComponent<StartGame>(); highscoreTable = new HighscoreTable(); }
private void Awake() { instance = this; entryContainer = transform.Find("highscoreEntryContainer"); entryTemplate = entryContainer.Find("highscoreEntryTemplate"); string jsonString = PlayerPrefs.GetString("highscoreTableEndlessRunner"); Highscores highscores = JsonUtility.FromJson <Highscores>(jsonString); //highscores = null; // Reset Table if (highscores == null) { // There's no stored table, initialize Debug.Log("Initializing table with default values..."); PlayerPrefs.DeleteKey("highscoreTableEndlessRunner"); AddHighscoreEntry(23, "VIU"); AddHighscoreEntry(21, "ILF"); AddHighscoreEntry(20, "LAM"); AddHighscoreEntry(18, "AG2"); AddHighscoreEntry(14, "NE0"); AddHighscoreEntry(13, "OL2"); AddHighscoreEntry(12, "VT0"); AddHighscoreEntry(11, "AR!"); } entryTemplate.gameObject.SetActive(false); gameObject.SetActive(false); }
// Saves the Users high score public void saveHighScore() { string name = SceneController.saveName(); HighscoreTable.AddHighscoreEntry(roundedScore, name, "beach"); GameObject.FindGameObjectWithTag("HighScore").SetActive(false); }
private void Awake() { Instance = this; entryContainer = transform.Find("highscoreEntryContainer"); entryTemplate = entryContainer.Find("highscoreEntryTemplate"); entryTemplate.gameObject.SetActive(false); //PlayerPrefs.DeleteKey("highscoreTable"); string jsonString = PlayerPrefs.GetString("highscoreTable"); Highscores1 highscores1 = JsonUtility.FromJson <Highscores1>(jsonString); transform.Find("Reset").GetComponent <Button_UI>().ClickFunc = () => { highscores1 = null; PlayerPrefs.SetString("highscoreTable", ""); PlayerPrefs.Save(); // Reset Scores SceneManager.LoadScene(0); }; if (highscores1 == null) { // There's no stored table, initialize //Debug.Log("Initializing table with default values..."); AddHighscoreEntry1(30, "MINH"); AddHighscoreEntry1(40, "LINH"); // Reload jsonString = PlayerPrefs.GetString("highscoreTable"); highscores1 = JsonUtility.FromJson <Highscores1>(jsonString); } RefreshHighscoreTable1(); Hide(); }
private void _RefreshScores() { if (OptionsData.highScores.Count > 0) { firstRanked.transform.Find("TextScore").GetComponent <Text>().text = OptionsData.highScores[0].score + ""; firstRanked.transform.Find("TextName").GetComponent <Text>().text = OptionsData.highScores[0].name; firstPlace.SetActive(true); } if (OptionsData.highScores.Count > 1) { secondRanked.transform.Find("TextScore").GetComponent <Text>().text = OptionsData.highScores[1].score + ""; secondRanked.transform.Find("TextName").GetComponent <Text>().text = OptionsData.highScores[1].name; secondPlace.SetActive(true); } if (OptionsData.highScores.Count > 2) { thirdRanked.transform.Find("TextScore").GetComponent <Text>().text = OptionsData.highScores[2].score + ""; thirdRanked.transform.Find("TextName").GetComponent <Text>().text = OptionsData.highScores[2].name; thirdPlace.SetActive(true); } if (OptionsData.highScores.Count > 4) { CredButton.gameObject.SetActive(true); CredButton.enabled = true; CredButton.interactable = true; } HighscoreTable.Refresh(); }
private void addScore() { var ts = TimeSpan.FromSeconds(Time.time - startTime); string timeCompletion = string.Format("{0:00}:{1:00}", ts.TotalMinutes, ts.Seconds); HighscoreTable.AddHighscoreEntry( instance.pacman.GetComponent <PlayerController>().score, timeCompletion); }
/// <summary> /// Starts the coroutine to get all highscores. /// </summary> /// <param name="table_head">HighscoreTableHead object of table to fetch.</param> /// <param name="reverse_order">True to fetch in DESC order. Defaults to false.</param> /// <returns>HighscoreTable object.</returns> public HighscoreTable getHighscoreAll(HighscoreTableHead table_head, bool reverse_order = false) { var table = new HighscoreTable(table_head); getHighscoreAll(table, reverse_order); return(table); }
/// <summary> /// Starts the coroutine to get highscores around user. /// </summary> /// <param name="table_head">HighscoreTableHead object of table to fetch.</param> /// <param name="platform_user">True to fetch highscores only from user platform. Defaults to true.</param> /// <returns>HighscoreTable object.</returns> public HighscoreTable getHighscoreAroundUser(HighscoreTableHead table_head, bool platform_user = true) { var table = new HighscoreTable(table_head); getHighscoreAroundUser(table, platform_user); return(table); }
public void OnMouseUp() { int finalScore = LevelGenerator.GetlevelPartCount() + Coin.chupetes - 5; HighscoreNameInputWindow.Show(finalScore, (string name) => { HighscoreTable.AddHighscoreEntry_Static(finalScore, name); HighscoreTable.Show(); }); pre_score.SetActive(false); }
/// <summary> /// Coroutine which handles the Highscore Get Around User request. /// </summary> /// <param name="table"></param> /// <param name="platform_user"></param> /// <returns></returns> private IEnumerator doGetHighscoreAroundUser(HighscoreTable table, bool platform_user = true) { var request = m_request_manager.createHighscoreGetAroundUserRequest(table.pt_head.pt_table_id == null ? table.pt_head.pt_table_name : table.pt_head.pt_table_id.ToString(), table.pt_head.pt_table_rows_max_view, platform_user); yield return(request.send()); fillInTableFromResponse(table, request.pt_response as HighscoreGetResponse); table.p_done = true; }
/// <summary> /// Coroutine which handles the Highscore Get All request. /// </summary> /// <param name="table"></param> /// <param name="reverse_order"></param> /// <returns></returns> private IEnumerator doGetHighscoreAll(HighscoreTable table, bool reverse_order = false) { var request = m_request_manager.createHighscoreGetAllRequest(table.pt_head.pt_table_id == null ? table.pt_head.pt_table_name : table.pt_head.pt_table_id.ToString(), table.pt_head.pt_table_from_platform, table.pt_head.pt_table_rows_page_view, table.pt_head.pt_table_rows_max_view, reverse_order); yield return(request.send()); fillInTableFromResponse(table, request.pt_response as HighscoreGetResponse); table.p_done = true; }
public static void SaveTable(HighscoreTable table) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/Highscore.score"; FileStream stream = new FileStream(path, FileMode.Create); formatter.Serialize(stream, table); stream.Close(); }
public void LoadHighscores() { table = SaveSystemScript.LoadScore(); if (table == null) { table = new HighscoreTable(); SaveSystemScript.SaveTable(table); } UIManagerScript.instance.ShowHighscoreDeathscreen(table); }
private void Start() { highscoreTable = FindObjectOfType <HighscoreTable>(); isPlayerDead = false; loseScreen.SetActive(false); livesTxt.text = lives.ToString(); pause = true; StartCoroutine(StartGame()); }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } }
public void LoadHighscores() { if (table == null) { table = SaveSystemScript.LoadScore(); } if (table == null) { table = new HighscoreTable(); SaveSystemScript.SaveTable(table); } }
/// <summary> /// The class constructor. Loads a GameValues instance and the /// computer's high score table, creates a board and random number /// generator instance, and generates the first level. /// </summary> /// <param name="gameValues">The files that will manage every important /// thing to begin the level. Can be 'loaded' from a saved game or /// a new one.</param> public Game(GameValues gameValues) { // Loads the highscore table and current game values. this.gameValues = gameValues; highscoreTable = SaveManager.Load(); // Create board and rand instance board = new Board(gameValues.Width, gameValues.Height); rand = new Random(); GenerateLevel(); }
void Start() { isLegendary = false; for (int i = 0; i < highscoreText.Length; i++) { highscoreText[i].transform.GetChild(1).transform.GetComponent <Text>().text = "Fetching..."; highscoreText[i].transform.GetChild(2).transform.GetComponent <Text>().text = "..."; } highscoreManager = GetComponent <HighscoreTable>(); StartCoroutine("RefreshHighscores"); isLegendary = false; }
private HighscoreTable GetTestTable() { Highscore h1 = new Highscore(validUserId); Highscore h2 = new Highscore(validUserId); Highscore h3 = new Highscore(validUserId); h1.Score = 70; h2.Score = 16; h3.Score = 20; HighscoreTable table = new HighscoreTable(); table.Add(h1); table.Add(h2); table.Add(h3); return table; }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.tag == "Enemy") { HighscoreTable.AddNewHighscore(Menu.PLAYERNAME, transform.GetComponent <ContadorPunts>().punts); //Poner animación de fade para el panel final. endPanel.SetActive(true); anim.SetBool("isJumping", false); FindObjectOfType <AudioManagerScript>().PlaySound("Ouch"); gameObject.transform.GetChild(1).gameObject.SetActive(false); gameObject.GetComponent <Rigidbody2D>().AddForce(new Vector3(0f, 30f), ForceMode2D.Impulse); anim.SetBool("Death", true); inGame = false; } }
public void endGame() { if (GetComponent <MineField>().isWin()) { state = GameState.END_WIN; Debug.Log("WIN"); HUD temp = GameManager.instance.GetComponent <HUD>(); HighscoreTable.AddHighscoreEntry((int)temp.elapsed, PlayerPrefs.GetString("name"), PlayerPrefs.GetInt("width") + "x" + PlayerPrefs.GetInt("height") + "_" + PlayerPrefs.GetInt("mines")); } else { Debug.Log("LOSE"); state = GameState.END_LOSE; } }
public void ShowHighscoreDeathscreen(HighscoreTable table) { topNameText.placeholder.GetComponent <TextMeshProUGUI>().text = table.standartName; string a = "Name\n"; string b = "Points\n"; string c = "Date\n"; string d = "\n"; int i = 1; if (table != null) { foreach (PlayerData item in table.datas) { a += item.name + "\n"; b += item.highscore + "\n"; c += item.date.ToShortDateString() + "\n"; d += i++ + ")\n"; if (i == 11) { if (table.lastPlayer?.highscore < item.highscore) { a += "...\n"; b += "...\n"; c += "...\n"; d += "...\n"; a += table.lastPlayer.name + "\n"; b += table.lastPlayer.highscore + "\n"; c += table.lastPlayer.date.ToShortDateString() + "\n"; d += (table.datas.IndexOf(table.lastPlayer) + 1) + ")\n"; } break; } } } highscoreNameText.text = a; highscorePointsText.text = b; highscoreDateText.text = c; highscoreNaumberText.text = d; }
public static HighscoreTable LoadScore() { string path = Application.persistentDataPath + "/Highscore.score"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); HighscoreTable data = formatter.Deserialize(stream) as HighscoreTable; stream.Close(); return(data); } else { Debug.LogError("noFile"); return(new HighscoreTable()); } }
/// <summary> /// Saves the data of the Highscore Table in a file /// </summary> /// <param name="highscore">Highscore table to be saved</param> public static void Save(HighscoreTable highscore) { // Open file in writeable mode StreamWriter sw = new StreamWriter("scores.txt"); // Checks every possible spot of the table. for (int i = 0; i < 10; i++) { // Gets the score correspondent to the spot. Score score = highscore.GetScore(i); // If theres a score in the specific spot, print it. if (score != null) { sw.WriteLine(score.Name + " " + score.NewScore); } } // Close file sw.Close(); }
/// <summary> /// Load the data of an Highscore Table form a file /// </summary> /// <returns> Properly filled Highscore Table </returns> public static HighscoreTable Load() { // Instatiate a new highscore table reference HighscoreTable highscore = new HighscoreTable(); string scoreData = ""; StreamWriter sw = new StreamWriter("scores.txt"); sw.Close(); // Open file in readeable mode StreamReader sr = new StreamReader("scores.txt"); // Cycle through every line inside the file while ((scoreData = sr.ReadLine()) != null) { // Split the data in two strings: Name and Score. string[] splitData = scoreData.Split(); int score; // Parse the score data into an int if (!int.TryParse(splitData[1], out score)) { UI.WriteMessage("Error."); Environment.Exit(0); } // Adds score to new HighscoreTable highscore.AddScore(splitData[0], score); } // Close the file. sr.Close(); // Returns the Highscore table. return(highscore); }
// on hero's death void OnDestroy() { // Display the menu Canvas.FindObjectOfType <PauseMenu>().pauseMenuUI.SetActive(true); Button[] buttons = PauseMenu.FindObjectsOfType <Button>(); // Display GAMEOVER Canvas.FindObjectOfType <PauseMenu>().gameover.SetActive(true); // turning off "Resume button" in the menu after death of the hero buttons[1].interactable = false; // Put score on score board int score = ManageScore.GetScore(); string playerName = PlayerPrefs.GetString("playerName"); if (playerName == null) { playerName = "PLAYER"; } HighscoreTable.AddHighscoreEntry(score, playerName); }
void UpdateLeaderboard() { Leaderboard.SetActive(true); if (highscoreTable == null) { highscoreTable = FindObjectOfType <HighscoreTable>(); } int pos = highscoreTable.CheckNewEntry(Score.score); Debug.Log(pos); if (pos != -1) { highscoreTable.AddNewEntry(pos, new HighscoreTable.HighscoreEntry(pos, Score.score, PlayerPrefs.GetString("init", "NUL"))); } highscoreTable.UpdateLeaderBoard(); highscoreTable.SaveBoard(); hasUpdatedLeaderboard = true; }
void OnPlayerDied() { gameOver = true; PlayerPrefs.SetString("score", score.ToString()); int highScore = PlayerPrefs.GetInt("HighScore"); if (score > highScore) { PlayerPrefs.SetInt("HighScore", score); } string username = PlayerPrefs.GetString("username"); string phone = PlayerPrefs.GetString("phone"); HighscoreTable.AddHighscoreEntry(score, username, phone); SetPageState(PageState.GameOver); // WRITE TO TEXT FILE using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"./highscore.txt", true)) { file.WriteLine("username:{0};phone:{1};score:{2}", PlayerPrefs.GetString("username"), PlayerPrefs.GetString("phone"), PlayerPrefs.GetString("score")); } }
/// <summary> /// Fills the table head and rows from Highscore Get request. /// </summary> /// <param name="table"></param> /// <param name="response"></param> private void fillInTableFromResponse(HighscoreTable table, HighscoreGetResponse response) { if (response != null && response.results != null && response.results.success && response.results.head != null) { table.pt_head.setTableRowsCurrentView(response.results.head.rows_count); if (response.results.head.table != null) { table.pt_head.setTableRowsSum(response.results.head.table.rows_count); } table.p_rows.Clear(); if (response.results.rows != null) { foreach (var row in response.results.rows) { User user = new User(row.user.id, row.user.nickname); user.setEid(row.user.eid); HighscoreTableRow tableRow = new HighscoreTableRow(user, getHighscoreTableRowPlatform(row.platform.id, row.platform.name), row.rank, row.score, DateTime.Parse(row.scored_at)); table.p_rows.Add(tableRow); } } } }
[SerializeField] int scorePerHitAfekaCircle = 40; //Score for hitting white circle // Start is called before the first frame update void Awake() { gameOver = false; song = PlayerPrefs.GetString("song"); music.clip = Resources.Load <AudioClip>("Music/GameSongs/" + song); music.Play(); difficulty = PlayerPrefs.GetFloat("level", 1); musicLength = PlayerPrefs.GetInt("songLength", 1); highScoreTable = FindObjectOfType <HighscoreTable>(); lowestScore = PlayerPrefs.GetInt("lowestScore", 0); topScore = PlayerPrefs.GetInt("topScore", 0); liveBoard = FindObjectOfType <LiveBoard>(); laserPointer.SetActive(false); sideLights = GameObject.Find("Sides").GetComponent <Component>(); comboUpdateSign = GameObject.Find("ComboUpdateSign").GetComponent <Component>(); goodLuckLabel = GameObject.Find("GoodLuckLabel").GetComponent <Component>(); RaiseLevelLabel = GameObject.Find("RaiseLevel").GetComponent <Component>(); DecreaseLevelLabel = GameObject.Find("DecreaseLevel").GetComponent <Component>(); TopScoreLabel = GameObject.Find("TopScore").GetComponent <Component>(); NewHighScoreLabel = GameObject.Find("NewHighScore").GetComponent <Component>(); boostTimer = GameObject.Find("boostTimer").GetComponent <Component>(); StartCoroutine(CheckNewHighScore()); SwitchSlicer(true); }
/// <summary> /// Starts the coroutine to get highscores around user. /// </summary> /// <param name="table">HighscoreTable object of the table to fetch.</param> /// <param name="platform_user">True to fetch highscores only from user platform. Defaults to true.</param> public void getHighscoreAroundUser(HighscoreTable table, bool platform_user = true) { table.p_done = false; StartCoroutine(doGetHighscoreAroundUser(table, platform_user)); }