Ejemplo n.º 1
0
    public IEnumerator ServerRequestFacilityBuildComplete(Action <bool> completed)
    {
        bool isEventBuild = false;

        if (!this.isFacilityBuildCompleteRequesting)
        {
            UserFacility userFacility = Singleton <UserDataMng> .Instance.GetUserFacility(this.userFacilityID);

            double restSecondes = FarmUtility.RestSeconds(userFacility.completeTime);
            if (0.0 >= restSecondes)
            {
                this.isFacilityBuildCompleteRequesting = true;
                RestrictionInput.StartLoad(RestrictionInput.LoadType.SMALL_IMAGE_MASK_ON);
                bool isSuccess = false;
                RequestFA_FacilityBuildComplete request = new RequestFA_FacilityBuildComplete
                {
                    SetSendData = delegate(FacilityBuildComplete param)
                    {
                        param.userFacilityId = this.userFacilityID;
                    },
                    OnReceived = delegate(FacilityBuildCompleteResult response)
                    {
                        isSuccess = (response.result == 1);
                    }
                };
                yield return(base.StartCoroutine(request.Run(delegate()
                {
                    RestrictionInput.EndLoad();
                    if (isSuccess)
                    {
                        userFacility.completeTime = null;
                        userFacility.level++;
                        this.BuildCompleteEffect();
                        this.ClearConstruction();
                        isEventBuild = true;
                    }
                }, null, null)));

                this.isFacilityBuildCompleteRequesting = false;
            }
        }
        if (completed != null)
        {
            completed(isEventBuild);
        }
        yield break;
    }