Example #1
0
    void Start()
    {
        // PlayerPrefs.DeleteAll();
        // first run init
        if (!PlayerPrefs.HasKey(Constants.GHOSTS) || !PlayerPrefs.HasKey(Constants.NUM_OF_LOCAL_GHOST_RECORDS))
        {
            PlayerPrefs.SetInt(Constants.GHOSTS, Constants.GHOST_COMPETITORS);
            PlayerPrefs.SetInt(Constants.NUM_OF_LOCAL_GHOST_RECORDS, Constants.GHOST_COMPETITORS);
        }

        GrappleUI.GhostsInput.text       = PlayerPrefs.GetInt(Constants.GHOSTS).ToString();
        GrappleUI.GhostRecordsInput.text = PlayerPrefs.GetInt(Constants.NUM_OF_LOCAL_GHOST_RECORDS).ToString();

        GrappleUI.TotalGhostRecordsLocal.text = PlayerReplay.NumOfLocalRecords.ToString();

        if (PlayerPrefs.GetString(Constants.USERNAME_KEY) == "")
        {
            GrappleUI.NoUsernameScreen.SetActive(true);
            GrappleUI.StartScreen.SetActive(false);
        }
        else
        {
            GrappleUI.UserName.text = _username;
            GrappleUI.StartScreen.SetActive(true);
        }

        Player.Enable();
        Level.SetSectionCreator(Player.gameObject);
        Bug.Init();

        //GrappleServerData.Instance.StartCoroutine(GrappleServerData.Instance.AddLevel(_levelName, (Success, ReturnString) =>
        //{
        //    if (!Success && ReturnString != "")
        //    {
        //        Debug.Log("Server Error: " + ReturnString);
        //        return;
        //    }
        //    PlayerReplay.Instance.StartCoroutine(PlayerReplay.Instance.GetPlayerReplays(_levelName, (replays) =>
        //    {
        //        ReplaysRecieved(replays);
        //        //if (replays.Count > 0)
        //            //StartCoroutine("ReleaseGhosts");
        //    }));
        //}));

        //StartCoroutine("WaitForPlayerInput");
        StartCoroutine("WaitForOpenUI");

        //_playerAudio.Play();
    }