Пример #1
0
        public static void refreshDynamic(Person nfocus)
        {
            clear();

            List <GraphicalSlot> nodes = new List <GraphicalSlot>();

            foreach (Person p in activeSociety.people)
            {
                GraphicalSlot ds = p.outer;
                ds.targetEnabled = false;

                ds.gameObject.SetActive(true);
                nodes.Add(ds);
            }

            solver = new NewtonSolver <GraphicalSlot>(nodes, new AverageLikingMetric());

            state = viewState.DYNAMIC;
            resetHidden();
            refreshOffset();
        }
Пример #2
0
        public static void refreshUnlanded(Person nfocus)
        {
            clear();

            focus = (nfocus != null) ? nfocus : activeSociety.getSovereign();
            if (state != viewState.UNLANDED)
            {
                originalFocus = focus;
            }

            int n = 0;

            foreach (Person p in activeSociety.people)
            {
                if (p != focus && (p.title_land == null || p == originalFocus))
                {
                    n += 1;
                }
            }

            focus.outer.gameObject.SetActive(true);
            focus.outer.targetPosition = Vector3.zero;

            int i = 0;

            foreach (Person p in activeSociety.people)
            {
                if (p == focus || (p.title_land != null && p != originalFocus))
                {
                    continue;
                }

                GraphicalSlot ds = p.outer;

                float radius = 2.5f * zoom;
                float angle  = 6.28f / n * i;

                float x = Mathf.Cos(angle) * radius;
                float y = Mathf.Sin(angle) * radius;

                ds.gameObject.SetActive(true);
                ds.connection = focus.outer;

                RelObj rto   = focus.getRelation(p);
                RelObj rfrom = p.getRelation(focus);

                float to   = (float)rto.getLiking();
                float from = (float)rfrom.getLiking();

                ds.targetPosition = new Vector3(x, y, 0.0f);
                if (from < 0)
                {
                    ds.targetStartColor = Color.Lerp(ds.neutralColor, ds.badColor, -from / 100);
                }
                else
                {
                    ds.targetStartColor = Color.Lerp(ds.neutralColor, ds.goodColor, from / 100);
                }
                if (to < 0)
                {
                    ds.targetEndColor = Color.Lerp(ds.neutralColor, ds.badColor, -to / 100);
                }
                else
                {
                    ds.targetEndColor = Color.Lerp(ds.neutralColor, ds.goodColor, to / 100);
                }
                ds.targetStartColor.a = ds.targetEndColor.a = 0.5f;

                ds.upperRightText.text  = "liking for center: " + from.ToString("N0") + "%";
                ds.upperRightText.text += "\nliking from center: " + to.ToString("N0") + "%";
                ds.lowerRightText.text  = "suspicion for center: " + rfrom.suspicion.ToString("N0") + "%";
                ds.lowerRightText.text += "\nsuspicion from center: " + rto.suspicion.ToString("N0") + "%";

                i += 1;
            }

            state = viewState.UNLANDED;
            resetHidden();
            refreshOffset();
        }
Пример #3
0
        public static void refreshHierarchy(Person nfocus)
        {
            clear();

            Person ss = activeSociety.getSovereign();

            if (ss == null)
            {
                return;
            }

            focus = (state == viewState.HIERARCHY && nfocus != null) ? nfocus : ss;

            var tree = new Dictionary <GraphicalSlot, List <GraphicalSlot> >();

            foreach (Person p in activeSociety.people)
            {
                GraphicalSlot ds = null;
                if (p == ss)
                {
                    continue;
                }

                Person sp = p.getDirectSuperiorIfAny();
                if (sp != null)
                {
                    if (sp == ss)
                    {
                        if (!p.getIsProvinceRuler())
                        {
                            ds = loadedPlaceholders[p.getLocation().province];
                        }
                    }
                    else
                    {
                        ds = sp.outer;
                    }
                }
                else
                {
                    ds = loadedPlaceholders[p.getLocation().province];
                }

                if (ds == null)
                {
                    continue;
                }

                if (!tree.ContainsKey(ds))
                {
                    tree.Add(ds, new List <GraphicalSlot>());
                }

                tree[ds].Add(p.outer);
            }

            ss.outer.gameObject.SetActive(true);
            focus.outer.targetPosition = Vector3.zero;

            int n = tree.Count, i = 0;

            foreach (var pair in tree)
            {
                GraphicalSlot ds = pair.Key;

                double exponent = 1;
                if (i % 2 == 0)
                {
                    exponent = 1.6;
                }
                float radius = (float)(2.0f * Math.Pow(zoom, exponent));
                float angle  = 6.28f / n * i;

                float x = Mathf.Cos(angle) * radius;
                float y = Mathf.Sin(angle) * radius;


                ds.gameObject.SetActive(true);
                ds.connection = ss.outer;

                ds.targetPosition     = new Vector3(x, y, 0.0f);
                ds.targetStartColor   = ds.targetEndColor = ds.neutralColor;
                ds.targetStartColor.a = ds.targetEndColor.a = 0.5f;

                float n2 = pair.Value.Count, j = 0;
                foreach (GraphicalSlot ds2 in pair.Value)
                {
                    exponent = 0.8;
                    //if (i % 2 == 0) { exponent = 1.4; }
                    float radius2 = (float)(1.5 * Math.Pow(zoom, exponent));
                    //float spread  = (n2 > 4) ? 3.5f : 2.5f;
                    float spread = 4;
                    float angle2 = (angle - spread / 2) + spread / n2 * (j + 0.5f);

                    float x2 = Mathf.Cos(angle2) * radius2 + x;
                    float y2 = Mathf.Sin(angle2) * radius2 + y;

                    ds2.gameObject.SetActive(true);
                    //ds2.gameObject.transform.localScale = originalScale * 0.75f;
                    ds2.connection = ds;

                    ds2.targetPosition     = new Vector3(x2, y2, 0.0f);
                    ds2.targetStartColor   = ds2.targetEndColor = ds2.neutralColor;
                    ds2.targetStartColor.a = ds2.targetEndColor.a = 0.25f;

                    j += 1;
                }

                i += 1;
            }

            state = viewState.HIERARCHY;
            resetHidden();
            refreshOffset();
            world.ui.uiLeftPrimary.uiPerson.setTo(focus);
        }