Exemplo n.º 1
0
        public static int GetItemQuantity(SettlementSize s, Random r)
        {
            if (s == SettlementSize.Hamlet)
            {
                return(1);
            }
            if (s == SettlementSize.Village)
            {
                return(r.Next(1, 5));
            }
            if (s == SettlementSize.Small_Town)
            {
                return(r.Next(1, 7));
            }
            if (s == SettlementSize.Large_Town)
            {
                return(r.Next(1, 9));
            }
            if (s == SettlementSize.Small_City)
            {
                return(r.Next(1, 11));
            }
            if (s == SettlementSize.Large_City)
            {
                return(r.Next(1, 13));
            }

            return(0);
        }
Exemplo n.º 2
0
    public Settlement(Faction faction, SettlementSize size, Cell cell, int population, bool isStartingArea = false)
    {
        Faction     = faction;
        Size        = size;
        Citizens    = new List <Entity>();
        _cell       = cell;
        _population = population;

        Name = SettlementPrefabStore.GenerateName();

        //todo just add 'New' or '2' or something to the name when it exists
        while (WorldData.Instance.Settlements.ContainsKey(Name))
        {
            Name = SettlementPrefabStore.GenerateName();
        }

        WorldData.Instance.Settlements.Add(Name, this);

        if (isStartingArea)
        {
            _areas = new Dictionary <Area, SettlementSection>();
            var area = _cell.Areas[1, 1];
            area.Settlement        = this;
            area.SettlementSection = new SettlementSection();
            _areas.Add(area, area.SettlementSection);
        }
        else
        {
            PickAreas();
        }
    }
Exemplo n.º 3
0
    public Settlement(SettlementSdo sdo)
    {
        if (sdo == null)
        {
            return;
        }

        if (!string.IsNullOrEmpty(sdo.FactionName))
        {
            Faction = WorldData.Instance.Factions[sdo.FactionName];
        }

        Size        = sdo.Size;
        Name        = sdo.Name;
        _cell       = WorldData.Instance.MapDictionary[sdo.CellId];
        _population = sdo.Population;
        _history    = sdo.History;

        Citizens = new List <Entity>();

        foreach (var id in sdo.CitizenIds)
        {
            Citizens.Add(WorldData.Instance.Entities[id]);
        }

        _areas = new Dictionary <Area, SettlementSection>();

        foreach (var id in sdo.AreaIds)
        {
            var splitId = id.Split(' ');

            var area = _cell.Areas[int.Parse(splitId[0]), int.Parse(splitId[1])];

            _areas.Add(new KeyValuePair <Area, SettlementSection>(area, area.SettlementSection));
        }
    }
Exemplo n.º 4
0
    public static SettlementPrefab GetSettlementPrefab(SettlementSize size)
    {
        var prefab = SettlementPrefabs[size][Random.Range(0, SettlementPrefabs[size].Count)];

        return(new SettlementPrefab(prefab));
    }
Exemplo n.º 5
0
        public void Generate(int sizeOption, int militaryOption, int religionOption, int churches)
        {
            rnd           = new Random(name.GetHashCode());
            this.churches = churches;

            Array sizes = Enum.GetValues(typeof(SettlementSize));

            if (sizeOption == 0)
            {
                size = (SettlementSize)sizes.GetValue(rnd.Next(sizes.Length));
            }
            else
            {
                size = (SettlementSize)(sizeOption - 1);
            }

            switch (size)
            {
            case SettlementSize.Hamlet:
                population = rnd.Next(1, 65);
                WealthInGP = rnd.Next((int)(200 * 0.75), (int)(200 * 1.5)); break;

            case SettlementSize.Village:
                population = rnd.Next(66, 250);
                WealthInGP = rnd.Next((int)(500 * 0.75), (int)(500 * 1.5)); break;

            case SettlementSize.Small_Town:
                population = rnd.Next(251, 2000);
                WealthInGP = rnd.Next((int)(1000 * 0.75), (int)(1000 * 1.5)); break;

            case SettlementSize.Large_Town:
                population = rnd.Next(2001, 10000);
                WealthInGP = rnd.Next((int)(2000 * 0.75), (int)(2000 * 1.5)); break;

            case SettlementSize.Small_City:
                population = rnd.Next(10001, 15000);
                WealthInGP = rnd.Next((int)(4000 * 0.75), (int)(4000 * 1.5)); break;

            case SettlementSize.Large_City:
                population = rnd.Next(15001, 40000);
                WealthInGP = rnd.Next((int)(8000 * 0.75), (int)(8000 * 1.5)); break;
            }

            Array miltarySizes = Enum.GetValues(typeof(MilitaryStrength));

            if (militaryOption == 0)
            {
                strength = (MilitaryStrength)miltarySizes.GetValue(rnd.Next(miltarySizes.Length));
            }
            else
            {
                strength = (MilitaryStrength)(militaryOption - 1);
            }

            double p = population / 100.0;

            switch (strength)
            {
            case MilitaryStrength.Weak: military = rnd.Next((int)(p * 2.5), (int)(p * 5)); break;

            case MilitaryStrength.Average: military = rnd.Next((int)(p * 5), (int)(p * 7)); break;

            case MilitaryStrength.Strong: military = rnd.Next((int)(p * 7), (int)(p * 15)); break;
            }

            guards    = new int[7]; guards[0] = 0;
            guards[1] = military * 40 / 100;
            guards[2] = military * 22 / 100;
            guards[3] = military * 18 / 100;
            guards[4] = military * 12 / 100;
            guards[5] = military * 6 / 100;
            guards[6] = military * 2 / 100;

            Array religionLvls = Enum.GetValues(typeof(ReligiousPresence));

            if (religionOption == 0)
            {
                religiousness = (ReligiousPresence)religionLvls.GetValue(rnd.Next(religionLvls.Length));
            }
            else
            {
                religiousness = (ReligiousPresence)(religionOption - 1);
            }

            switch (religiousness)
            {
            case ReligiousPresence.Weak:
                clergymen = rnd.Next((int)(p * 2), (int)(p * 7));
                priests   = rnd.Next((int)(clergymen * 0.01), (int)(clergymen * 0.02)); break;

            case ReligiousPresence.Average:
                clergymen = rnd.Next((int)(p * 7), (int)(p * 17));
                priests   = rnd.Next((int)(clergymen * 0.03), (int)(clergymen * 0.05)); break;

            case ReligiousPresence.Strong:
                clergymen = rnd.Next((int)(p * 17), (int)(p * 25));
                priests   = rnd.Next((int)(clergymen * 0.05), (int)(clergymen * 0.07)); break;
            }
        }
Exemplo n.º 6
0
 public Settlement(string name, SettlementSize size)
 {
     Name = name;
     Size = size;
 }