Exemplo n.º 1
0
 public void Update()
 {
     if (high)
     {
         if (drawed && !asked)
         {
             Renderer.StopDrawing = true;
             while (!Renderer.DrawEnded)
             {
                 ;
             }
             Console.ForegroundColor = ConsoleColor.White;
             Console.BackgroundColor = ConsoleColor.Blue;
             Console.CursorTop       = 13;
             Console.CursorLeft      = 15;
             name = Console.ReadLine();
             Renderer.StopDrawing = false;
             asked = true;
             place = scores.PutScore(score, name);
             Highscores.Save(scores);
         }
     }
     if (high && asked)
     {
         if (ConsoleKeyboard.KeyAvailable)
         {
             if (ConsoleKeyboard.PressedKey == ConsoleKey.Escape)
             {
                 Program.game.Place = place;
                 Program.game.SwitchScene(3);
             }
         }
     }
 }
Exemplo n.º 2
0
        public ActionResult addHighscore(Highscores ScoreName)
        {
            if (!ModelState.IsValid)
            { return RedirectToAction("Index"); }
            int score = 0;
            if (Session["game"] != null)
            {
                Game game = (Game)Session["game"];

                for (int i = 0; i < 16; i++)
                {
                    if (game.Gamefield.Field[i].Value != "")
                    {
                        score = (score + int.Parse(game.Gamefield.Field[i].Value));
                    }
                }

                Highscores highscore = new Highscores();
                highscore.Name = ScoreName.Name;
                highscore.Score = score.ToString();

                db.Highscores.Add(highscore);
                db.SaveChanges();
            }
            return RedirectToAction("newGame");
        }
Exemplo n.º 3
0
    private void SaveHighscores(Highscores highscores)
    {
        string json = JsonUtility.ToJson(highscores);

        PlayerPrefs.SetString(HIGHSCORE_PLAYERPREFS_KEY, json);
        PlayerPrefs.Save();
    }
Exemplo n.º 4
0
    public void AddHighscoreEntry(int i_Score)
    {
        //create highscore entry
        HighScoreEntry highscoreEntry = new HighScoreEntry(i_Score);
        // load saved highscores
        string     jsonString = PlayerPrefs.GetString("highscoreTable");
        Highscores highscores = JsonUtility.FromJson <Highscores>(jsonString);

        // add new highscore
        if (highscores == null)
        {
            // There's no stored table, initialize
            highscores = new Highscores()
            {
                highscoreEntryList = new List <HighScoreEntry>()
            };
        }

        highscores.highscoreEntryList.Add(highscoreEntry);
        //save updated score
        string json = JsonUtility.ToJson(highscores);

        PlayerPrefs.SetString("highscoreTable", json);
        PlayerPrefs.Save();
    }
Exemplo n.º 5
0
    void CreateHighscoreEntries(List <HighscoreEntry> entries)
    {
        float templateHeight = 25f;

        for (int i = 0; i < (entries.Count < 10 ? entries.Count : 10); i++)
        {
            Transform     entryTransform     = Instantiate(entryTemplate, entryContainer);
            RectTransform entryRectTransform = entryTransform.GetComponent <RectTransform>();
            entryRectTransform.anchoredPosition = new Vector2(0, -templateHeight * i);
            entryTransform.gameObject.SetActive(true);

            int rank = i + 1;
            entryTransform.Find("Position").GetComponent <TextMeshProUGUI>().text = rank.ToString();
            entryTransform.Find("Time").GetComponent <TextMeshProUGUI>().text     = FormatTime(entries[i].time);
            entryTransform.Find("Name").GetComponent <TextMeshProUGUI>().text     = entries[i].name;
        }

        Highscores hs = new Highscores {
            entries = entries
        };
        string json = JsonUtility.ToJson(hs);

        PlayerPrefs.SetString("localLeaderboard", json);
        Debug.Log(json);
        PlayerPrefs.Save();
    }
