Beispiel #1
0
        private UIRadialChart CreateRadialChart(int level)
        {
            UIRadialChart rc = AddUIComponent <UIRadialChart>();

            rc.isEnabled        = true;
            rc.isVisible        = true;
            rc.name             = "EmploymentChartLevel" + level;
            rc.size             = chartSize;
            rc.relativePosition = new Vector2(chartPadding + (level % 2 * (rc.size.x + chartSeparator)), chartPadding + (level / 2 * (rc.size.y + chartSeparator)));
            rc.zOrder           = 2;
            rc.spriteName       = "PieChartWhiteBg";

            rc.AddSlice();
            UIRadialChart.SliceSettings slice0 = rc.GetSlice(0);
            Color32 color = JobsUtils.educationLevelColors[level];

            slice0.outterColor = color;
            slice0.innerColor  = color;

            rc.AddSlice();
            UIRadialChart.SliceSettings slice1 = rc.GetSlice(1);
            Color32 color2 = new Color32(132, 110, 110, 255);

            slice1.outterColor = color2;
            slice1.innerColor  = color2;

            return(rc);
        }
Beispiel #2
0
        public static UIRadialChart CreateTwoSlicedRadialChart(UIComponent parent, string name)
        {
            UIRadialChart radialChart = parent.AddUIComponent <UIRadialChart>();

            radialChart.name = name;

            radialChart.size       = new Vector3(50f, 50f);
            radialChart.spriteName = "PieChartBg";

            radialChart.AddSlice();
            UIRadialChart.SliceSettings slice = radialChart.GetSlice(0);
            Color32 color = new Color32(229, 229, 229, 128);

            slice.outterColor = color;
            slice.innerColor  = color;

            radialChart.AddSlice();
            UIRadialChart.SliceSettings slice1 = radialChart.GetSlice(1);
            Color32 color1 = new Color32(178, 178, 178, 128);

            slice1.outterColor = color1;
            slice1.innerColor  = color1;

            return(radialChart);
        }
Beispiel #3
0
        public override void Awake()
        {
            resourceBars   = new Dictionary <ImmaterialResourceManager.Resource, UIProgressBar>();
            resourceLabels = new Dictionary <ImmaterialResourceManager.Resource, UILabel>();

            for (var i = 0; i < 20; i += 1)
            {
                var res = (ImmaterialResourceManager.Resource)i;
                var bar = AddUIComponent <UIProgressBar>();
                bar.backgroundSprite = "LevelBarBackground";
                bar.progressSprite   = "LevelBarForeground";
                bar.progressColor    = Color.green;
                resourceBars.Add(res, bar);
                var label = AddUIComponent <UILabel>();
                label.text      = Localization.Get(LocalizationCategory.BuildingInfo, res.ToString());
                label.textScale = 0.5f;
                label.size      = new Vector2(100, 20);
                resourceLabels.Add(res, label);
            }

            pollutionBar = AddUIComponent <UIProgressBar>();
            pollutionBar.backgroundSprite = "LevelBarBackground";
            pollutionBar.progressSprite   = "LevelBarForeground";
            pollutionBar.progressColor    = Color.red;
            pollutionLabel           = AddUIComponent <UILabel>();
            pollutionLabel.text      = Localization.Get(LocalizationCategory.BuildingInfo, "Pollution");
            pollutionLabel.textScale = 0.5f;
            pollutionLabel.size      = new Vector2(100, 20);

            serviceLabel = AddUIComponent <UILabel>();
            serviceBar   = AddUIComponent <UIProgressBar>();

            educationLabel = AddUIComponent <UILabel>();
            educationBar   = AddUIComponent <UIProgressBar>();

            happyLabel      = AddUIComponent <UILabel>();
            _mCustomMessage = AddUIComponent <UILabel>();
            happyBar        = AddUIComponent <UIProgressBar>();

            buildingNames.Clear();
            LoadTextFiles();

            descriptionLabel  = AddUIComponent <UILabel>();
            descriptionButton = AddUIComponent <UIButton>();
            _rChart           = CreateExampleTwoSlicedRadialChart(this, "Chart name");
            //_rChart.position = new Vector3(25, 250);


            base.Awake();
        }
