示例#1
0
        private void generatePerson()
        {
            this.scen.GameCommonData.PersonGeneratorSetting.bornLo = int.Parse(tbBornYearLo.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.bornHi = int.Parse(tbBornYearHi.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.debutLo = int.Parse(tbDebutAgeLo.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.debutHi = int.Parse(tbDebutAgeHi.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.dieLo = int.Parse(tbAgeLo.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.dieHi = int.Parse(tbAgeHi.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.debutAtLeast = int.Parse(tbDebutAtLeast.Text);

            ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[0]).generationChance = int.Parse(tbPersonType0.Text);
            ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[1]).generationChance = int.Parse(tbPersonType1.Text);
            ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[2]).generationChance = int.Parse(tbPersonType2.Text);
            ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[3]).generationChance = int.Parse(tbPersonType3.Text);
            ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[4]).generationChance = int.Parse(tbPersonType4.Text);
            ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[5]).generationChance = int.Parse(tbPersonType5.Text);
            ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[6]).generationChance = int.Parse(tbPersonType6.Text);
            ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[7]).generationChance = int.Parse(tbPersonType7.Text);
            ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[8]).generationChance = int.Parse(tbPersonType8.Text);
            ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[9]).generationChance = int.Parse(tbPersonType9.Text);

            int count = GameObject.Random(int.Parse(tbAddPersonLo.Text), int.Parse(tbAddPersonHi.Text));

            int joinChance = int.Parse(tbJoinedFactionChance.Text);
            for (int i = 0; i < count; ++i)
            {
                bool joined = GameObject.Chance(joinChance);

                Architecture location = null;
                if (joined)
                {
                    ArchitectureList candidates = new ArchitectureList();
                    foreach (Architecture j in scen.Architectures)
                    {
                        if (j.BelongedFaction != null)
                        {
                            candidates.Add(j);
                        }
                    }
                    if (candidates.Count > 0)
                    {
                        location = (Architecture)candidates.GetRandomObject();
                    }
                    else
                    {
                        joined = false;
                    }
                }

                if (!joined)
                {
                    location = (Architecture)scen.Architectures.GetRandomObject();
                }

                Person p = Person.createPerson(scen, location, null, false);
                if (joined && location.BelongedFaction != null)
                {
                    p.ChangeFaction(location.BelongedFaction);
                }
            }
        }