Exemplo n.º 6
0
    private void AddHighscoreEntry(int score, string name)
    {
        // Create HighscoreEntry
        HighscoreEntry highscoreEntry = new HighscoreEntry {
            score = score, name = name
        };

        // Load saved Highscores
        string     jsonString = PlayerPrefs.GetString("highscoreTable");
        Highscores highscores = JsonUtility.FromJson <Highscores>(jsonString);


        if (highscores == null)
        {
            // There's no stored table, initialize
            highscores = new Highscores()
            {
                highscoreEntryList = new List <HighscoreEntry>()
            };
        }

        // Add new entry to Highscores
        highscores.highscoreEntryList.Add(highscoreEntry);

        // Save updated Highscores
        string json = JsonUtility.ToJson(highscores);

        PlayerPrefs.SetString("highscoreTable", json);
        PlayerPrefs.Save();
    }
Exemplo n.º 7
0
    public void OnNameGiven(string playerName)
    {
        int playerScore = SceneController.instance.GetPlayerScore();

        AddHighscoreEntry(playerScore, playerName);

        string     jsonString = PlayerPrefs.GetString("highscoreTable");
        Highscores highscores = JsonUtility.FromJson <Highscores>(jsonString);   // "Decode" from JSON to Object

        // Sort entry list by Score
        for (int i = 0; i < highscores.highscoreEntryList.Count; i++)
        {
            for (int j = i + 1; j < highscores.highscoreEntryList.Count; j++)
            {
                if (highscores.highscoreEntryList[j].score > highscores.highscoreEntryList[i].score)
                {
                    // Swap
                    HighscoreEntry tmp = highscores.highscoreEntryList[i];
                    highscores.highscoreEntryList[i] = highscores.highscoreEntryList[j];
                    highscores.highscoreEntryList[j] = tmp;
                }
            }
        }

        int size = highscores.highscoreEntryList.Count < 12 ? highscores.highscoreEntryList.Count : 12;

        highscoreEntryTransformList = new List <Transform>();
        for (int i = 0; i < size; i++)
        {
            CreateHighscoreEntryTransform(highscores.highscoreEntryList[i], entryContainer, highscoreEntryTransformList);
        }

        textInputCanvas.enabled = false; // not working
    }
Exemplo n.º 8
0
	/*
	void Update () {
		if (Input.GetKeyDown (KeyCode.Tab)) {
			Save ();
		}
	}
	*/


	public void Load(){
		shopItemsOwned = new bool[50];
		shopItemsEquipped = new bool[50];
		achievementsGotten = new bool[50];

		for (int i = 0; i < shopItemsOwned.Length; i++) {
			string strOwned = "shopItem" + i;
			string strEquipped = "shopItemEquipped" + i;
			shopItemsOwned [i] = intToBool(PlayerPrefs.GetInt (strOwned));
			shopItemsEquipped[i] = intToBool(PlayerPrefs.GetInt (strEquipped));
		}

		for (int i = 0; i < achievementsGotten.Length; i++) {
			string strAch = "achievement" + i;
			achievementsGotten [i] = intToBool(PlayerPrefs.GetInt(strAch));
		}

		this.coins = PlayerPrefs.GetInt ("coins");
		this.maxAchievedDungeonLevel = PlayerPrefs.GetInt ("dungeonLevel");
		if (maxAchievedDungeonLevel == 0)
			maxAchievedDungeonLevel = 1;
		this.highQuality = intToBool(PlayerPrefs.GetInt ("highQuality"));
        highscores = new Highscores();
        string jsonDataString = Serializer.Load<string>("highScores.txt");
        highscores = JsonUtility.FromJson<Highscores>(jsonDataString);
        max_score = getMaxScore();

        if (PlayerPrefs.HasKey("id"))
        {
            server_communication();
        }
		Debug.Log ("Loaded data succesfully");
	}
    private void Awake()
    {
        entryContainer = transform.Find("HighScoreEntryContainer");
        entryTemplate  = entryContainer.Find("HighScoreEntryTemplate");

        entryTemplate.gameObject.SetActive(false);

        string     jsonString = PlayerPrefs.GetString("highscoreTable");
        Highscores highscores = JsonUtility.FromJson <Highscores>(jsonString);

        // Sort entry list by Score
        for (int i = 0; i < highscores.highscoreEntryList.Count; i++)
        {
            for (int j = i + 1; j < highscores.highscoreEntryList.Count; j++)
            {
                if (highscores.highscoreEntryList[j].score > highscores.highscoreEntryList[i].score)
                {
                    // Swap
                    HighscoreEntry tmp = highscores.highscoreEntryList[i];
                    highscores.highscoreEntryList[i] = highscores.highscoreEntryList[j];
                    highscores.highscoreEntryList[j] = tmp;
                }
            }
        }


        highscoreEntryTransformList = new List <Transform>();
        foreach (HighscoreEntry highscoreEntry in highscores.highscoreEntryList)
        {
            CreateHighscoreEntryTransform(highscoreEntry, entryContainer, highscoreEntryTransformList);
        }
    }
