Exemplo n.º 1
0
            public void Refresh(UIBuildingCardPreset preset)
            {
                buildData = GameCore.DataTable.GetDataTable <BuildingData>().GetDataRow(preset.buildID);
                if (buildData != null)
                {
                    if (buildData.IsUnlocked)
                    {
                        root.SetActive(false);
                        return;
                    }
                    else
                    {
                        root.SetActive(true);
                    }

                    Refresh();
                    RefreshButtons(preset);

                    if (buildData.culture_tree_id > 0)
                    {
                        var cultureTreeData = GameCore.DataTable.GetDataTable <CultureTreeData>().GetDataRow(buildData.culture_tree_id);
                        unlockTip.SetText(GameFramework.Utility.Text.Format(GameCore.Localization.GetString(300019), GameCore.Localization.GetString(cultureTreeData.string_id)));
                    }
                }
            }
Exemplo n.º 2
0
        private void UpdateBuildingListData()
        {
            dataPreset.Clear();

            // 建物顯示排序預設為ID遞增排序,當前的項目會顯示在最前面
            var buildDatas = GameCore.DataTable.GetDataTable <BuildingData>().GetDataRows(delegate(BuildingData building)
            {
                return(building.type == masterData.sub_type);
            });

            buildDatas = buildDatas.OrderBy(data => !data.IsUnlocked).ThenBy(data => data.Id != slaverTid).ThenBy(data => data.Id).ToArray();

            for (int i = 0; i < buildDatas.Length; i++)
            {
                UIBuildingCardPreset preset = ReferencePool.Acquire <UIBuildingCardPreset>();
                preset.buildID      = buildDatas[i].Id;
                preset.totalCost    = (subBuildingPreset.isMainBuildingProcess) ? masterData.population_cost + buildDatas[i].population_cost : buildDatas[i].population_cost;
                preset.nonUsingCost = nonUsingCost;
                preset.isUsing      = buildDatas[i].Id == slaverTid;
                preset.selectAction = OnSelectBuilding;
                dataPreset.Add(preset);
            }

            txt_noBuilds.gameObject.SetActive(buildDatas.Length == 0);
            BtnRoot.gameObject.SetActive(buildDatas.Length == 0);
        }
Exemplo n.º 3
0
            public void Refresh(UIBuildingCardPreset preset)
            {
                buildData = GameCore.DataTable.GetDataTable <BuildingData>().GetDataRow(preset.buildID);
                if (buildData != null)
                {
                    if (buildData.IsUnlocked)
                    {
                        root.SetActive(true);
                    }
                    else
                    {
                        root.SetActive(false);
                        return;
                    }

                    Refresh();
                    RefreshButtons(preset);

                    if (preset.isUsing)
                    {
                        costRoot.SetActive(false);
                        unlockTipRoot.SetActive(true);
                        unlockTip.SetText(300012);

                        if (buildData.IsSubBuilding)
                        {
                            // 預設為使用中的卡片, 直接觸發被點選的效果
                            selectBtn.onClick.Invoke();
                        }
                        else
                        {
                            selectedToggle.isOn = true;
                        }
                    }
                    else
                    {
                        unlockTipRoot.SetActive(false);
                        costRoot.SetActive(true);

                        maxTitle.SetText(300007);
                        maxNum.text = Utility.Text.Format(GameCore.Localization.GetString(300013), GameCore.NetData.GetBuildingCount(buildData.Id), buildData.max);

                        populationUnion.SetText(buildData.population_cost.GeneralFormat());
                        populationUnion.ChangeStyle(preset.nonUsingCost < buildData.population_cost ? redTextStyleIdx : coinTextStyleIdx);
                    }
                }
            }
Exemplo n.º 4
0
            public void RefreshButtons(UIBuildingCardPreset preset)
            {
                infoBtn.onClick.AddListener(() =>
                {
                    selectedToggle.isOn = true;
                    curDisplayMode      = DisplayMode.Info;
                });

                infoBackBtn.onClick.AddListener(() =>
                {
                    selectedToggle.isOn = true;
                    curDisplayMode      = DisplayMode.Normal;
                });

                // 選擇該建築進行建設
                selectBtn.onClick.AddListener(() =>
                {
                    selectedToggle.isOn = true;

                    if (buildData.IsMainBuilding)
                    {
                        if (CheckBuildCondition(buildData, preset.totalCost, preset.nonUsingCost))
                        {
                            GameCore.Event.Fire(this, ChangeStateEventArgs.Create(typeof(WorldMapSelectSubBuilding), new WorldMapSelectSubBuilding.Preset()
                            {
                                posIndex = preset.posIndex, position = preset.position, masterTid = buildData.Id, isMainBuildingProcess = true
                            }));
                        }
                    }
                    else if (buildData.IsSubBuilding)
                    {
                        if (preset.selectAction != null)
                        {
                            preset.selectAction(buildData);
                        }
                    }
                });
            }
Exemplo n.º 5
0
        private void UpdateBuildingListData()
        {
            dataPreset.Clear();

            // 建物顯示排序預設為ID遞增排序,但是已解鎖項目會再排在前段,後段為未解鎖
            // 目前使用中建物會顯示在最前面
            var buildData = GameCore.DataTable.GetDataTable <BuildingData>().GetDataRows(delegate(BuildingData building)
            {
                return(building.ui_type == (int)CurDisplayType);
            });

            buildData = buildData.OrderBy(data => !data.IsUnlocked).ThenBy(data => data.Id != usingMasterTid).ThenBy(data => data.Id).ToArray();

            for (int i = 0; i < buildData.Length; i++)
            {
                UIBuildingCardPreset preset = ReferencePool.Acquire <UIBuildingCardPreset>();
                preset.buildID      = buildData[i].Id;
                preset.nonUsingCost = nonUsingCost;
                preset.isUsing      = buildData[i].Id == usingMasterTid;
                preset.posIndex     = worldMapPreset.posIndex;
                preset.position     = worldMapPreset.position;
                dataPreset.Add(preset);
            }
        }