Ejemplo n.º 1
0
 public Person getSuperiorIfAny()
 {
     foreach (Title t in titles)
     {
         if (t is Title_ProvinceRuler)
         {
             return(this.society.getSovereign());
         }
     }
     //Am not a duke
     foreach (Title t in society.titles)
     {
         if (t is Title_Sovereign)
         {
             return(null);
         }
         if (t is Title_ProvinceRuler)
         {
             if (((Title_ProvinceRuler)t).province == this.getLocation().province)
             {
                 return(t.heldBy);
             }
         }
     }
     //Am neither duke nor sovereign, nor do I live in a duke's province
     return(society.getSovereign());
 }
Ejemplo n.º 2
0
 public Person getSuperiorInSociety(Society society)
 {
     if (society.getCapital() != null && society.getCapital().province == this.province)
     {
         return(society.getSovereign());
     }
     foreach (Title t in society.titles)
     {
         if (t is Title_ProvinceRuler)
         {
             Title_ProvinceRuler t2 = (Title_ProvinceRuler)t;
             if (t2.province == this.province)
             {
                 return(t2.heldBy);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        public void populate(Society soc, Person agent)
        {
            this.agent               = agent;
            societyName.text         = soc.getName();
            textVotingIssue.text     = soc.voteSession.issue.ToString();
            textVotingIssueDesc.text = soc.voteSession.issue.getLargeDesc();
            textProposer.text        = "Proposed by: " + soc.voteSession.issue.proposer.getFullName();
            if (soc.voteSession.issue.proposer != null)
            {
                World.log("Proposer: " + soc.voteSession.issue.proposer.getFullName());
                World.log("Text " + textProposerVote);
                textProposerVote.text = "Voting For: " + soc.voteSession.issue.proposer.getVote(soc.voteSession).info(soc.voteSession.issue);
                proposerBack.sprite   = soc.voteSession.issue.proposer.getImageBack();
                proposerMid.sprite    = soc.voteSession.issue.proposer.getImageMid();
                proposerFore.sprite   = soc.voteSession.issue.proposer.getImageFore();
                proposerBorder.sprite = soc.voteSession.issue.proposer.getImageBorder();
            }
            else
            {
                Person arbitrary = soc.getSovereign();
                if (arbitrary == null)
                {
                    arbitrary = soc.people[0];
                }
                if (arbitrary != null)
                {
                    textProposerVote.text = "";
                    proposerBack.sprite   = arbitrary.getImageBack();
                    proposerMid.sprite    = arbitrary.getImageMid();
                    proposerFore.sprite   = arbitrary.getImageFore();
                    proposerBorder.sprite = arbitrary.getImageBorder();
                }
            }
            foreach (Person p in soc.people)
            {
                PopVoterBar bar = world.prefabStore.getVoterBar(p);
                //bar.gameObject.transform.parent = this.gameObject.transform;
                voterBars.Add(bar);
            }
            foreach (VoteOption opt in soc.voteSession.issue.options)
            {
                PopOptBar bar = world.prefabStore.getVoteOptBar(opt, soc.voteSession);
                //bar.gameObject.transform.parent = this.gameObject.transform;
                voteOptBars.Add(bar);
            }
            viewSelf.gameObject.SetActive(false);
            if (agent != null)
            {
                textAgentName.text = "Interacting with:\n" + agent.getFullName();
                agentBack.sprite   = agent.getImageBack();
                agentBorder.sprite = agent.getImageBorder();
                agentFore.sprite   = agent.getImageFore();
                agentMid.sprite    = agent.getImageMid();
                textAgentDesc.text = "You may use the voter's liking for " + agent.getFullName() + " to sway their votes one way or another, spending this liking as political capital.";
            }
            else
            {
                agentBack.sprite   = world.textureStore.icon_mask;
                agentMid.sprite    = world.textureStore.icon_mask;
                agentBorder.sprite = world.textureStore.slotCount;
                agentFore.sprite   = world.textureStore.icon_mask;
                textAgentName.text = "Interacting without character";
                textAgentDesc.text = "If you interact with a society with an enthralled noble, or use an agent, you can spend the liking the voters have towards them to sway their votes.";
            }


            if (World.staticMap.param.option_useAdvancedGraphics == 1 && agent != null)
            {
                Person p = agent;
                if (p.isMale)
                {
                    agentMid.sprite   = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_faces[p.imgAdvFace];
                    agentEyes.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_eyes[p.imgAdvEyes];
                    agentMouth.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_mouths[p.imgAdvMouth];
                    agentHair.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_hair[p.imgAdvHair];
                    agentJewel.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].m_jewels[p.imgAdvJewel];
                }
                else
                {
                    agentMid.sprite   = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_faces[p.imgAdvFace];
                    agentEyes.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_eyes[p.imgAdvEyes];
                    agentMouth.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_mouths[p.imgAdvMouth];
                    agentHair.sprite  = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_hair[p.imgAdvHair];
                    agentJewel.sprite = p.map.world.textureStore.cultures[p.culture.graphicsIndex].f_jewels[p.imgAdvJewel];
                }
                agentFore.sprite = p.getImageFore();
            }
            else
            {
                agentEyes.sprite  = World.self.textureStore.person_advClear;
                agentMouth.sprite = World.self.textureStore.person_advClear;
                agentHair.sprite  = World.self.textureStore.person_advClear;
                agentJewel.sprite = World.self.textureStore.person_advClear;
            }
            lastPos = World.self.ui.uiInputs.scrollwheelTracking;

            sess = soc.voteSession;
            checkData();

            if (agent != null && agent == soc.map.overmind.enthralled)
            {
                bGoToSelf();
                viewSelf.gameObject.SetActive(true);
            }
        }
        public override void castInner(Map map, Person person)
        {
            ThreatItem item = person.getGreatestThreat();

            if (item == null)
            {
                return;
            }

            Society soc = person.society;
            Person  sov = soc.getSovereign();

            if (sov == null)
            {
                return;
            }
            int    nAffected = 0;
            double totalV    = 0;
            double sovFear   = 0;

            foreach (ThreatItem ti in sov.threatEvaluations)
            {
                if (item.isSame(ti))
                {
                    sovFear = ti.threat;
                    break;
                }
            }
            foreach (Person p in soc.people)
            {
                double myFear = 0;
                foreach (ThreatItem ti in p.threatEvaluations)
                {
                    if (item.isSame(ti))
                    {
                        myFear = ti.threat;
                        break;
                    }
                }

                double deltaFear = myFear - sovFear;
                if (deltaFear <= 0)
                {
                    continue;
                }

                double deltaLiking = deltaFear * map.param.ability_denounceLeaderLikingMult;
                deltaLiking = Math.Min(deltaLiking, map.param.ability_denounceLeaderMax);

                p.getRelation(sov).addLiking(-deltaLiking, "Doesn't take threat of " + item.getTitle() + " seriously", map.turn);

                nAffected += 1;
                totalV    += deltaFear;
            }

            double avrg = 0;

            if (nAffected > 0)
            {
                avrg = totalV / nAffected;
            }
            map.world.prefabStore.popImgMsg(
                "You rally the people against " + sov.getFullName() + ", denouncing them as unable to defend the people against the threat of " + item.getTitle() + ".\n" +
                nAffected + " nobles agree, with an average liking change of of " + (int)(-avrg),
                map.world.wordStore.lookup("ABILITY_DENOUNCE_LEADER"));
        }
Ejemplo n.º 6
0
        public void takeLocationFromOther(SocialGroup att, SocialGroup def, Location taken)
        {
            World.log(att.getName() + " takes " + taken.getName() + " from " + def.getName());
            int  priority = MsgEvent.LEVEL_YELLOW;
            bool benefit  = !def.hasEnthralled();

            if (att.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_GREEN;
            }
            else if (def.hasEnthralled())
            {
                priority = MsgEvent.LEVEL_RED;
            }
            else
            {
                priority = MsgEvent.LEVEL_YELLOW;
            }


            turnMessages.Add(new MsgEvent(att.getName() + " takes " + taken.getName() + " from " + def.getName(), priority, benefit, taken.hex));

            if (taken.settlement != null)
            {
                if (taken.settlement.isHuman == false)
                {
                    taken.settlement = null;//Burn it down
                }
                else if (taken.settlement is Set_Ruins)
                {
                    //Nothing to do if you take ruins
                }
                else if (taken.settlement.title != null && taken.settlement.title.heldBy != null)
                {
                    Person lord = taken.settlement.title.heldBy;
                    if (att is Society)
                    {
                        Society socAtt = (Society)att;
                        lord.prestige *= param.combat_prestigeLossFromConquest;
                        if (socAtt.getSovereign() != null)
                        {
                            lord.getRelation(socAtt.getSovereign()).addLiking(param.person_likingFromBeingInvaded, "Their nation invaded mine", turn);
                        }
                        foreach (Title t in lord.titles)
                        {
                            t.heldBy = null;
                        }
                        lord.titles.Clear();


                        movePerson(lord, socAtt);
                    }
                    else
                    {
                        lord.die("Killed by " + att.getName() + " when " + taken.getName() + " fell", true);
                    }
                }
            }

            taken.soc = att;
            att.takeLocationFromOther(def, taken);

            bool hasRemainingTerritory = false;

            foreach (Location loc in locations)
            {
                if (loc.soc == def)
                {
                    hasRemainingTerritory = true;
                    break;
                }
            }
            if (!hasRemainingTerritory)
            {
                World.log("Last territory taken");
                addMessage(def.getName() + " has lost its last holdings to " + att.getName());

                /*
                 * if (att is Society && def is Society)
                 * {
                 *  Society sAtt = (Society)att;
                 *  Society sDef = (Society)def;
                 *  List<Person> toMove = new List<Person>();
                 *  foreach (Person p in sDef.people)
                 *  {
                 *      if (p.title_land == null)
                 *      {
                 *          toMove.Add(p);
                 *      }
                 *  }
                 *  foreach (Person p in toMove)
                 *  {
                 *      movePerson(p, sAtt);
                 *      addMessage(p.getFullName() + " is now part of the court of " + att.getName(), MsgEvent.LEVEL_GRAY, false);
                 *  }
                 * }
                 */
            }
        }