Exemplo n.º 10
0
 public void OK()
 {
     panel.gameObject.SetActive(false);
     endUsername.text = username;
     endUsername.gameObject.SetActive(true);
     Highscores.AddNewHighscore(username, score);
 }
Exemplo n.º 11
0
        private void setBommenLabel()
        {
            if (gameover)
            {
                AantalBommen.Text      = "Game Over! Start een nieuwe match!";
                AantalBommen.BackColor = Color.Red;
                MessageBox.Show("Game Over, start een nieuwe match", "Game Over", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                timer1.Stop();
            }
            else if (won)
            {
                timer1.Stop();

                AantalBommen.Text      = "Je hebt gewonnen";
                AantalBommen.BackColor = Color.Green;
                MessageBox.Show("Je hebt gewonnen start een nieuwe match om verder te kunnen spelen", "Won", MessageBoxButtons.OK, MessageBoxIcon.None);
                updateHighscores = new UpdateHighscores(sbombs, x * y, timer);
                highscores       = new Highscores();
            }
            else
            {
                AantalBommen.Text      = "Aantal bommen: " + (bombs - flaggs);
                AantalBommen.BackColor = Color.White;
            }
        }
Exemplo n.º 12
0
 void Awake()
 {
     highscoreDisplay = GetComponent <displayHighscores> ();
     instance         = this;
     highscore        = PlayerPrefs.GetInt("Highscore", highscore);
     AddNewHighscore(usernameReal, highscore);
 }
Exemplo n.º 13
0
    private void Start()
    {
        _instance = this;
        entryTemplate.gameObject.SetActive(false);

        string     jsonString = PlayerPrefs.GetString("highscoreTable");
        Highscores highscores = JsonUtility.FromJson <Highscores>(jsonString);

        for (int i = 0; i < highscores.highscoreEntryList.Count; i++)
        {
            for (int j = i + 1; j < highscores.highscoreEntryList.Count; j++)
            {
                if (highscores.highscoreEntryList[j].score < highscores.highscoreEntryList[i].score)
                {
                    HighscoreEntry tmp = highscores.highscoreEntryList[i];
                    highscores.highscoreEntryList[i] = highscores.highscoreEntryList[j];
                    highscores.highscoreEntryList[j] = tmp;
                }
            }
        }

        highscoreEntryTransformList = new List <Transform>();
        foreach (HighscoreEntry highscoreEntry in highscores.highscoreEntryList)
        {
            CreateHighscoreEntryTransform(highscoreEntry, entryContainer, highscoreEntryTransformList);
        }
    }
Exemplo n.º 14
0
    public void Populate()
    {
        // First we drop all records that have been here before. This will happen
        // if the user will go back and forth on both menu screen.
        foreach (Ladderboardrecord record in records)
        {
            Destroy(record.gameObject);
        }
        records.Clear();

        // Now fetch the highscore table and put the results on the screen:
        Highscores hs = HighscoreManager.Instance.Highscores;

        recordProto.gameObject.SetActive(true);
        for (int i = 0; i < hs.records.Count; ++i)
        {
            Ladderboardrecord newRecord =
                Instantiate(recordProto.gameObject, scrollAreaTransform.transform)
                .GetComponent <Ladderboardrecord>();

            records.Add(newRecord);
            newRecord.SetContent(i, hs.records[i].secondsSurvived, hs.records[i].playerName);
        }
        recordProto.gameObject.SetActive(false);
    }
Exemplo n.º 15
0
    public void DoUpdateHighscoreTable()
    {
        //destroy old highscore table if it exists
        foreach (var transform in transformsList)
        {
            Destroy(transform.gameObject);
        }
        //remove template (shouldn't show it)
        template.gameObject.SetActive(false);
        //grab the table from PlayerPrefs
        var jsonString = PlayerPrefs.GetString("highscoreTable");
        //decompose json into object
        var highscores = JsonUtility.FromJson <Highscores>(jsonString);

        //this should only happen when the playerprefs fetch failed, but make a new object if it did
        if (highscores == null)
        {
            highscores = new Highscores();
        }
        //sort highscores table in descending order
        highscores.highscoreEntries = highscores.highscoreEntries.OrderByDescending(i => i.score).ToList();
        //display the minimum of either the count of highscores entries or 10
        for (int i = 0; i < Mathf.Min(highscores.highscoreEntries.Count, 10); ++i)
        {
            CreateHighscoreEntryTransform(highscores.highscoreEntries[i], container, transformsList);
        }
    }
Exemplo n.º 16
0
    //Do adding new entry to highscore list
    public void AddHighscoreEntry(int score)
    {
        HighscoreEntry highscoreEntry = new HighscoreEntry(score);
        //fetch json from playerprefs
        string jsonString = PlayerPrefs.GetString("highscoreTable");
        //decompose json into object
        Highscores highscores = JsonUtility.FromJson <Highscores>(jsonString);

        //if fetch failed, make a new object
        if (highscores == null)
        {
            highscores = new Highscores();
        }
        //add entry and then sort the list based on scores
        highscores.highscoreEntries.Add(highscoreEntry);
        highscores.highscoreEntries = highscores.highscoreEntries.OrderByDescending(i => i.score).ToList();
        //prune highscore list to only show top 10
        while (highscores.highscoreEntries.Count > 10)
        {
            highscores.highscoreEntries.RemoveAt(highscores.highscoreEntries.Count - 1);
        }
        //save new highscore table to playerprefs
        string json = JsonUtility.ToJson(highscores);

        PlayerPrefs.SetString("highscoreTable", json);
        PlayerPrefs.Save();
    }
Exemplo n.º 17
0
    // Start is called before the first frame update
    private void Awake()
    {
        //PlayerPrefs.DeleteKey("highscoreTable");


        entryContainer = transform.Find("HighScoreEntryContainer");
        entryTemplate  = entryContainer.Find("HighScoreEntryTemplate");

        entryTemplate.gameObject.SetActive(false);

        //AddHighscoreEntry(10000, "CMK");
        // Supostamente para tirar
        //highscoreEntryList = new List<HighScoreEntry>()
        //{
        //    new HighScoreEntry{score = 5212312, name = "TO"},
        //    new HighScoreEntry{score = 31233, name = "DU"}
        //};



        // Para carregar do json

        string     jsonString = PlayerPrefs.GetString("highscoreTable");
        Highscores highscores = JsonUtility.FromJson <Highscores>(jsonString);

        if (highscores == null)
        {
            Debug.Log("Initializing table with default values...");
            AddHighscoreEntry(1000000, "CMK");
            AddHighscoreEntry(897621, "JOE");
            AddHighscoreEntry(872931, "DAV");
            AddHighscoreEntry(785123, "CAT");
            AddHighscoreEntry(542024, "MAX");
            AddHighscoreEntry(68245, "AAA");
        }
        // Dar sort aqui!

        // Codigo do sort
        Debug.Log(PlayerPrefs.GetInt("Lastscore"));

        highscoreEntryTransformList = new List <Transform>();
        AddHighscoreEntry(PlayerPrefs.GetInt("Lastscore"), "teste");
        SortScores(highscores);
        Debug.Log(highscores.highscoreEntryList.Count);
        foreach (HighScoreEntry highscoreEntry in highscores.highscoreEntryList)
        {
            if (highscores.highscoreEntryList.Count == 5) // Para só ter 5 entradas
            {
                break;
            }
            CreatedHighscoreEntryTransform(highscoreEntry, entryContainer, highscoreEntryTransformList);
        }

        //// Para guardar o ranking
        //Highscores highscores = new Highscores { highscoreEntryList = highscoreEntryList };
        //string json = JsonUtility.ToJson(highscores);
        //PlayerPrefs.SetString("highscoreTable", json);
        //PlayerPrefs.Save();
        ////Debug.Log(PlayerPrefs.GetString("highscoreTable"));
    }
Exemplo n.º 18
0
    public void SubmitEntry()
    {
        if (playerInput.text == "")
        {
            return;
        }
        HighscoreEntry entry = new HighscoreEntry {
            highScore = PointHandeler.GetScore(), name = playerInput.text
        };

        CalculateNewHighscore(entry);
        for (int i = 0; i < entries.Count; i++)
        {
            HighscoreEntry currentEntry = new HighscoreEntry {
                highScore = int.Parse(entries[i].Find("ScoreTab").GetComponent <Text>().text),
                name      = entries[i].Find("NameTab").GetComponent <Text>().text
            };
            highscoreEntryList.Add(currentEntry);
        }
        Highscores highscores = new Highscores {
            highscoreEntryList = highscoreEntryList
        };
        string json = JsonUtility.ToJson(highscores);

        PlayerPrefs.SetString("highscoreTable", json);
        PlayerPrefs.Save();
        inputWindow.SetActive(false);
    }
Exemplo n.º 19
0
        private void SaveHighscore()
        {
            string currentDirectory = Directory.GetCurrentDirectory();
            string filePath = Path.Combine(currentDirectory, _highscoreFileName);

            Highscores.Sort();
            using (StreamWriter writer = new StreamWriter(filePath))
            {
                try
                {
                    foreach (var highscore in Highscores)
                    {
                        writer.WriteLine(EncryptString.Encrypt(highscore.Score + "§" + highscore.Name, _passString.ToString()));
                    }
                }
                catch (System.Exception)
                {
                    Console.WriteLine("Error writing to File!");
                }
                finally
                {
                    writer.Close();
                }
            }
        }
Exemplo n.º 20
0
 void Start()
 {
     float h = Screen.height / 4;
     rect = new Rect (Screen.width/2-h, Screen.height/2-h, h*2, h*2);
     movement = GetComponent<Movement>();
     highscores = GetComponent<Highscores>();
 }
Exemplo n.º 21
0
        private void Awake()
        {
            Assert.IsNull(instance);
            instance = this;

            retry.onClick.AddListener(() => { LevelContext.Level.Own.Retry(); });
            menu.onClick.AddListener(() => { LevelContext.Level.Own.ToMenu(); });
            onScoreAdded.AddListener(ShowHighscores);

            key = "highscoreTable" + SceneManager.GetActiveScene().buildIndex;

            if (!PlayerPrefs.HasKey(key))
            {
                highscores = new Highscores {
                    highscoreEntryList = new List <HighscoreEntry>()
                };

                string json = JsonUtility.ToJson(highscores);
                PlayerPrefs.SetString(key, json);
                PlayerPrefs.Save();
            }
            // PlayerPrefs.DeleteKey("highscoreTable");
            // PlayerPrefs.DeleteAll();

            // load saved Highscores
            string jsonString = PlayerPrefs.GetString(key);

            highscores = JsonUtility.FromJson <Highscores>(jsonString);
        }
    public void AddHighscoreEntry(float score, string name)
    {
        HighscoreEntry highscoreEntry = new HighscoreEntry {
            score = score, name = name
        };

        //Load saved Highscores
        string     jsonString = PlayerPrefs.GetString("highscoreTable");
        Highscores highscores = JsonUtility.FromJson <Highscores>(jsonString);

        if (highscores == null)
        {
            highscores = new Highscores();
            highscores.highscoreEntryList = new List <HighscoreEntry>();
        }

        //Add new entry to Highscores
        highscores.highscoreEntryList.Add(highscoreEntry);

        //Save updates Highscores
        string json = JsonUtility.ToJson(highscores);

        PlayerPrefs.SetString("highscoreTable", json);
        PlayerPrefs.Save();
    }
        /// <summary>
        /// Reset all player entries for restarting a game.
        /// In derived classes reset all the variables we need to reset for
        /// a new game there (e.g. car speed in CarController or
        /// cameraWobbel in ChaseCamera).
        /// </summary>
        public virtual void Reset()
        {
            //*** Initialize the high scores

            Highscores.Initialize();

            levelNum   = TrackSelection.SelectedTrackNumber;
            isGameOver = false;
            alreadyUploadedHighscore    = false;
            currentGameTimeMilliseconds = 0;
            bestLapTimeMilliseconds     = 0;
            lap        = 0;
            victory    = false;
            zoomInTime = StartGameZoomTimeMilliseconds;
            firstFrame = true;

            m_LapId = Guid.NewGuid().ToString();

            CurrentLapData = new LapData()
            {
                PlayerName    = GameSettings.Default.PlayerName,
                CarType       = RacingGameManager.currentCarNumber,
                LapId         = m_LapId,
                GameStartTime = DateTime.UtcNow,
                Level         = levelNum
            };
        }
Exemplo n.º 24
0
    private void Awake()
    {
        entryContainer = transform.Find("HighscoreEntryContainer");
        entryTemplate  = entryContainer.Find("HighscoreEntryTemplate");

        entryTemplate.gameObject.SetActive(false);

        scoreS = PlayerPrefs.GetInt("Score");
        if (PlayerPrefs.HasKey("HighscoreTable"))
        {
            string     jsonString = PlayerPrefs.GetString("HighscoreTable");
            Highscores highscores = JsonUtility.FromJson <Highscores>(jsonString);

            highscoreEntryTransformList = new List <Transform>();
            foreach (HighScoreEntry highScoreEntry in highscores.highscoreEntryList)
            {
                CreatingHighscoreEntryTransform(highScoreEntry, entryContainer, highscoreEntryTransformList);
            }
        }
        else
        {
            HighScoreEntry defaultHighscoreEntry = new HighScoreEntry {
                score = 100, name = "AAA"
            };
            string defaultJson = JsonUtility.ToJson(defaultHighscoreEntry);
            PlayerPrefs.SetString("HighscoreTable", defaultJson);
            PlayerPrefs.Save();
        }
    }
    private void SaveHighscores(Highscores highscores)
    {
        string jason = JsonUtility.ToJson(highscores);

        PlayerPrefs.SetString("Highscores", jason);
        PlayerPrefs.Save();
    }
Exemplo n.º 26
0
    void Update()
    {
        if (restart)
        {
            if ((Input.touchCount > 0) || Input.GetButton("Fire1") || Input.GetMouseButtonDown(0))
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            }
        }
        if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButton("Cancel"))
        {
            if (score > 0)
            {
                PlayerPrefs.SetInt("normalScore", score);
                Highscores.AddNewHighscore(username, score);
            }

            /* if (PlayerPrefs.HasKey("normalHighscore"))
             * {
             *   if (PlayerPrefs.GetInt("normalHigscore") < PlayerPrefs.GetInt("normalScore"))
             *       PlayerPrefs.SetInt("normalHighscore", PlayerPrefs.GetInt("normalScore"));
             * }
             * else
             *   PlayerPrefs.SetInt("normalHighscore", score);*/
        }
    }
