Example #1
0
        private void UpdateMapTooltip()
        {
            if (Game.MapMode != Game.MapModes.Political
                //&& Date.Today.isDivisible(Options.MapRedrawRate)
                )
            {
                Game.redrawMapAccordingToMapMode();
            }

            if (!EventSystem.current.IsPointerOverGameObject())// don't force map tooltip if mouse hover UI
            {
                if (Game.MapMode == Game.MapModes.PopulationChange)
                {
                    int meshNumber      = Province.FindByCollider(SelectionComponent.getRayCastMeshNumber());
                    var hoveredProvince = World.FindProvince(meshNumber);
                    if (hoveredProvince == null)// || hoveredProvince is Province
                    {
                        tooltip.Hide();
                    }
                    else
                    {
                        if (Game.selectedProvince == null)
                        {
                            tooltip.SetTextDynamic(() =>
                                                   "Country: " + hoveredProvince.Country + ", population (men): " + hoveredProvince.Country.Provinces.AllPops.Sum(x => x.population.Get())
                                                   + "\n" + hoveredProvince.Country.Provinces.AllPopsChanges
                                                   .Where(y => y.Key == null || y.Key is Staff || (y.Key is Province && (y.Key as Province).Country != hoveredProvince.Country))
                                                   .ToString("\n", "Total change: "));
                        }
                        else
                        {
                            tooltip.SetTextDynamic(() =>
                                                   "Province: " + hoveredProvince.ShortName + ", population (men): " + hoveredProvince.AllPops.Sum(x => x.population.Get())
                                                   + "\n" + hoveredProvince.AllPopsChanges
                                                   .Where(y => y.Key == null || y.Key is Province || y.Key is Staff)
                                                   .ToString("\n", "Total change: ")
                                                   );
                        }
                        tooltip.Show();
                    }
                }
                else if (Game.MapMode == Game.MapModes.PopulationDensity)
                {
                    int meshNumber      = Province.FindByCollider(SelectionComponent.getRayCastMeshNumber());
                    var hoveredProvince = World.FindProvince(meshNumber);
                    if (hoveredProvince == null)
                    {
                        tooltip.Hide();
                    }
                    else
                    {
                        tooltip.SetTextDynamic(() =>
                                               "Province: " + hoveredProvince.ShortName + ", population (men): " + hoveredProvince.AllPops.Sum(x => x.population.Get())
                                               + "\nChange: " + hoveredProvince.AllPopsChanges
                                               .Where(y => y.Key == null || y.Key is Province || y.Key is Staff).Sum(x => x.Value)
                                               + "\nOverpopulation: " + hoveredProvince.GetOverpopulation()
                                               );
                        tooltip.Show();
                    }
                }
                else if (Game.MapMode == Game.MapModes.Prosperity) //prosperity wars
                {
                    int meshNumber      = Province.FindByCollider(SelectionComponent.getRayCastMeshNumber());
                    var hoveredProvince = World.FindProvince(meshNumber);
                    if (hoveredProvince == null)
                    {
                        tooltip.Hide();
                    }
                    else
                    {
                        tooltip.SetTextDynamic(() =>
                                               "Province: " + hoveredProvince.ShortName + ", population (men): " + hoveredProvince.AllPops.Sum(x => x.population.Get())
                                               + "\nAv. needs fulfilling: " + hoveredProvince.AllPops.GetAverageProcent(x => x.needsFulfilled));
                        tooltip.Show();
                    }
                }
            }
            else
            {
                if (tooltip.IsInside()) // hide only if it's that tooltip is shown
                {
                    tooltip.Hide();
                }
            }
        }
Example #2
0
        private void RefreshMap()
        {
            if (Game.getMapMode() != 0
                //&& Date.Today.isDivisible(Options.MapRedrawRate)
                )
            {
                Game.redrawMapAccordingToMapMode(Game.getMapMode());
            }


            if (Game.getMapMode() == 4)
            {
                int meshNumber      = Province.FindByCollider(SelectionComponent.getRayCastMeshNumber());
                var hoveredProvince = World.FindProvince(meshNumber);
                if (hoveredProvince == null)
                {
                    GetComponent <ToolTipHandler>().Hide();
                }
                else
                {
                    if (Game.selectedProvince == null)
                    {
                        GetComponent <ToolTipHandler>().SetTextDynamic(() =>
                                                                       "Country: " + hoveredProvince.Country + ", population (men): " + hoveredProvince.Country.GetAllPopulation().Sum(x => x.population.Get())
                                                                       + "\n" + hoveredProvince.Country.getAllPopulationChanges()
                                                                       .Where(y => y.Key == null || y.Key is Staff || (y.Key is Province && (y.Key as Province).Country != hoveredProvince.Country))
                                                                       .getString("\n", "Total change: "));
                    }
                    else
                    {
                        GetComponent <ToolTipHandler>().SetTextDynamic(() =>
                                                                       "Province: " + hoveredProvince.ShortName + ", population (men): " + hoveredProvince.GetAllPopulation().Sum(x => x.population.Get())
                                                                       + "\n" + hoveredProvince.getAllPopulationChanges()
                                                                       .Where(y => y.Key == null || y.Key is Province || y.Key is Staff)
                                                                       .getString("\n", "Total change: ")
                                                                       );
                    }
                    GetComponent <ToolTipHandler>().Show();
                }
            }
            else if (Game.getMapMode() == 5)
            {
                int meshNumber      = Province.FindByCollider(SelectionComponent.getRayCastMeshNumber());
                var hoveredProvince = World.FindProvince(meshNumber);
                if (hoveredProvince == null)
                {
                    GetComponent <ToolTipHandler>().Hide();
                }
                else
                {
                    GetComponent <ToolTipHandler>().SetTextDynamic(() =>
                                                                   "Province: " + hoveredProvince.ShortName + ", population (men): " + hoveredProvince.GetAllPopulation().Sum(x => x.population.Get())
                                                                   + "\nChange: " + hoveredProvince.getAllPopulationChanges()
                                                                   .Where(y => y.Key == null || y.Key is Province || y.Key is Staff).Sum(x => x.Value)
                                                                   + "\nOverpopulation: " + hoveredProvince.GetOverpopulation()
                                                                   );
                    GetComponent <ToolTipHandler>().Show();
                }
            }
            else if (Game.getMapMode() == 6) //prosperity wars
            {
                int meshNumber      = Province.FindByCollider(SelectionComponent.getRayCastMeshNumber());
                var hoveredProvince = World.FindProvince(meshNumber);
                if (hoveredProvince == null)
                {
                    GetComponent <ToolTipHandler>().Hide();
                }
                else
                {
                    GetComponent <ToolTipHandler>().SetTextDynamic(() =>
                                                                   "Province: " + hoveredProvince.ShortName + ", population (men): " + hoveredProvince.GetAllPopulation().Sum(x => x.population.Get())
                                                                   + "\nAv. needs fulfilling: " + hoveredProvince.GetAllPopulation().GetAverageProcent(x => x.needsFulfilled));
                    GetComponent <ToolTipHandler>().Show();
                }
            }
        }