Exemplo n.º 1
0
        public static void setup(Society soc)
        {
            activeSociety = soc;
            //Person ss = activeSociety.getSovereign();

            foreach (Person p in activeSociety.people)
            {
                world.prefabStore.getGraphicalSlot(p);
                if (p.getLocation() == null)
                {
                    continue;
                }
            }

            foreach (Person p in activeSociety.people)
            {
                Province pp = p.getLocation().province;
                if (!loadedPlaceholders.ContainsKey(pp))
                {
                    GraphicalSlot ds = world.prefabStore.getGraphicalSlotPlaceholder(pp.name);
                    originalScale = ds.gameObject.transform.localScale;

                    //if (ss != null && ss.getLocation().province.name == pp.name)
                    //{
                    //ds.layerBack.enabled = false;
                    //ds.border.enabled = false;
                    //}

                    ds.border.enabled   = false;
                    ds.layerBack.sprite = world.textureStore.emptyDukeSlot;
                    loadedPlaceholders.Add(pp, ds);
                }
            }
        }
        public GraphicalSlot getGraphicalSlotPlaceholder(string title)
        {
            GameObject    obj      = Instantiate(prefabSlot) as GameObject;
            GraphicalSlot specific = obj.GetComponent <GraphicalSlot>();

            specific.world = world;

            specific.setToPlaceholder(title);
            return(specific);
        }
Exemplo n.º 3
0
        public GraphicalSlot getGraphicalSlot(Person p)
        {
            GameObject    obj      = Instantiate(prefabSlot) as GameObject;
            GraphicalSlot specific = obj.GetComponent <GraphicalSlot>();

            GraphicalSociety.loadedSlots.Add(specific);
            specific.world = world;

            specific.setTo(p);
            return(specific);
        }
Exemplo n.º 4
0
        public static void setup(Society soc)
        {
            activeSociety = soc;
            foreach (Person p in activeSociety.people)
            {
                GraphicalSlot slot = world.prefabStore.getGraphicalSlot(p);
            }

            if (loadedSlots.Count != 0)
            {
                refresh(activeSociety.people[0]);
            }
        }
Exemplo n.º 5
0
        public void clickOnSociety()
        {
            Vector3       pos  = Input.mousePosition;
            double        dist = 0;
            GraphicalSlot best = null;

            foreach (GraphicalSlot slot in GraphicalSociety.loadedSlots)
            {
                Vector3 slotLoc = world.outerCamera.WorldToScreenPoint(slot.transform.position);
                double  d       = (slotLoc - pos).sqrMagnitude;
                if (best == null || d < dist)
                {
                    dist = d;
                    best = slot;
                }
            }
            //GraphicalSociety.focus = best.inner;
            GraphicalSociety.refresh(best.inner);
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
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);
        }