示例#1
0
 void OnScoreAdd(bool success)
 {
     if (success)
     {
         Debug.Log("Score added");
         mState = State.None;
     }
     else
     {
         UIModalMessage.Open("GameJolt Error", "Unable to post score.", null);
         mState = State.Fail;
     }
 }
示例#2
0
 void OnTrophyAdd(bool success)
 {
     if (success)
     {
         Debug.Log("Process trophy: " + mCurAchieveDat.title);
         mState = State.None;
     }
     else
     {
         UIModalMessage.Open("GameJolt Error", "Unable to process trophy: " + mCurAchieveDat.title, null);
         mState = State.Fail;
     }
 }
示例#3
0
    // Update is called once per frame
    void Update()
    {
#if !OUYA
        if (mRetry)
        {
            if (Time.time - mLastTime > retryWaitDelay)
            {
                DoScoreProcess();
                mRetry = false;
            }
        }
        else if (mCurBoardProcess)
        {
            if (mNG.HasStarted())
            {
                if (!mNG.IsWorking())
                {
                    if (!mScoreProcessing)  //start process if we haven't
                    {
                        StartCoroutine(mNG.postScore(mCurBoardScore, mCurBoardName));
                        mScoreProcessing = true;
                    }
                    else   //completed
                    {
                        if (!mNG.success)
                        {
                            if (mCurRetry == retryCount)
                            {
                                //TODO: tell the user the bad news
                                UIModalMessage.Open("Server Error: " + mNG.errorCode, mNG.errorMessage, null);
                                mCurBoardProcess = false;
                            }
                            else
                            {
                                mCurRetry++;
                                mLastTime        = Time.time;
                                mRetry           = true;
                                mScoreProcessing = false;
                            }
                        }
                        else
                        {
                            mCurBoardProcess = false;
                        }
                    }
                }
            }
        }
#endif
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
#if OUYA
        return;
#else
        switch (mStatus)
        {
        case Status.Uninitialized:
            if (mNG.HasStarted())
            {
                StartCoroutine(mNG.loadSettings());
                mStatus = Status.RetrieveMedals;
            }
            break;

        case Status.RetrieveMedals:
            if (!mNG.IsWorking())
            {
                if (mData != null)
                {
                    StartCoroutine(mNG.unlockMedal(mData.title));
                    mStatus = Status.ProcessData;
                }
                else
                {
                    mStatus   = Status.None;
                    mLastTime = Time.time;
                }
            }
            break;

        case Status.ProcessData:
            if (!mNG.IsWorking())
            {
                if (!mNG.success)
                {
                    if (mCurRetry == retryCount)
                    {
                        //TODO: tell the user the bad news
                        UIModalMessage.Open("Server Error: " + mNG.errorCode, mNG.errorMessage, null);
                        mStatus = Status.Error;
                    }
                    else
                    {
                        mCurRetry++;
                        mLastTime = Time.time;
                        mStatus   = Status.RetryWait;
                    }
                }
                else
                {
                    mStatus   = Status.None;
                    mLastTime = Time.time;
                }
            }
            break;

        case Status.Wait:
            if (mNG.HasStarted() && !mNG.IsWorking())
            {
                StartCoroutine(mNG.unlockMedal(mData.title));
                mStatus = Status.ProcessData;
            }
            break;

        case Status.RetryWait:
            if (Time.time - mLastTime > waitDelay)
            {
                if (mNG.IsWorking() || !mNG.HasStarted())
                {
                    mStatus = Status.Wait;
                }
                else
                {
                    Debug.Log("Newgrounds Try Again: " + mData.title);
                    StartCoroutine(mNG.unlockMedal(mData.title));
                    mStatus = Status.ProcessData;
                }
            }
            break;
        }
#endif
    }