예제 #1
0
    private void CreateType(ListUpgrade type, int maxQuality)
    {
        DeployMilitaryTag tag = GetTag();

        tag.Icon.Placeholder.text = type.ToString();
        tag.MaxQuality            = maxQuality;
        tag.Type = type;
        tag.gameObject.SetActive(true);
    }
예제 #2
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();
    }
예제 #3
0
        private bool ValidateResearchTask(MiniTaskWDOElement taskElement)
        {
            ListUpgrade type = baseInfo.ResearchWait_ID;

            if (type.IsDefined())
            {
                taskElement.SetGetTimeFunc
                (
                    delegate { return(GetResearchTimeString(taskElement)); },
                    GetResearchMaxTime()
                );
                taskElement.SetTitleFunc(delegate { return("Researching " + type.ToString().InsertSpace() + "..."); });
                taskElement.SetSliderValue(GetResearchTime);
                taskElement.gameObject.SetActive(true);
                return(true);
            }
            return(false);
        }
예제 #4
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
    }