Ejemplo n.º 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);
     }
 }