void Start()
    {
        //prefabPlayerHeight = prefabPlayer.GetComponent<RectTransform>().rect.height;
        ScoreboardInfo.DeleteScoreboardDataInHolder();

        chooseBtn.onClick.Invoke();
    }
Beispiel #2
0
    private void OnEnable()
    {
        if (!playerList)
        {
            Debug.LogError("NO PLAYER LIST ASSIGNED");
            return;
        }

        if (!playerInfoPrefab)
        {
            Debug.LogError("NO PLAYER INFO PREFAB");
            return;
        }

        PlayerNetwork[] temp = FindObjectsOfType <PlayerNetwork>(); // Get reference to all players

        if (temp == null)                                           // If the reference is null, return
        {
            return;
        }

        if (temp.Length != children.Count)   //Amount of players in list does not match with the amount of actual players, update it!
        {
            //Remove all players from scoreboard
            for (int i = 0; i < playerList.childCount; i++)
            {
                Destroy(playerList.GetChild(i)); // Destroy all spawned UI objects
            }
            children.Clear();                    // Clear the list

            //Re-populate the scoreboard with players
            for (int i = 0; i < temp.Length; i++)
            {
                GameObject     go   = Instantiate(playerInfoPrefab, playerList); // Instantiate UI object
                ScoreboardInfo info = go.GetComponent <ScoreboardInfo>();        // Get reference to the info

                info.AssignPlayerNetwork(temp[i]);                               // Set the UI's player reference
                children.Add(info);                                              // Add the info to the list
            }
        }

        if (GameManager.instance.gameHasEnded)
        {
            transform.GetChild(2).gameObject.SetActive(true);
        }
    }
