Exemplo n.º 1
0
    IEnumerator Start()
    {
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }

        loading.SetActive(true);

        WWW www = LeaderBoardConnector.FetchResultsAll(10);

        while (!www.isDone)
        {
            yield return(null);
        }

        if (www.error != null)
        {
            yield break;
        }

        var lines = LeaderBoardConnector.ConvertStringToResult(www.text);

        if (!string.IsNullOrEmpty(NameManager.Name) && !lines.Any(r => r.name == NameManager.Name))
        {
            www = LeaderBoardConnector.FetchResultsPlayer(NameManager.Name);

            while (!www.isDone)
            {
                yield return(null);
            }

            if (www.error != null)
            {
                yield break;
            }

            lines.AddRange(LeaderBoardConnector.ConvertStringToResult(www.text));
        }

        foreach (var line in lines)
        {
            GameObject prefab  = line.place == 1 ? leaderboardLinePrefab1 : line.place == 2 ? leaderboardLinePrefab2 : line.place == 3 ? leaderboardLinePrefab3 : leaderboardLinePrefab;
            GameObject newLine = Instantiate(prefab);

            newLine.transform.SetParent(transform, false);

            var lineComponent = newLine.GetComponent <LeaderboardLine>();
            lineComponent.place           = line.place;
            lineComponent.playerName      = line.name;
            lineComponent.score           = line.score;
            lineComponent.isCurrentPlayer = line.name == NameManager.Name;
        }

        loading.SetActive(false);
    }
Exemplo n.º 2
0
    private IEnumerator OnGameOver()
    {
        gameOver          = true;
        gameOverText.text = gameOverText.text.Replace("XXX", antHill.level.ToString()).Replace("YYY", Medal());
        innerPanel.SetActive(true);
        GameManager.OnGameOver();

        WWW www = LeaderBoardConnector.Save(NameManager.Name, antHill.level);

        while (!www.isDone)
        {
            yield return(null);
        }

        leaderboardSent = true;
    }