Exemplo n.º 27
0
    void ChangeScore(string _username, int _score)
    {
        int    score    = _score;
        string username = _username;

        Highscores.AddNewHighscore(username, score);
    }
Exemplo n.º 28
0
        /// <summary>
        /// Start new lap, checks if the newReplay is good and
        /// can be stored as best replay :)
        /// </summary>
        public void StartNewLap()
        {
            float thisLapTime =
                RacingGameManager.Player.GameTimeMilliseconds / 1000.0f;

            // Upload new highscore (as we currently are in game,
            // no bonus or anything will be added, this score is low!)
            Highscores.SubmitHighscore((int)level,
                                       (int)RacingGameManager.Player.GameTimeMilliseconds);

            RacingGameManager.Player.AddLapTime(thisLapTime);

            if (thisLapTime < bestReplay.LapTime)
            {
                // Add final checkpoint
                RacingGameManager.Landscape.NewReplay.CheckpointTimes.Add(
                    thisLapTime);

                // Record lap time
                newReplay.LapTime = thisLapTime;

                // Save this replay to load it everytime in the future
                // Do this on a worker thread to prevent the game from skipping frames
                ThreadPool.QueueUserWorkItem(new WaitCallback(SaveReplay),
                                             (Replay)newReplay.Clone());

                // Set it as the current best replay
                bestReplay = newReplay;
            }

            // And start a new replay for this round
            newReplay = new Replay((int)level, true, track);
        }
