コード例 #1
0
    // MARK: Claim

    public void doClaim(Objectives.ClaimRequest request)
    {
        var response = new Objectives.ClaimResponse();

        //invalid index
        if (request.id >= this.fetchedObjectives.Length)
        {
            response.isRewardGranted = false;
            this.presenter.presentClaim(response);
            return;
        }
        //max step not reached
        if (this.fetchedObjectives[request.id].currentStep != this.fetchedObjectives[request.id].numberOfSteps)
        {
            response.isRewardGranted = false;
            this.presenter.presentClaim(response);
            return;
        }

        var reward = this.fetchedObjectives[request.id].reward;

        LocalMoneyWorker.Instance.Sell(reward, delegate(int amount) {
            //everything is fine, we can update claim status
            //fetchedObjectives[request.id].isRewardClaimed = true;
            ObjectivesWorker.UpdateStatus(request.id, fetchedSet, true);

            //since we flushed data we fetch objectives again
            var fetchRequest = new Objectives.FetchRequest();
            fetchRequest.numberOfObjectives = numberOfObjectives;
            fetchRequest.set = fetchedSet;
            doFetch(fetchRequest);

            //if all Game Objectives are complete and claimed, we should autoflush
            if (fetchedSet == Objectives.ObjectiveSet.Game)
            {
                bool shouldAutoFlush = true;
                foreach (var objective in fetchedObjectives)
                {
                    if (false == objective.isRewardClaimed)
                    {
                        shouldAutoFlush = false;
                    }
                }

                if (shouldAutoFlush)
                {
                    var flushRequest = new Objectives.FlushRequest();
                    doFlush(flushRequest);
                }
            }

            response.isRewardGranted = true;
            this.presenter.presentClaim(response);
        });
    }
コード例 #2
0
    // MARK: Claim

    public void presentClaim(Objectives.ClaimResponse response)
    {
        if (response.isRewardGranted)
        {
            NotifierPresenter.Instance.PerformInstantaneousRequest("Cash Earned !");
        }
        else
        {
            NotifierPresenter.Instance.PerformInstantaneousRequest("Hum ... Cannot add more cash !");
        }
    }
コード例 #3
0
 void IObjectivesPresenter.presentClaim(Objectives.ClaimResponse response)
 {
     presentClaimCalled = true;
     lastClaimResponse  = response;
 }