public Meeting(Family f) : base(f.Game) { _family = f; _village = f.OwnerVillage; Convocate(); }
public bool OpenPanel(Family f) { if (f == null) return false; else { this.BringToFront(); this.Show(); _isOpen = true; SetLists(f); UnlockElements(); _page.InformationsBox.ActionsButton.Enabled = false; return true; } }
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; }
//public void AffectMissionToVillager(Villager villager, Missions expectedMission) //{ // if (expectedMission != villager.Mission) // { // villager.Mission = expectedMission; // } //} internal override void OnDestroy() { _village.MeetingEnded(); _village = null; _family = null; }
/// <summary> /// Remove destroyed family from families list /// </summary> /// <param name="family"></param> internal void FamilyDestroyed(Family family) { if (_meeting != null) if (family == _meeting.Family) EndMeeting(); Debug.Assert(family != null, @"(village, FamilyDestroyed) Family don't exist"); _familiesList.Remove(family); }
public bool MeetingStart(Family f) { if (_meeting != null) return false; if (f == null) return false; if (BuildingsList.TablePlaceList.Count == 0) return false; _meeting = new Meeting(f); return true; }
/// <summary> /// Create family with no mother and no father but with jobs /// </summary> /// <param name="mothersJob"></param> /// <param name="fathersJob"></param> /// <returns></returns> public Family CreateFamilyFromScratch(JobsModel mothersJob, JobsModel fathersJob) { Debug.Assert(Game != null, @"(village, CreateFamilyFromScratch2) Game is null"); // Create family var name = Game.NameList.NextName; Villager VillagerAM = new Villager(Game, Genders.MALE, Game.FirstNameList.NextName); Villager VillagerAF = new Villager(Game, Genders.FEMALE, Game.FirstNameList.NextName); var newFamily = new Family(Game, VillagerAF, VillagerAM, name); // Add family into families house _familiesList.Add(newFamily); // Remove villager into job worker list if (VillagerAF.Job != null) VillagerAF.Job.RemovePerson(VillagerAF); if (VillagerAM.Job != null) VillagerAM.Job.RemovePerson(VillagerAM); // Add villager into job worker list mothersJob.AddPerson(VillagerAF); fathersJob.AddPerson(VillagerAM); // Create new house Buildings.House house = new Buildings.House(this); // Add family into house and house in family house.Family = newFamily; newFamily.House = house; return newFamily; }
/// <summary> /// Create family without mother and father /// </summary> /// <returns></returns> public Family CreateFamilyFromScratch() { Debug.Assert(Game != null, @"(village, CreateFamilyFromScratch) Game is null"); // Create family var name = Game.NameList.NextName; Villager VillagerAM = new Villager(Game, Genders.MALE, Game.FirstNameList.NextName); Villager VillagerAF = new Villager(Game, Genders.FEMALE, Game.FirstNameList.NextName); var newFamily = new Family(Game, VillagerAF, VillagerAM, name); // Add family into families list _familiesList.Add(newFamily); // Create new house Buildings.House house = new Buildings.House(this); // Add family into house and house in family house.Family = newFamily; newFamily.House = house; return newFamily; }
// Families Methods /// <summary> /// Create family with mother and father /// </summary> /// <param name="mother"></param> /// <param name="father"></param> /// <returns></returns> public Family CreateFamily(Villager mother, Villager father) { if (mother.ParentFamily == null || father.ParentFamily == null) throw new ArgumentNullException(@"(village, CreateFamily) Mother or Father is null"); else { if (mother.Gender != Genders.FEMALE || father.Gender != Genders.MALE) throw new InvalidOperationException(@"(village, CreateFamily) Gender issue"); if (mother.ParentFamily == father.ParentFamily) throw new InvalidOperationException(@"(village, CreateFamily) Same family"); } // Create family if still one place in village var name = Game.NameList.NextName; var newFamily = new Family(Game, mother, father, name); // No house yet for this family Buildings.House house = null; // Add family to families list _familiesList.Add(newFamily); // Try add empty house to family if (EmptyHouseList.Count > 0) { int i = 0; while (i < EmptyHouseList.Count && house == null) { if (EmptyHouseList[i].Hp > 0) { house = EmptyHouseList[0]; RemoveEmptyHouse(house); } i++; } } else house = new Buildings.House(this, JobsList.Construction_Worker.Workers.Count > 0); // Add house to family and family into house house.Family = newFamily; newFamily.House = house; return newFamily; }
/// <summary> /// Remove villager from family's members list /// </summary> /// <param name="villager"></param> /// <param name="parentFamily"></param> private void RemoveFromFamily(Villager villager, Family parentFamily) { parentFamily.FamilyMembers.Remove(villager); }
private void SetLists(Family f) { // ListOfVillagers BindingList<Villager> villagersList = new BindingList<Villager>(); foreach (Villager v in f.FamilyMembers) villagersList.Add(v); ListOfVillagers.ValueMember = null; ListOfVillagers.DisplayMember = "FirstName"; ListOfVillagers.DataSource = villagersList; // ListOfJobs BindingList<JobsModel> jobsList = new BindingList<JobsModel>(); foreach (JobsModel j in _page.TheGame.Villages[0].JobsList) if (j.Building != null) jobsList.Add(j); ListOfJobs.ValueMember = null; ListOfJobs.DisplayMember = "Name"; ListOfJobs.DataSource = jobsList; }
// Villagers list internal void ShowVillagerListInFamily(Family fam) { if (!passed) { ListOfVillagersToShow = new List<VillagerBannerUC>(); passed = true; } DestroyVillagerList(); for (int i = 0; i < fam.FamilyMembers.Count; i++) { VillagerBannerUC tmp = new VillagerBannerUC(fam.FamilyMembers[i]); // Set VillagerBannerUC tmp.Location = new System.Drawing.Point(positionX, positionY); // Add VillagerBannerUC to lists and show it this.VillagerList.Controls.Add(tmp); ListOfVillagersToShow.Add(tmp); tmp.Show(); // Set position for next VillagerBannerUC positionY += 62; } }
// Hide or Show elements in InfoBox internal void SetFamilyHouseInfo(Family family) { if (family != null) { this.SuspendLayout(); _family = family; // Background this.BackgroundImage = GamePages.Properties.Resources.InformationBox_house_background; // BuildingImage buildingIcon.BackgroundImage = GamePages.Properties.Resources.Building_House; buildingIcon.Visible = true; #region InfoBox infos // Title Title.Location = new Point(positionX, positionY); Title.Text = "Famille"; Title.Visible = true; // ObjectName objectName.Visible = true; ElementName.Text = family.Name; ElementName.Visible = true; // Gold goldIcon.Visible = true; Gold.Text = _page.TransformHighNumberToKnumbers(family.GoldStash); Gold.Visible = true; // Faith faithIcon.Visible = true; if (family.FaithAverageValue.ToString().Count<char>() > 5) { string txt = family.FaithAverageValue.ToString(); string tmp = ""; for (int i = 0; i < 5; i++) tmp += txt[i]; Faith.Text = tmp; } else Faith.Text = family.FaithAverageValue.ToString(); Faith.Visible = true; // Members membersIcon.Visible = true; NbMembers.Text = family.FamilyMembers.Count.ToString(); NbMembers.Visible = true; // Happiness happinessIcon.Visible = true; if (family.HappinessAverageValue.ToString().Count<char>() > 5) { string txt = family.HappinessAverageValue.ToString(); string tmp = ""; for (int i = 0; i < 5; i++) tmp += txt[i]; Happiness.Text = tmp; } else Happiness.Text = family.HappinessAverageValue.ToString(); Happiness.Visible = true; // Building Life buildingHealthIcon.Visible = true; buildingLife.Text = family.House.Hp.ToString(); buildingLife.Visible = true; this.ResumeLayout(); #endregion // Action Tab infos _page.ActionMenu.Visible = false; _page.ActionMenu.SuspendLayout(); _page.ActionMenu.ShowVillagerListInFamily(family); _page.ActionMenu.ResumeLayout(); _page.ActionMenu.Visible = true; // Meetings Details GodMeeting.Visible = true; if (_page.TheGame.Villages[0].Meeting != null) GodMeeting.Enabled = false; else GodMeeting.Enabled = true; StopMeeting.Visible = false; StopMeeting.Enabled = false; ActionsButton.Visible = false; ActionsButton.Enabled = false; } else SetError(); }
public FamilyMemberList(Family owner) { _members = new List<Villager>(); _owner = owner; FamilyMemberListChanged = true; }
/// <summary> /// Take gold from total gold when family is destroyed /// </summary> /// <param name="family"></param> internal void TakeGoldWhenFamilyRemoved(Family family) { _totalGold.Current -= family.GoldStash; }
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++; } }