Beispiel #3
0
    IEnumerator GetRequest(string url, int mode)
    {
        if (ScoreboardInfo.infoHolder[mode] != null)
        {
            ScoreboardInfo.info = ScoreboardInfo.infoHolder[mode];
            dataReceived        = true;
            yield break;
        }

        UnityWebRequest uwr = UnityWebRequest.Get(url);

        uwr.certificateHandler = new AcceptAllCertificatesSignedWithASpecificKeyPublicKey();
        dataReceivedFailed     = false;

        for (int i = 0; i < MAX_ATTEMPTS; i++)
        {
            uwr.timeout = 5;
            yield return(uwr.SendWebRequest());

            if (uwr.isHttpError || uwr.isNetworkError)
            {
                GameSettings.MyDebug("Error While Sending: " + uwr.error);
                //SceneSwitcher.LoadScene2(GameSettings.MENU_LEADERBOARDS);
                dataReceivedFailed = true;
                continue;
            }
            else
            {
                GameSettings.MyDebug("Received: " + uwr.downloadHandler.text);

                /*if (thematic)
                 * {
                 *  GameInfoThematic.SetRoundStartInfo(uwr.downloadHandler.text, true);
                 * }*/// wtf id dis here for? i must have lost my mind aready, $#&%

                ScoreboardInfo.SetScoreboardInfoForHolders(uwr.downloadHandler.text, mode);

                ScoreboardInfo.info = ScoreboardInfo.infoHolder[mode];

                dataReceived = true;
                break;
            }
        }
    }
    /*******************************************************************************
        Function: LoadRewardsFromFile

     Description: Grabs the saved achievements

          Inputs: None

         Outputs: None
    *******************************************************************************/
    public void LoadRewardsFromFile()
    {
        // ui_HighScore =              (uint)PlayerPrefs.GetInt("HighScore");
        // ui_HighScore_LongestLife =  (uint)PlayerPrefs.GetInt("HighScore_LongestLife");

        scoreboardInfo = new ScoreboardInfo();

        if (PlayerPrefs.HasKey("Name_1st"))
        {
            scoreboardInfo.Name_1st = PlayerPrefs.GetString("Name_1st");
            scoreboardInfo.Name_2nd = PlayerPrefs.GetString("Name_2nd");
            scoreboardInfo.Name_3rd = PlayerPrefs.GetString("Name_3rd");
            scoreboardInfo.Name_4th = PlayerPrefs.GetString("Name_4th");
            scoreboardInfo.Name_5th = PlayerPrefs.GetString("Name_5th");

            scoreboardInfo.Score_1st = (uint)PlayerPrefs.GetInt("Score_1st");
            scoreboardInfo.Score_2nd = (uint)PlayerPrefs.GetInt("Score_2nd");
            scoreboardInfo.Score_3rd = (uint)PlayerPrefs.GetInt("Score_3rd");
            scoreboardInfo.Score_4th = (uint)PlayerPrefs.GetInt("Score_4th");
            scoreboardInfo.Score_5th = (uint)PlayerPrefs.GetInt("Score_5th");
        }
        else
        {
            scoreboardInfo.Name_1st = Name_1st;
            scoreboardInfo.Name_2nd = Name_2nd;
            scoreboardInfo.Name_3rd = Name_3rd;
            scoreboardInfo.Name_4th = Name_4th;
            scoreboardInfo.Name_5th = Name_5th;

            scoreboardInfo.Score_1st = Score_1st;
            scoreboardInfo.Score_2nd = Score_2nd;
            scoreboardInfo.Score_3rd = Score_3rd;
            scoreboardInfo.Score_4th = Score_4th;
            scoreboardInfo.Score_5th = Score_5th;

        }

        // print("Load Rewards");
        SaveRewardsToFile();
    }
    // Use this for initialization
    void Start()
    {
        scoreboardInfo = new ScoreboardInfo();

        LoadRewardsFromFile();
    }
    /*******************************************************************************
    Function: ResetRewardValues

 Description: Resets all achievement scores

      Inputs: None

     Outputs: None
*******************************************************************************/
    public void ResetRewardValues()
    {
        ui_HighScore = 0;
        ui_HighScore_LongestLife = 0;

        scoreboardInfo = new ScoreboardInfo();

        scoreboardInfo.Name_1st = "Alpha";
        scoreboardInfo.Name_2nd = "Beta";
        scoreboardInfo.Name_3rd = "Charlie";
        scoreboardInfo.Name_4th = "Delta";
        scoreboardInfo.Name_5th = "Echo";
        scoreboardInfo.Score_1st = 1000;
        scoreboardInfo.Score_2nd = 900;
        scoreboardInfo.Score_3rd = 800;
        scoreboardInfo.Score_4th = 700;
        scoreboardInfo.Score_5th = 600;

        //print(scoreboardInfo.Name_1st);

        SaveRewardsToFile();
    }
    /*******************************************************************************
    Function: SetScoreboardInformation

 Description: Receives the new Scoreboard information from external sources

      Inputs: scoreboardInfo_ (ScoreboardInfo) - The new scoreboardinfo

     Outputs: None
*******************************************************************************/
    public void SetScoreboardInformation(ScoreboardInfo scoreboardInfo_)
    {
        //print("New 5th: " + scoreboardInfo_.Score_5th);

        scoreboardInfo.Score_1st = scoreboardInfo_.Score_1st;
        scoreboardInfo.Score_2nd = scoreboardInfo_.Score_2nd;
        scoreboardInfo.Score_3rd = scoreboardInfo_.Score_3rd;
        scoreboardInfo.Score_4th = scoreboardInfo_.Score_4th;
        scoreboardInfo.Score_5th = scoreboardInfo_.Score_5th;

        scoreboardInfo.Name_1st = scoreboardInfo_.Name_1st;
        scoreboardInfo.Name_2nd = scoreboardInfo_.Name_2nd;
        scoreboardInfo.Name_3rd = scoreboardInfo_.Name_3rd;
        scoreboardInfo.Name_4th = scoreboardInfo_.Name_4th;
        scoreboardInfo.Name_5th = scoreboardInfo_.Name_5th;

        SaveRewardsToFile();
    }
    public ScoreboardInfo GetScoreboardInfo()
    {
        if(scoreboardInfo.Name_1st == null)
        {
            scoreboardInfo = new ScoreboardInfo();

            scoreboardInfo.Name_1st = Name_1st;
            scoreboardInfo.Name_2nd = Name_2nd;
            scoreboardInfo.Name_3rd = Name_3rd;
            scoreboardInfo.Name_4th = Name_4th;
            scoreboardInfo.Name_5th = Name_5th;

            scoreboardInfo.Score_1st = Score_1st;
            scoreboardInfo.Score_2nd = Score_2nd;
            scoreboardInfo.Score_3rd = Score_3rd;
            scoreboardInfo.Score_4th = Score_4th;
            scoreboardInfo.Score_5th = Score_5th;
        }

        return scoreboardInfo;
    }
Beispiel #9
0
    // Use this for setting values
    void Start()
    {
        dataReceived = false;

        ScoreboardInfo.DeleteScoreboardDataInHolder();
    }