Пример #1
0
        internal Villager(Game g, Family parentFamily, string name)
            : base(g)
        {
            _faith = new HistorizedValue<double, Villager>(this, "_faith", 20);
            _happiness = new HistorizedValue<double, Villager>(this, "_happiness", 20);
            _health = new HistorizedValue<Healths, Villager>(this, "_health", 20);
            _statusInFamily = new HistorizedValue<Status, Villager>(this, "_statusInFamily", 20);
            _statusInFamily.Current = Status.SINGLE;

            g.VillagerAdded();
            parentFamily.OwnerVillage.VillagerAdded();
            Debug.Assert(g != null);
            if (Game.Rand.Next(101) < 2)
                _faith.Current = 13;
            else
                _faith.Current = parentFamily.FaithAverage();
            if (_faith.Current <= 15)
                _health.Current = Healths.HERETIC;
            switch (Game.Rand.Next(2))
            {
                case 0: _gender = Genders.MALE;
                    if (parentFamily.Father != null)
                        if (parentFamily.Father.Job != null)
                            parentFamily.Father.Job.AddPerson(this);
                    g.AddSingleMan(this); break;
                case 1: _gender = Genders.FEMALE;
                    if (parentFamily.Mother != null)
                        if (parentFamily.Mother.Job != null)
                            parentFamily.Mother.Job.AddPerson(this);
                    Engage(this, parentFamily); break;
            }
            if (parentFamily.OwnerVillage.Meeting != null)
            {
                if (parentFamily.OwnerVillage.Meeting.Family == parentFamily)
                {
                    MeetingStarted();
                }
            }
            _happiness.Current = parentFamily.HappinessAverage();
            _age = 0;
            _lifeExpectancy = 85 * 12;
            _name = name;
        }