Exemplo n.º 29
0
    void ToVersus()
    {
        if (ArcadeManager.am.win < 7)
        {
            SceneManager.LoadScene(6);
        }
        else if (ArcadeManager.am.win == 7)
        {
            SceneManager.LoadScene(17);
        }
        else
        {
            string     jsonString = File.ReadAllText(Application.dataPath + "/highscore.json");
            Highscores highscores = JsonUtility.FromJson <Highscores>(jsonString);

            if (highscores.highscoreEntryList[9].score < ArcadeManager.am.score)
            {
                SceneManager.LoadScene(19);
            }
            else
            {
                SceneManager.LoadScene(20);
            }
        }
    }
    private void Awake()
    {
        entryContainer = transform.Find("HightscoreEntryContainer");
        entryTemplate  = entryContainer.Find("HighscoreEntryTemplate");

        entryTemplate.gameObject.SetActive(false);

        string jsonString = PlayerPrefs.GetString("highscoreTable");

        var highscores = JsonUtility.FromJson <Highscores>(jsonString);

        if (highscores == null)
        {
            highscores = new Highscores();
            highscores.highscoreEntryList = new List <HighscoreEntry>();
        }

        highscoreEntryList = highscores.highscoreEntryList;
        highscoreEntryList.Sort();

        highscoreEntryTransformList = new List <Transform>();
        var max = 0;

        foreach (var highscoreEntry in highscoreEntryList)
        {
            CreateHighscoreEntryTransform(highscoreEntry, entryContainer, highscoreEntryTransformList);
            max++;
            if (max == 10)
            {
                break;
            }
        }
    }
    public void Login()
    {
        if (Highscores.GetUsernameHash(usernameLoginField.text) == float.Parse(passwordLoginField.text))
        {
            highscores.ContainsUsername(usernameLoginField.text, (bool contains) => {
                if (contains)
                {
                    SetUsername(usernameLoginField.text);
                    Debug.Log("Loged in as " + username + " with the password " + passwordField.text);

                    ClearError();
                    mainErrorText.color = loginErrorText.color = Color.green;
                    mainErrorText.text  = loginErrorText.text = "Logged in successfully";

                    loginPanel.SetActive(false);
                }
                else
                {
                    Debug.Log("Username not recognised");
                    loginErrorText.text = "Username or password incorrect";
                }
            });
        }
        else
        {
            Debug.Log("Password incorrect");
            loginErrorText.text = "Username or password incorrect";
        }
    }