Beispiel #4
0
        public static UIRadialChart CreateExampleTwoSlicedRadialChart(UIComponent parent, string name)
        {
            UIRadialChart radialChart = parent.AddUIComponent <UIRadialChart>();

            radialChart.name = name;

            radialChart.size       = new Vector3(150f, 150f);
            radialChart.spriteName = "PieChartBg";

            radialChart.AddSlice();
            UIRadialChart.SliceSettings slice = radialChart.GetSlice(0);
            Color32 colorYellow = new Color32(255, 255, 0, 128);

            slice.outterColor = colorYellow;
            slice.innerColor  = colorYellow;

            radialChart.AddSlice();
            UIRadialChart.SliceSettings slice1 = radialChart.GetSlice(1);
            Color32 colorRed = new Color32(255, 0, 0, 128);

            slice1.outterColor = colorRed;
            slice1.innerColor  = colorRed;


            radialChart.AddSlice();
            UIRadialChart.SliceSettings slice2 = radialChart.GetSlice(2);
            Color32 colorGreen = new Color32(0, 255, 0, 128);

            slice2.outterColor = colorGreen;
            slice2.innerColor  = colorGreen;



            radialChart.SetValues(0.2f, 0.3f, 0.5f);
            radialChart.tooltip = "Some message when hover the chart";
            return(radialChart);
        }
        /// <summary>
        /// create patch for OutsideConnectionsInfoViewPanel.UpdatePanel
        /// </summary>
        public static void CreateUpdatePanelPatch()
        {
            // get the OutsideConnectionsInfoViewPanel panel (displayed when the user clicks on the Outside Connections info view button)
            OutsideConnectionsInfoViewPanel ocPanel = UIView.library.Get <OutsideConnectionsInfoViewPanel>(typeof(OutsideConnectionsInfoViewPanel).Name);

            if (ocPanel == null)
            {
                Debug.LogError("Unable to find [OutsideConnectionsInfoViewPanel].");
                return;
            }

            // find import total label
            string componentName = "ImportTotal";

            _importTotalLabel = ocPanel.Find <UILabel>(componentName);
            if (_importTotalLabel == null)
            {
                Debug.LogError($"Unable to find label [{componentName}] on [OutsideConnectionsInfoViewPanel].");
                return;
            }

            // find export total label
            componentName     = "ExportTotal";
            _exportTotalLabel = ocPanel.Find <UILabel>(componentName);
            if (_exportTotalLabel == null)
            {
                Debug.LogError($"Unable to find label [{componentName}] on [OutsideConnectionsInfoViewPanel].");
                return;
            }

            // find import chart
            componentName = "ImportChart";
            _importChart  = ocPanel.Find <UIRadialChart>(componentName);
            if (_importChart == null)
            {
                Debug.LogError($"Unable to find chart [{componentName}] on [OutsideConnectionsInfoViewPanel].");
                return;
            }

            // find export chart
            componentName = "ExportChart";
            _exportChart  = ocPanel.Find <UIRadialChart>(componentName);
            if (_exportChart == null)
            {
                Debug.LogError($"Unable to find chart [{componentName}] on [OutsideConnectionsInfoViewPanel].");
                return;
            }

            // get the original UpdatePanel method
            MethodInfo original = typeof(OutsideConnectionsInfoViewPanel).GetMethod("UpdatePanel", BindingFlags.Instance | BindingFlags.NonPublic);

            if (original == null)
            {
                Debug.LogError($"Unable to find OutsideConnectionsInfoViewPanel.UpdatePanel method.");
                return;
            }

            // find the Prefix method
            MethodInfo prefix = typeof(OutsideConnectionsInfoViewPanelPatch).GetMethod("Prefix", BindingFlags.Static | BindingFlags.Public);

            if (prefix == null)
            {
                Debug.LogError($"Unable to find OutsideConnectionsInfoViewPanelPatch.Prefix method.");
                return;
            }

            // create the patch
            ExcludeMail.harmony.Patch(original, new HarmonyMethod(prefix), null, null);
        }