Пример #1
0
 /// <summary>
 /// Generates the kingdom data for each NPC -
 /// Tells the NPC which settlement and kingdom it belongs too, as well as its position in the settlement
 /// </summary>
 /// <param name="npcs"></param>
 /// <param name="settlement"></param>
 private void GenerateSettlementNPCKingdomData(List <NPC> npcs, Settlement settlement)
 {
     foreach (NPC npc in npcs)
     {
         KingdomHierarchy rank = KingdomHierarchy.Peasant;
         House            h    = npc.NPCData.House as House;
         if (h is Castle) //Check if the house is a Castle
         {
             //If this is a capital, then this NPC is a monarch
             if (settlement.SettlementType == SettlementType.CAPITAL)
             {
                 rank = KingdomHierarchy.Monarch;
             }
             else
             {//If not, they're a noble
                 rank = KingdomHierarchy.Noble;
             }
             //Either way, they'll be a leader of this settlement
             settlement.AddLeader(npc);
         }
         else if (h is Hold)
         {
             rank = KingdomHierarchy.LordLady;
             settlement.AddLeader(npc);
         }
         else if (h is VillageHall)
         {
             rank = KingdomHierarchy.Mayor;
             settlement.AddLeader(npc);
         }
         else
         {
             if (settlement.SettlementType == SettlementType.CAPITAL)
             {
                 rank = KingdomHierarchy.Citizen; //All NPCs in capital are citizens
             }
             else
             {
                 //Citizen or peasant based on house value
                 float cutoff = 150; //The cutoff value. If house is worth less than this, peasant
                 if (h.Value < cutoff)
                 {
                     rank = KingdomHierarchy.Peasant;
                 }
                 else
                 {
                     rank = KingdomHierarchy.Citizen;
                 }
             }
         }
         //Create and appl.
         NPCKingdomData kData = new NPCKingdomData(rank, settlement.KingdomID, settlement.SettlementID);
         npc.SetKingdomData(kData);
     }
 }
Пример #2
0
    private void GenerateNPCPersonalities(List <NPC> npcs)
    {
        //iterate all npcs
        foreach (NPC npc in npcs)
        {
            //Personality is random
            KingdomHierarchy rank    = npc.NPCKingdomData.Rank;
            float            loyalty = 1;
            float            wealth  = 0;
            if (rank == KingdomHierarchy.Monarch)
            {
                wealth  = 1;
                loyalty = 1;
            }
            else if (rank == KingdomHierarchy.Noble)
            {
                loyalty = Mathf.Clamp(GenerationRan.GaussianFloat(0.8f, 0.2f), 0, 1);
                wealth  = Mathf.Clamp(GenerationRan.GaussianFloat(0.8f, 0.2f), 0, 1);
            }
            else if (rank == KingdomHierarchy.LordLady)
            {
                loyalty = Mathf.Clamp(GenerationRan.GaussianFloat(0.7f, 0.3f), 0, 1);
                wealth  = Mathf.Clamp(GenerationRan.GaussianFloat(0.7f, 0.3f), 0, 1);
            }
            else if (rank == KingdomHierarchy.Knight || rank == KingdomHierarchy.Mayor)
            {
                loyalty = Mathf.Clamp(GenerationRan.GaussianFloat(0.7f, 0.4f), 0, 1);
                wealth  = Mathf.Clamp(GenerationRan.GaussianFloat(0.7f, 0.3f), 0, 1);
            }
            else if (rank == KingdomHierarchy.Citizen)
            {
                loyalty = Mathf.Clamp(GenerationRan.GaussianFloat(0.6f, 0.6f), 0, 1);
                wealth  = Mathf.Clamp(GenerationRan.GaussianFloat(0.5f, 0.3f), 0, 1);
            }
            else
            {
                loyalty = Mathf.Clamp(GenerationRan.GaussianFloat(0.5f, 0.5f), 0, 1);
                wealth  = Mathf.Clamp(GenerationRan.GaussianFloat(0.3f, 0.3f), 0, 1);
            }

            float kindness  = Mathf.Clamp(GenerationRan.GaussianFloat(0.6f, 0.4f), 0, 1);
            float agression = Mathf.Clamp(GenerationRan.GaussianFloat(0.6f, 0.4f), 0, 1);
            float greed     = Mathf.Clamp(GenerationRan.GaussianFloat(0.6f, 0.4f), 0, 1);

            EntityPersonality pers = new EntityPersonality(agression, kindness, loyalty, greed, wealth);
            npc.SetPersonality(pers);
        }
    }
Пример #3
0
    private void GenerateNPCJobs(List <NPC> npcs, Settlement set)
    {
        List <NPCJob> workJobs = new List <NPCJob>();
        Dictionary <KingdomHierarchy, List <NPCJob> > rankedJobs = new Dictionary <KingdomHierarchy, List <NPCJob> >();

        //Iterate all buildings and select work buildings
        foreach (Building b in set.Buildings)
        {
            if (b is IWorkBuilding)
            {
                //Get the jobs for each building
                NPCJob[] js = (b as IWorkBuilding).GetWorkData.BuildingJobs;
                foreach (NPCJob j in js)
                {
                    if (!rankedJobs.ContainsKey(j.RequiredRank))
                    {
                        rankedJobs.Add(j.RequiredRank, new List <NPCJob>());
                    }
                    rankedJobs[j.RequiredRank].Add(j);
                }
            }
        }
        Debug.Log("Settlement " + set.ToString() + " has " + workJobs.Count + " jobs", Debug.ENTITY_GENERATION);


        foreach (NPC npc in npcs)
        {
            KingdomHierarchy rank = npc.NPCKingdomData.Rank;
            if (!rankedJobs.ContainsKey(rank))
            {
                continue;
            }
            if (rankedJobs[rank].Count == 0)
            {
                continue;
            }

            NPCJob job = rankedJobs[rank][0];
            rankedJobs[rank].Remove(job);
            npc.NPCData.SetJob(job);
        }
    }
Пример #4
0
 public NPCJobMarketStall(string title, IWorkBuilding workLocation, WorldObjectData marketStall, KingdomHierarchy rankReq = KingdomHierarchy.Citizen) : base(title, workLocation, rankReq)
 {
 }
Пример #5
0
 public NPCKingdomData(KingdomHierarchy rank, int kingdomID, int settlementID)
 {
     Rank         = rank;
     KingdomID    = kingdomID;
     SettlementID = settlementID;
 }
Пример #6
0
 public NPCJob(string title, IWorkBuilding workLocation, KingdomHierarchy rankReq = KingdomHierarchy.Citizen)
 {
     Title        = title;
     WorkLocation = workLocation;
     RequiredRank = rankReq;
 }