Exemplo n.º 32
0
    public void SetHighscore(int score) //Sets Client and Server Score
    {
        if (score == CountJumpObjects())
        {
            Highscores.AddNewHighscore(CountJumpObjects());
        }
        else
        {
            adManager.showEveryN = 0;   //Thank the hacker for ma Ads!
            PlayerPrefs.SetInt("HasHacked", 1);
        }
        SetLocalHighscore(score);


        if (adManager)
        {
            adManager.DelayAd();
            CheckColor();
        }

        if (hintManager)
        {
            hintManager.RewardPlayer();
            hintManager.ToggleHints(true);
        }
        if (analyticsManager)
        {
            analyticsManager.OnHighscoreReached(score);
        }
    }
Exemplo n.º 33
0
    void Start()
    {
        for(int i = 0; i < highscoreFields.Length; i++)
        {
            highscoreFields[i].text = i+1 + ". Fetching...";
        }

        highscoresManager = GetComponent<Highscores>();
        StartCoroutine("RefreshHighscores");
    }
    void Start()
    {
        for (int i = 0; i < highscoreText.Length; i++)
        {
            highscoreText[i].text = i + 1 + ". Loading...";
        }

        highscoreManeger = GetComponent<Highscores>();

        StartCoroutine("RefreshHighscores");
    }
