Пример #1
0
    private void Awake()
    {
        instance = this;

        string pList = PlayerPrefs.GetString("PlayerList");

        if (pList.Length == 0)
        {
            return;
        }

        string[] nameArray = pList.Split(';');

        foreach (string name in nameArray)
        {
            if (name == "")
            {
                continue;
            }

            float result = PlayerPrefs.GetFloat(name, 100);

            if (!playerList.ContainsKey(name))
            {
                playerList.Add(name, result);
            }
            else
            {
                playerList[name] = result;
            }
        }
    }
Пример #2
0
    void OnHiscoresLoaded(string receivedData)
    {
        levels[0].hiscore.Clear();
        Debug.Log("Sores Init: " + receivedData);

        string[] allData = Regex.Split(receivedData, "</n>");

        for (var i = 0; i < allData.Length - 1; i++)
        {
            string[] userData = Regex.Split(allData[i], ":");
            Hiscore  hiscore  = new Hiscore();
            hiscore.id         = int.Parse(userData[0]);
            hiscore.score      = int.Parse(userData[1]);
            hiscore.facebookID = userData[2];
            hiscore.username   = Data.Instance.userData.GetUserNameSmaller(userData[3]);
            levels[0].hiscore.Add(hiscore);

            //por las dudas uqe habia otro score grabado local
            if (hiscore.facebookID == Data.Instance.userData.facebookId)
            {
                Debug.Log(":______________ hiscore.facebookID " + hiscore.facebookID + " " + Data.Instance.userData.facebookId + " score: " + hiscore.score);
                levels[0].myScore = hiscore.score;
            }
        }

        //por ahora lo hago aca...
        if (levels[0].myScore > 0)
        {
            LoadMyHiscoreIfNotExistesInRanking(Data.Instance.userData.facebookId, levels[0].myScore);
        }
    }
Пример #3
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            hiscore = SaveFile.Load();

            scoreFont    = Content.Load <SpriteFont>("ScoreFont");
            gameOverFont = Content.Load <SpriteFont>("GameOverFont");

            snake.SetupTexture(GraphicsDevice);
            apple.SetupTexture(GraphicsDevice);
        }
Пример #4
0
    public void NewGame()
    {
        string nick = nickname.text;

        if (nick.Length < 1)
        {
            //TODO: show error;
            return;
        }

        Player.NickName = nick;
        Hiscore.AddPlayer(nick);
        LoadScene("SampleScene");
    }
Пример #5
0
    //ładuje stan gry
    public static void Open()
    {
        if (vaultOpen)
        {
            return;
        }

        energy = 20;

        playerScore    = Hiscore.LoadScore();
        playerSettings = Options.LoadSettings();

        vaultOpen = true;
    }
Пример #6
0
    void OnTournamentAddScores(int levelID, List <int> playersID)
    {
        if (!isOn)
        {
            return;
        }
        Hiscore hiscore = new Hiscore();

        hiscore.playersID = playersID;
        int id = levelID - 1;

        if (hiscores.Count == id)
        {
            hiscores.Add(hiscore);
        }
        else
        {
            hiscores[id] = hiscore;
        }
    }
Пример #7
0
    public Hiscore GetMyNextGoal()
    {
        string facebookID = Data.Instance.userData.facebookId;

        if (levels[0].hiscore.Count == 0)
        {
            return(null);
        }

        Hiscore lastHiscore = levels[0].hiscore[0];

        foreach (Hiscore hiscore in levels[0].hiscore)
        {
            if (levels[0].myScore > hiscore.score || facebookID == hiscore.facebookID)
            {
                return(lastHiscore);
            }
            lastHiscore = hiscore;
        }
        return(lastHiscore);
    }
Пример #8
0
    public void SaveNew(string fileName, string username, int newHiscoreToSave)
    {
        Hiscore newHiscore = new Hiscore();

        newHiscore.username = username;
        newHiscore.hiscore  = newHiscoreToSave;
        hiscores.Add(newHiscore);

        arrengedHiscores = OrderByHiscore(hiscores);

        String[] arrLines = new String[hiscores.Count];
        int      a        = 0;

        foreach (Hiscore hs in arrengedHiscores)
        {
            arrLines [a] = hs.username + "_" + hs.hiscore;
            a++;
        }
        File.WriteAllLines(fileName, arrLines);
        Invoke("grabaEnd", 0.25f);
    }
Пример #9
0
    void LoadMyHiscoreIfNotExistesInRanking(string facebookID, int score)
    {
        bool exists = false;

        foreach (Hiscore hiscore in levels[0].hiscore)
        {
            if (facebookID == hiscore.facebookID)
            {
                exists = true;
            }
        }
        if (!exists)
        {
            Hiscore hiscore = new Hiscore();
            hiscore.id         = Data.Instance.userData.userId;
            hiscore.score      = score;
            hiscore.facebookID = facebookID;
            hiscore.username   = "******";
            levels[0].hiscore.Add(hiscore);
        }
        ArrengeHiscoresByScore();
    }
Пример #10
0
    void LoadHiscores(string fileName)
    {
        String[] arrLines = File.ReadAllLines(fileName);
        int      num      = 1;

        foreach (string line in arrLines)
        {
            string[] lines   = line.Split("_"[0]);
            Hiscore  hiscore = new Hiscore();
            hiscore.username = lines[0];
            hiscore.hiscore  = int.Parse(lines[1]);
            hiscores.Add(hiscore);

            if (hiscore.hiscore < Data.Instance.score && !yaAgrego)
            {
                yaAgrego = true;
                puesto   = num;
                if (num < 11)
                {
                    ScoreLine newScoreLine = Instantiate(scoreLineNewHiscore);
                    newScoreLine.Init(num, "XXX", Data.Instance.score);
                    newScoreLine.transform.SetParent(container);
                    newScoreLine.transform.localScale = Vector3.one;
                    num++;
                }
            }

            if (num < 11)
            {
                ScoreLine newScoreLine = Instantiate(scoreLine);
                newScoreLine.Init(num, hiscore.username, hiscore.hiscore);
                newScoreLine.transform.SetParent(container);
                newScoreLine.transform.localScale = Vector3.one;
            }

            num++;
        }
    }
Пример #11
0
    void LoadHiscores(string fileName)
    {
        String[] arrLines = File.ReadAllLines(fileName);
        all.Clear();
        foreach (string line in arrLines)
        {
            string[] lines   = line.Split("_"[0]);
            Hiscore  hiscore = new Hiscore();
            hiscore.username = lines[0];
            hiscore.hiscore  = int.Parse(lines[1]);
            all.Add(hiscore);
//
//			if (hiscore.hiscore < _hiscore && !yaAgrego)
//			{
//				yaAgrego = true;
//				puesto = num;
//				if (num < 16)
//				{
//					ScoreLine newScoreLine = Instantiate(scoreLineNewHiscore);
//					newScoreLine.Init(num, "XXXXX", _hiscore);
//					newScoreLine.transform.SetParent(container);
//					newScoreLine.transform.localScale = Vector3.one;
//					num++;
//				}
//			}
//
//			if(num<16)
//			{
//				ScoreLine newScoreLine = Instantiate(scoreLine);
//				newScoreLine.Init(num, hiscore.username, hiscore.hiscore);
//				newScoreLine.transform.SetParent(container);
//				newScoreLine.transform.localScale = Vector3.one;
//			}

            //num++;
        }
    }