示例#1
0
        private string GetButtonName(PrefabInfo info)
        {
            if (info.GetAI() is ExtractingFacilityAI)
            {
                BuildingInfo bi = info as BuildingInfo;

                if (bi.name.Contains("Beech"))
                {
                    return(bi.name.Replace("Beech", "Alder"));
                }
                if (bi.name.Contains("Conifer"))
                {
                    return(bi.name.Replace("Conifer", "Alder"));
                }
                if (bi.name.Contains("Orange"))
                {
                    return(bi.name.Replace("Orange", "Apple"));
                }
                if (bi.name.Contains("Pear"))
                {
                    return(bi.name.Replace("Pear", "Apple"));
                }
                if (bi.name.Contains("Green House"))
                {
                    return(bi.name.Replace("Green House", "Apple"));
                }
            }
            return(info.name);
        }
示例#2
0
        public static string GetLocalizedTooltip(Asset asset, PrefabInfo prefab, string title)
        {
            MilestoneInfo unlockMilestone = prefab.GetUnlockMilestone();

            string text = TooltipHelper.Format(new string[]
            {
                LocaleFormatter.Title,
                title,
                LocaleFormatter.Sprite,
                (!string.IsNullOrEmpty(prefab.m_InfoTooltipThumbnail)) ? prefab.m_InfoTooltipThumbnail : prefab.name,
                LocaleFormatter.Text,
                (asset.findIt2Description + Asset.GetLocalizedDescription(prefab)),
                LocaleFormatter.Locked,
                (!ToolsModifierControl.IsUnlocked(unlockMilestone)).ToString()
            });

            ToolsModifierControl.GetUnlockingInfo(unlockMilestone, out string unlockDesc, out string currentValue, out string targetValue, out string progress, out string locked);

            string addTooltip = TooltipHelper.Format(new string[]
            {
                LocaleFormatter.LockedInfo,
                locked,
                LocaleFormatter.UnlockDesc,
                unlockDesc,
                LocaleFormatter.UnlockPopulationProgressText,
                progress,
                LocaleFormatter.UnlockPopulationTarget,
                targetValue,
                LocaleFormatter.UnlockPopulationCurrent,
                currentValue
            });

            text = TooltipHelper.Append(text, addTooltip);
            PrefabAI aI = prefab.GetAI();

            if (aI != null)
            {
                text = TooltipHelper.Append(text, aI.GetLocalizedTooltip());
            }

            if (prefab is PropInfo || prefab is TreeInfo)
            {
                text = TooltipHelper.Append(text, TooltipHelper.Format(new string[]
                {
                    LocaleFormatter.Cost,
                    LocaleFormatter.FormatCost(prefab.GetConstructionCost(), false)
                }));
            }

            return(text);
        }
        /// <summary>
        /// When the checkbox is set
        /// Attempts to set the Prefab AI to the indicated type (if appropriate)
        /// </summary>
        private void ApplyNewAI(UIComponent ui, UIMouseEventParameter e)
        {
            sem.WaitOne();

            var confirmPanel = UIView.library.ShowModal <ConfirmPanel>("ConfirmPanel", (UIComponent component, int result) =>
            {
                if (result != -1)
                {
                    if (prefabInfo.GetAI().GetType().FullName != meowUI.selectAIDropDown.selectedValue)
                    {
                        // remove old ai
                        var oldAI = prefabInfo.gameObject.GetComponent <PrefabAI>();
                        UnityEngine.Object.DestroyImmediate(oldAI);

                        // add new ai
                        var newAIInfo = meowUI.SelectedAIInfo;
                        if (newAIInfo != null)
                        {
                            var newAI = (PrefabAI)prefabInfo.gameObject.AddComponent(newAIInfo.type);
                            TryCopyAttributes(oldAI, newAI, result == 0);
                            prefabInfo.InitializePrefab();
                            meowUI.PrefabInfo = prefabInfo;
                        }
                        else
                        {
                            Debug.LogError("New AI Info could not be found.");
                        }
                    }
                }
                sem.Release();
            });

            confirmPanel.SetMessage("Copy all attributes", "Copy only visible attributes or all attributes? Only copy all attributes if you know what you are doing.");
            confirmPanel.Find <UIButton>("Yes").text = "All";
            confirmPanel.Find <UIButton>("No").text  = "Only visible";
        }
 private void OnEditPrefabChanged(PrefabInfo info)
 {
     var ai = info.GetAI();
     if (ai != null)
         m_selectAIPanel.value = ai.GetType().FullName;
 }