private UserFacility StartBuild(FarmObject farmObject, FarmGrid.GridPosition gridPosition)
    {
        FacilityM facilityMaster = FarmDataManager.GetFacilityMaster(farmObject.facilityID);
        int       num            = int.Parse(facilityMaster.buildingTime);
        string    text           = null;

        if (facilityMaster.autoBuildingFlg == "0")
        {
            text = ServerDateTime.Now.ToString();
        }
        if (0 < num)
        {
            DateTime time = ServerDateTime.Now.AddSeconds((double)num + 1.0);
            text = FarmUtility.GetDateString(time);
        }
        return(new UserFacility
        {
            userFacilityId = farmObject.userFacilityID,
            facilityId = farmObject.facilityID,
            positionX = gridPosition.x,
            positionY = gridPosition.y,
            level = ((text != null) ? 0 : 1),
            completeTime = text
        });
    }
    public void StartUpgrade(UserFacility userFacility)
    {
        FarmRoot         instance = FarmRoot.Instance;
        FacilityUpgradeM facilityUpgradeMaster = FarmDataManager.GetFacilityUpgradeMaster(userFacility.facilityId, userFacility.level + 1);

        FarmUtility.PayCost(facilityUpgradeMaster.upgradeAssetCategoryId1, facilityUpgradeMaster.upgradeAssetNum1);
        int num = 0;

        if (int.TryParse(facilityUpgradeMaster.upgradeTime, out num))
        {
            DateTime time = ServerDateTime.Now.AddSeconds((double)(num + 1));
            userFacility.completeTime = FarmUtility.GetDateString(time);
            FacilityM facilityMaster = FarmDataManager.GetFacilityMaster(userFacility.facilityId);
            if (facilityMaster.levelUpFlg == "1")
            {
                this.ReBuildEventItem(userFacility);
            }
            this.StartConstruction(userFacility.userFacilityId);
            instance.ClearSettingFarmObject();
        }
    }
    private void SetCostInfo()
    {
        DrawFacilityButton[] componentsInChildren = base.GetComponentsInChildren <DrawFacilityButton>();
        if (componentsInChildren == null || null == this.buildCostLabel)
        {
            return;
        }
        this.buildCostLabel.gameObject.SetActive(false);
        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            Transform transform = componentsInChildren[i].transform;
            if ("UpgradeButton" == transform.name)
            {
                this.buildCostLabel.SetUpgradeCostDetail(this.farmObject.userFacilityID);
                this.buildCostLabel.gameObject.SetActive(true);
                this.SetBuildCostLabelPosition(transform.parent.gameObject);
                break;
            }
            if ("ShortCutButton" == transform.name)
            {
                if (this.farmObject.IsTutorialFacility())
                {
                    FarmUI             componentInParent  = base.GetComponentInParent <FarmUI>();
                    ConstructionDetail constructionDetail = componentInParent.GetConstructionDetail(this.farmObject.userFacilityID);
                    int          complateSeconds          = constructionDetail.GetComplateSeconds();
                    UserFacility userFacility             = Singleton <UserDataMng> .Instance.GetUserFacility(this.farmObject.userFacilityID);

                    userFacility.completeTime = FarmUtility.GetDateString(ServerDateTime.Now.AddSeconds((double)complateSeconds));
                }
                this.buildCostLabel.SetShortCutCostDetail(this.farmObject.userFacilityID);
                this.buildCostLabel.gameObject.SetActive(true);
                this.SetBuildCostLabelPosition(transform.parent.gameObject);
                break;
            }
        }
    }