コード例 #1
0
    /*
     ############################################################
     ######################## CHALLENGE #########################
     ############################################################
     */

    IEnumerator GetText(string flowString, string volString)
    {
        int    oldBalance = PlayerPrefs.GetInt("COIN_BALANCE");
        string flow       = flowString.Remove(flowString.Length - 1, 1);
        string volume     = volString.Remove(volString.Length - 1, 1);

        string url = "https://uql53bqfta.execute-api.us-east-1.amazonaws.com/Artsy/add-breath";

        // TODO: Waiting on backend to change Headers to Form Data
        List <IMultipartFormSection> formData = new List <IMultipartFormSection>();
        UnityWebRequest request = UnityWebRequest.Post(url, formData);

        request.SetRequestHeader("deviceid", SystemInfo.deviceUniqueIdentifier.Replace("-", ""));
        request.SetRequestHeader("volume", volume);
        request.SetRequestHeader("flow", flow);

        yield return(request.SendWebRequest());

        string     data  = request.downloadHandler.text;
        Spirometer spiro = Spirometer.CreateFromJSON(data);

        PlayerPrefs.SetString("BREATH_GRADE", spiro.grade);
        PlayerPrefs.SetString("BREATH_FEEDBACK", spiro.feedback);
        PlayerPrefs.SetInt("BREATH_SCORE", spiro.score);
        PlayerPrefs.SetInt("COIN_BALANCE", spiro.balance);
        PlayerPrefs.SetInt("BREATH_COUNT", spiro.breathCount);

        if (spiro.breathCount >= 10)
        {
            PlayerPrefs.SetInt("UNLIMITED_STATUS", 1);
            // Set up the time of one hour
            DateTime dt = DateTime.UtcNow + TimeSpan.FromSeconds(3600);
            GlobalTimer.SetEndTime(dt);
            // Debug.Log("Timer is set up to:" + dt.ToString("yyyy-MM-dd-HH-mm-ss"));
        }

        SetCoinBalance();
        UpdateBar();

        int score = PlayerPrefs.GetInt("BREATH_SCORE");

        BreathQuality(score, oldBalance);
    }
コード例 #2
0
 public void CloseChallenge()
 {
     GlobalTimer.SetEndTime(DateTime.MaxValue);
     Alert.SetActive(false);
 }