Example #1
0
    private void OnSelected(ListUpgrade type)
    {
        selectedType = type;
        refType      = SyncData.CurrentBaseUpgrade[type];
        ITable dbTable = dBReference[selectedType];

        SQLiteTable_TrainningCost costTable = dBReference[DBType.TrainningCost] as SQLiteTable_TrainningCost;


        refTypeTraining = dbTable[SyncData.CurrentBaseUpgrade[selectedType].Level - 1];
        refCostInfo     = costTable[selectedType];

        CurrentSelect.Placeholder.text = selectedType.ToString().InsertSpace();
    }
Example #2
0
    public override void Load(params object[] input)
    {
        MainbaseLevelBar.Value = SyncData.CurrentBaseUpgrade[ListUpgrade.MainBase].Level;
        MainbaseLevelBar.SetDefaultPlaceholder();

        BaseUpgradeRow resRef = SyncData.CurrentResearch;
        BaseUpgradeRow upgRef = SyncData.CurrentUpgrade;

        bool isUpgrade = upgRef != null?upgRef.ID.IsDefined() : false;

        bool isResearch = resRef != null?resRef.ID.IsDefined() : false;

        //Debug.Log(isUpgrade + " - " + isResearch);
        ITable table = null;

        if (isUpgrade)
        {
            table = WDOCtrl[upgRef.ID];

            ITableData upgInfo = table[upgRef.Level - 1];
            int        timeInt = fieldReflection.GetPublicField <int>(upgInfo, "TimeInt");
            UpgProgBar.Slider.MaxValue = timeInt;
        }

        if (isResearch)
        {
            table = WDOCtrl[resRef.ID];

            ITableData resInfo = table[upgRef.Level - 1];
            int        timeInt = fieldReflection.GetPublicField <int>(resInfo, "TimeInt");
            ResProgBar.Slider.MaxValue = timeInt;
        }

        UpgProgBar.gameObject.SetActive(isUpgrade);
        ResProgBar.gameObject.SetActive(isResearch);
    }
Example #3
0
    /// <summary>
    /// 0: type - ListUpgrade
    /// 1: need material - int[4]
    /// 2: might bonus - int
    /// 3: time min - string
    /// 4: time int - int
    /// </summary>
    /// <param name="data">Params object</param>
    public override void Load(params object[] data)
    {
        currentMainBase = SyncData.CurrentMainBase;

        ListUpgrade loadType = data.TryGet <ListUpgrade>(0);
        ITable      table    = dbReference[loadType];

        string title = loadType.ToString().InsertSpace();
        int    level = SyncData.CurrentBaseUpgrade[loadType].Level;


        ITableData needInfo = table[level - 1];

        int foodCost   = GetPublicValue <int>(needInfo, "FoodCost");
        int woodCost   = GetPublicValue <int>(needInfo, "WoodCost");
        int metalCost  = GetPublicValue <int>(needInfo, "MetalCost");
        int stoneCost  = GetPublicValue <int>(needInfo, "StoneCost");
        int mightBonus = GetPublicValue <int>(needInfo, "MightBonus");

        int[] needMaterials = new int[] {
            foodCost,
            woodCost,
            stoneCost,
            metalCost
        };

        curMaterials[0] = currentMainBase.Farm;
        curMaterials[1] = currentMainBase.Wood;
        curMaterials[2] = currentMainBase.Stone;
        curMaterials[3] = currentMainBase.Metal;

        isUpgradeType = loadType.IsUpgrade();

        bool activeProgressBar = isUpgradeType ? currentMainBase.UpgradeWait_ID.IsDefined()
                                                            : currentMainBase.ResearchWait_ID.IsDefined();

        bool activeBtnGroup = !activeProgressBar;

        activeBtnGroup = activeBtnGroup && IsEnoughtMeterial(needMaterials);
        ActiveBtnGroup(activeBtnGroup);


        bool isSimilarCurUpgResType = true;

        if (isUpgradeType)
        {
            if (currentMainBase.UpgradeWait_ID.IsDefined() &&
                loadType != currentMainBase.UpgradeWait_ID)
            {
                loadType = currentMainBase.UpgradeWait_ID;
                isSimilarCurUpgResType = false;
            }
        }
        else
        {
            if (currentMainBase.ResearchWait_ID.IsDefined() &&
                loadType != currentMainBase.ResearchWait_ID)
            {
                loadType = currentMainBase.ResearchWait_ID;
                isSimilarCurUpgResType = false;
            }
        }

        refUpgType = SyncData.CurrentBaseUpgrade[loadType];
        if (!isSimilarCurUpgResType)
        {
            table    = dbReference[loadType];
            level    = refUpgType.Level;
            needInfo = table[level - 1];
        }


        string timeMin = GetPublicValue <string>(needInfo, "TimeMin"); // needInfo.TimeMin;
        int    timeInt = GetPublicValue <int>(needInfo, "TimeInt");    //needInfo.TimeInt;

        ActiveProgressBar(activeProgressBar && timeInt > 0);
        ProgressSlider.Slider.MaxValue = timeInt;


        bool isBuildingRequire = false;
        bool isResearchRequire = false;

        BuildingLevel.transform.parent.gameObject.SetActive(isBuildingRequire);
        ResearchLevel.transform.parent.gameObject.SetActive(isResearchRequire);

        #region display info
        Title.text = title;

        if (curMaterials != null && needMaterials != null)
        {
            for (int i = 0; i < 4; i++)
            {
                int captureInt = i;
                OrderMaterialElements[i].SelectableComp.OnClickEvents += delegate
                {
                    SetMaterialRequirement(captureInt, ++curMaterials[captureInt], needMaterials[captureInt]);
                    if (IsEnoughtMeterial(needMaterials))
                    {
                        ActiveBtnGroup(true);
                    }
                };
                SetMaterialRequirement(i, curMaterials[i], needMaterials[i]);
            }
        }

        // ============================ //
        NumberName.text = "Might Bonus";
        Amount.text     = string.Format("{0}", mightBonus);

        //DurationText.text = "Duration: " + timeMin;
        DurationText.text = timeMin;
        #endregion
    }