internal Family(Game game, Villager mother, Villager father, string name) : base(game) { // Initialized historized value for gold _goldStash = new HistorizedValue<int, Family>(this, @"_goldstash", 20); _hungry = new HistorizedValue<bool, Family>(this, @"_hungry", 5); if (mother.ParentFamily != null && father.ParentFamily != null) { _goldStash.Current = mother.ParentFamily.TakeFromGoldStash(mother.ParentFamily.GoldStash / 10); //10% _goldStash.Current += father.ParentFamily.TakeFromGoldStash(father.ParentFamily.GoldStash / 10); //10% RemoveFromFamily(mother, mother.ParentFamily); RemoveFromFamily(father, father.ParentFamily); } else _goldStash.Current = 20; game.GoldAdded(_goldStash.Current); if (mother.StatusInFamily == Status.SINGLE && father.StatusInFamily == Status.SINGLE) mother.Engage(father); var firstNamesPath = File.ReadAllLines(@"Extra\nameList.txt"); _firstNameGenerator = new NameGenerator(firstNamesPath, 1, 1); _name = name; _mother = mother; _father = father; _mother.StatusInFamily = Status.MARRIED; _father.StatusInFamily = Status.MARRIED; _familyMembersList = new FamilyMemberList(this); _familyMembersList.Add(_mother); _familyMembersList.Add(_father); _mother.ParentFamily = this; _father.ParentFamily = this; //=> marriage pendant convocation ? ils s'enfuyent. _mother.ActivityStatus = _mother.ActivityStatus & ~ActivityStatus.CONVOCATED; _father.ActivityStatus = _father.ActivityStatus & ~ActivityStatus.CONVOCATED; }
private void Engage(Villager woman, Family parentFamily) { Debug.Assert(woman.Gender ==Genders.FEMALE , "not a woman !"); int i = 0; while (i < Game.SingleMen.Count) { if (parentFamily != Game.SingleMen[i].ParentFamily) { Debug.Assert(Game.SingleMen[i].StatusInFamily == Status.SINGLE, "the man you're trying to marry is not single!"); woman.Engage(Game.SingleMen[i]); /*woman.StatusInFamily = Status.ENGAGED; Game.SingleMen[i].StatusInFamily = Status.ENGAGED; tmpSingleMan = Game.SingleMen[i]; Game.RemoveSingleMan(tmpSingleMan);// Debug.Assert(Game.SingleMen.Contains(tmpSingleMan)); Debug.Assert(parentFamily != Game.SingleMen[i].ParentFamily);*/ /*Timer timer = new Timer; timer.Interval=5000; timer.Start*/ break; } i++; } }