示例#1
0
    void Update()
    {
        if (mProcessUpdates.Count > 0)
        {
            DataProcess dat = mProcessUpdates.Peek();

            int numProcessComplete = 0;
            int numInvalid         = 0;
            int numUnlocked        = 0;

            for (int i = 0; i < mServices.Count; i++)
            {
                IService service = mServices[i];

                Data serviceData = service.AchievementCurrentData();
                if (serviceData == dat.data)
                {
                    Status s = service.AchievementCurrentStatus();
                    if (s == Status.Error)
                    {
                        numInvalid++;
                    }
                    else if (s == Status.Complete)
                    {
                        numProcessComplete++;
                    }
                }
                else if (service.AchievementIsReady())
                {
                    if (service.AchievementAllow())
                    {
                        //if it's already completed
                        if (service.AchievementIsUnlocked(dat.data))
                        {
                            numUnlocked++;
                        }
                        else
                        {
                            service.AchievementProcessData(dat.data, dat.progress, dat.complete);
                            if (service.AchievementCurrentStatus() == Status.Complete)
                            {
                                numProcessComplete++;
                            }
                        }
                    }
                    else
                    {
                        numInvalid++;
                    }
                }
            }

            int validServices = mServices.Count - numInvalid;

            //all done?
            if (numUnlocked >= validServices)
            {
                mProcessUpdates.Dequeue();
            }
            else if (numProcessComplete > 0 && numUnlocked + numProcessComplete >= validServices)
            {
                mProcessUpdates.Dequeue();

                if (popupCallback != null)
                {
                    popupCallback(dat.data, dat.progress, dat.complete);
                }
                else
                {
                    mProcessPopUps.Enqueue(dat);
                }
            }
        }

        //notify pop-up
        if (mProcessPopUps.Count > 0 && popupCallback != null)
        {
            while (mProcessPopUps.Count > 0)
            {
                DataProcess dat = mProcessPopUps.Dequeue();
                popupCallback(dat.data, dat.progress, dat.complete);
            }
        }
    }