/// <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; }
private bool CheckIfFamilyHouseIsPlaced(House house) { if (house.IsBought == true && house.HorizontalPos >= 0 && house.VerticalPos >= 0 && house.Family != null) return true; else return false; }
public void AddNewFamilyHouse(House house) { if (_emptySquaresList.Count > 0 && _board.HasAnyEmptyPlace()) { if (!house.IsBought) { SquareControl s = _emptySquaresList[_board.randomNumber.Next(0, _emptySquaresList.Count)]; // Set coordinates int hPos = s.Row; int vPos = s.Col; // Setting the building house.SetCoordinates(hPos, vPos); house.IsBought = true; // Update the grid _emptySquaresList.Remove(s); _board.UpdateSquares(hPos, vPos, Board.FamilyHouseInt); UpdateSquare(house.HorizontalPos, house.VerticalPos, _grid, _board); } } /*else { string message = @"La famille " + house.Family.Name + " n'a pas de maison où s'installer."; string title = @"Village plein."; PushAlert(message, title); }*/ }
internal void SetEmptyHouseInfo(House house) { if (house != null) { this.SuspendLayout(); // Background this.BackgroundImage = GamePages.Properties.Resources.InformationBox_others_background; // BuildingImage buildingIcon.BackgroundImage = GamePages.Properties.Resources.Building_House; buildingIcon.Visible = true; #region InfoBox infos // Title Title.Location = new Point(positionX - 20, positionY); Title.Text = "Maison Vide"; Title.Visible = true; // Hidden infos objectName.Visible = false; ElementName.Visible = false; goldIcon.Visible = false; Gold.Visible = false; faithIcon.Visible = false; Faith.Visible = false; happinessIcon.Visible = false; Happiness.Visible = false; membersIcon.Visible = false; NbMembers.Visible = false; // Building buildingHealthIcon.Visible = true; buildingLife.Text = house.Hp.ToString(); buildingLife.Visible = true; this.ResumeLayout(); #endregion // Action Tab infos _page.ActionMenu.Visible = false; _page.ActionMenu.SuspendLayout(); _page.ActionMenu.DestroyVillagerList(); _page.ActionMenu.ResumeLayout(); _page.ActionMenu.Visible = true; // Meeting Info GodMeeting.Visible = false; GodMeeting.Enabled = false; StopMeeting.Visible = false; StopMeeting.Enabled = false; ActionsButton.Visible = false; ActionsButton.Enabled = false; } else SetError(); }