Exemplo n.º 35
0
    private void Awake()
    {
        _hscores = GetComponent<Highscores>();
        _playerStats = GetComponent<PlayerStat>();
        _playerStats.LoadPersonalStats();
        UsernameField.text = _playerStats.Username;

        MagnetBText = MagnetB.GetComponentInChildren<Text>();
        DoubleJumpBText = DoubleJumpB.GetComponentInChildren<Text>();
        ScoreBText = ScoreB.GetComponentInChildren<Text>();

        UpdateHighscores();
    }
Exemplo n.º 36
0
    // Use this for initialization
    private void Start()
    {
        LoadPersonalStats();

        _levelManager = Camera.main.GetComponent<LevelManager>();
        if (_levelManager != null){
            _playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerMovement>();
            _highscores = GetComponent<Highscores>();
            ResetCurrentGame();
        }
    }
Exemplo n.º 37
0
 // Use this for initialization
 void Awake()
 {
     highscores = GetComponent<Highscores> ();
     player = GameObject.Find ("RockPlayer");
     gameTime = GameObject.Find ("GameTimeView").GetComponent<GameTimeView> ();
     levelHandler = GameObject.Find ("LevelHandler").GetComponent<LevelHandlerC> ();
     gameUIHelper = GameObject.Find ("GameUIHelper").GetComponent<GameUIHelper> ();
     googleGame = GameObject.Find ("LittleRockstarGoogleGame").GetComponent<LittleRockstarGoogleGame> ();
 }
Exemplo n.º 38
0
 // Use this for initialization
 void Start()
 {
     highscores = GetComponent<Highscores>();
     fx = GameObject.FindObjectOfType<FullScreenFX>();
     fx.SendMessage("OnTitleBeginFX", 1f);
 }
Exemplo n.º 39
0
 void Awake()
 {
     instance = this;
     highscoresDisplay = GetComponent<DisplayHighscores>();
 }
Exemplo n.º 40
0
 public void SaveNew()
 {
     Highscores highscores = new Highscores();
     highscores.BestNotUploadedScore = 0;
     highscores.Highscore = 0;
     EasySerializer.SerializeObjectToFile(highscores, SAVE_PATH);
 }