예제 #1
0
        public VillagerBannerUC(Villager v)
        {
            InitializeComponent();

            this.SuspendLayout();
            // Gender Pic
            if (v.Gender == Genders.FEMALE)
                VillagerFace.BackgroundImage = GamePages.Properties.Resources.Gender_Female;
            else
                VillagerFace.BackgroundImage = GamePages.Properties.Resources.Gender_Male;

            // Sick Pic
            Sick_status_pic.BackgroundImage = GamePages.Properties.Resources.ButtonIcon_epidemic;
            if ((v.Health & Healths.SICK) != 0)
                Sick_status_pic.Visible = true;
            else
                Sick_status_pic.Visible = false;

            // Name
            VillagerName.Text = v.FirstName + " " + v.Name;

            // Job
            if (v.Job != null)
                Job_label.Text = "Métier : " + v.Job.Name;
            else
                Job_label.Text = "Aucun métier";
            this.ResumeLayout();
        }
예제 #2
0
 public void Remove(Villager villager)
 {
     if (!_members.Remove(villager))
     {
         throw new InvalidOperationException("Villager must belong to this family.");
     }
     villager.ParentFamily = null;
     _members.Remove(villager);
     FamilyMemberListChanged = true;
 }
예제 #3
0
        public static void Engage(Villager woman, Villager man)
        {
            if (woman.Gender == man.Gender) { throw new InvalidOperationException("these villagers have the same gender"); }
            Debug.Assert(woman.StatusInFamily == Status.SINGLE, "the woman is not single");
            Debug.Assert(man.StatusInFamily == Status.SINGLE, "the man is not single");

            woman.SetFiance(man);
            man.SetFiance(woman);
            woman.StatusInFamily = Status.ENGAGED;
            man.StatusInFamily = Status.ENGAGED;
        }
예제 #4
0
 public void Add(Villager villager)
 {
     if (villager == null) throw new ArgumentNullException("villager");
     if (villager.ParentFamily != null)
     {
         if (villager.ParentFamily == this._owner) throw new InvalidOperationException("This villager already belongs to this Family.");
         throw new InvalidOperationException("This villager already belongs to a Family.");
     }
     villager.ParentFamily = _owner;
     _members.Add(villager);
     FamilyMemberListChanged = true;
 }
예제 #5
0
파일: Tailor.cs 프로젝트: EmilieS/Gleipnir
 /// <summary>
 /// Add amount of happiness for all others villagers
 /// </summary>
 /// <param name="person"></param>
 public override void AddHappiness(Villager villager)
 {
     if (_workers.Count == 0)
         return;
     if (villager.Job != null)
     {
         if (villager.Job == this)
             return;
     }
     double happinessToAdd;
     happinessToAdd = _happinessAddition + _workers.Count * 0.5;
     villager.AddOrRemoveHappiness(happinessToAdd);
 }
예제 #6
0
        public void Engage(Villager villager)
        {
            if(villager.Gender == _gender) { throw new InvalidOperationException("these villagers have the same gender"); }
            if (villager.StatusInFamily != Status.SINGLE || _statusInFamily.Current != Status.SINGLE) { throw new InvalidOperationException("villager is not single(Engage)"); }

            SetFiance(villager);
            villager.SetFiance(this);
            _statusInFamily.Current = Status.ENGAGED;
            villager.StatusInFamily = Status.ENGAGED;
             Villager man;
            if(_gender==Genders.MALE){man=this;}
            else{man=villager;}
            if (Game.SingleMen.Contains(man)) { Game.RemoveSingleMan(man); }
        }
예제 #7
0
파일: Family.cs 프로젝트: EmilieS/Gleipnir
        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;
        }
예제 #8
0
파일: Family.cs 프로젝트: EmilieS/Gleipnir
 /// <summary>
 /// Remove dead member from familyMemberList
 /// </summary>
 /// <param name="dead"></param>
 internal void FamilyMemberDestroyed(Villager dead)
 {
     Debug.Assert(dead != null, @"(family, FamilyMemberDestroyed) Villager exist");
     Debug.Assert(dead.IsDead(), @"(family, FamilyMemberDestroyed) Villager not dead");
     Debug.Assert(_familyMembersList.Contains(dead), @"(family, FamilyMemberDestroyed) Villager not familyMembersList");
     if (_mother != null)
         if (dead == _mother)
             _mother = null;
     if (_father != null)
         if (dead == _father)
             _father = null;
     _familyMembersList.Remove(dead);
 }
예제 #9
0
파일: Game.cs 프로젝트: EmilieS/Gleipnir
 /// <summary>
 /// Remove single man villager from single men list
 /// </summary>
 /// <param name="villager"></param>
 internal void RemoveSingleMan(Villager villager)
 {
     Debug.Assert(villager.StatusInFamily != Status.SINGLE, @"(game, RemoveSingleMen) Man not single");
     Debug.Assert(_singleMenList.Contains(villager), @"(game, RemoveSingleMen) Man not in singleMenList");
     _singleMenList.Remove(villager);
 }
예제 #10
0
 internal void SetFiance(Villager fiance)
 {
     if (StatusInFamily != Status.SINGLE) { throw new InvalidOperationException("villager is not single!(SetFiance)"); }
     if (fiance == null) { throw new ArgumentNullException("fiance is null"); }
     _fiance = fiance;
 }
예제 #11
0
파일: Village.cs 프로젝트: EmilieS/Gleipnir
 // called by ImpactHappiness
 /// <summary>
 /// Add happiness from job to villagers
 /// </summary>
 /// <param name="villager"></param>
 internal void JobHappiness(Villager villager)
 {
     foreach (JobsModel job in JobsList.HappinessJobList)
         job.AddHappiness(villager);
 }
예제 #12
0
파일: Village.cs 프로젝트: EmilieS/Gleipnir
        /// <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;
        }
예제 #13
0
파일: Family.cs 프로젝트: EmilieS/Gleipnir
 /// <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);
 }
예제 #14
0
 public bool AddPerson2(Villager person)
 {
     if (!AddPersonPrerequisites())
         return false;
     if (person == null)
         return false;
     if (!_workers.Contains(person))
     {
         person.setJob(this);
         _workerListChanged = true;
         _workers.Add(person);
         if ((person.Health & Healths.HERETIC) != 0)
         {
             addHereticWorker();
         }
         Debug.Assert(_workers.Contains(person), "(AddPerson) the person was not added Oo");
         //_gold = ModifyGoldGeneration();//not usefull here really...
         return true;
     }
     else
         return false;
 }
예제 #15
0
 /// <summary>
 /// Add amount of happiness for all others villagers
 /// </summary>
 /// <param name="person"></param>
 public virtual void AddHappiness(Villager villager)
 {
 }
예제 #16
0
        private void SetVillagerInfos(Villager v)
        {
            this.SuspendLayout();
            // Set genderIcon
            GenderIcon.Visible = true;
            if (v.Gender == Genders.FEMALE)
                GenderIcon.BackgroundImage = GamePages.Properties.Resources.Gender_Female;
            else
                GenderIcon.BackgroundImage = GamePages.Properties.Resources.Gender_Male;

            // Set villager Name
            VillagerSelected.Visible = true;
            VillagerSelected.Text = v.FirstName + " " + v.Name;

            // Set villager Job
            VillagerJob.Visible = true;
            if (v.Job != null)
                VillagerJob.Text = v.Job.Name;
            else
                VillagerJob.Text = "Aucun métier";

            // Set sickIcon
            SickIcon.Visible = true;
            if (v.Health == Healths.SICK)
                SickIcon.BackgroundImage = GamePages.Properties.Resources.ButtonIcon_epidemic;
            else
                SickIcon.BackgroundImage = GamePages.Properties.Resources.Building_HealthPoints;

            // Set villager State
            VillagerState.Visible = true;
            VillagerState.Text = v.Health.ToString();

            // Set villager Happiness
            VillagerHappinessIcon.Visible = true;
            VillagerHappiness.Visible = true;
            VillagerHappiness.Text = v.Happiness.ToString();

            // Set villager Faith
            VillagerFaithIcon.Visible = true;
            VillagerFaith.Visible = true;
            VillagerFaith.Text = v.Faith.ToString();
            this.ResumeLayout();
        }
예제 #17
0
 private void ListOfVillagers_SelectedValueChanged(object sender, EventArgs e)
 {
     if (ListOfVillagers.SelectedValue != null)
     {
         _villager = (Villager)ListOfVillagers.SelectedValue;
         SetVillagerInfos(_villager);
     }
     else
     {
         HideVillagerInfos();
         _villager = null;
     }
 }
예제 #18
0
 public void SetGoodHealth(Villager sickVillager)
 {
     sickVillager.SetHealed();
 }
예제 #19
0
파일: Game.cs 프로젝트: EmilieS/Gleipnir
 /// <summary>
 /// Add single man villager to single men list
 /// </summary>
 /// <param name="man"></param>
 internal void AddSingleMan(Villager man)
 {
     Debug.Assert(man != null, @"(game, AddSingleMan) Man is null");
     Debug.Assert(man.Gender == Genders.MALE, @"(game, AddSingleMan) Is a woman");
     Debug.Assert(man.StatusInFamily == Status.SINGLE, @"(game, AddSingleMan) Is not single");
     _singleMenList.Add(man);
 }
예제 #20
0
파일: Family.cs 프로젝트: EmilieS/Gleipnir
 /// <summary>
 /// Removes happiness when family member died
 /// </summary>
 /// <param name="deadVillager"></param>
 internal void FamilyMemberDied(Villager deadVillager)
 {
     for (int i = 0; i < FamilyMembers.Count; i++)
         if (FamilyMembers[i] != deadVillager)
             FamilyMembers[i].AddOrRemoveHappiness(-5);
 }
예제 #21
0
파일: Family.cs 프로젝트: EmilieS/Gleipnir
        /// <summary>
        /// Destroy family
        /// </summary>
        internal override void OnDestroy()
        {
            Debug.Assert(_familyMembersList.Count == 0, @"(family, OnDestroy) Still member in family");
            Debug.Assert(_ownerVillage != null, @"(family, OnDestroy) Family's village is null");

            _mother = null;
            _father = null;
            if (House != null)
            {
                House.FamilyDestroyed();
                House = null;
            }

            Debug.Assert(_ownerVillage.FamiliesList.Contains(this), @"(family, OnDestroy) Family not in village's familiesList");
            _ownerVillage.FamilyDestroyed(this);

            Debug.Assert(_ownerVillage == null, @"(family, OnDestroy) Village isn't null");
            Game.TakeGoldWhenFamilyRemoved(this);
        }
예제 #22
0
 public bool RemovePerson2(Villager person)
 {
     if (person == null)
         return false;
     if (_workers.Contains(person))
     {
         if ((person.Health & Healths.HERETIC) != 0)
         {
             removeHereticWorker();
         }
         person.setJob(null);
         _workerListChanged = true;
         _workers.Remove(person);
         //_gold = ModifyGoldGeneration();//not usefull here really
         return true;
     }
     else
         return false;
 }
예제 #23
0
파일: Village.cs 프로젝트: EmilieS/Gleipnir
        // 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;
        }
예제 #24
0
 /// <summary>
 /// Add a Villager to the Job
 /// </summary>
 /// <param name="person"></param>
 internal void AddPerson(Villager person)
 {
     if (!AddPersonPrerequisites())
         return;
     if (person == null) throw new ArgumentNullException();
     if (!_workers.Contains(person))
     {
         person.setJob(this);
         _workerListChanged = true;
         _workers.Add(person);
         if ((person.Health & Healths.HERETIC) != 0)
         {
             addHereticWorker();
         }
         Debug.Assert(_workers.Contains(person), "(AddPerson) the person was not added Oo");
         //_gold = ModifyGoldGeneration();//not usefull here really...
     }
     else throw new InvalidOperationException();
 }
예제 #25
0
파일: Village.cs 프로젝트: EmilieS/Gleipnir
        /// <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;
        }
예제 #26
0
 internal void WorkerDestroyed(Villager dead)
 {
     Debug.Assert(dead != null, "(JobsModel) villager is null");
     Debug.Assert(dead.IsDead(), "(JobsModel) villager is not dead ?!");
     Debug.Assert(_workers.Contains(dead), "(JobModel) villager isn't even in the workerlist!");
     Debug.Assert((dead.Faith <= 15) == ((dead.Health & Healths.HERETIC) != 0), "(JobModel/villagerdestroyed) heretism is not right!");
     if ((dead.Health & Healths.HERETIC) != 0)
     {
         removeHereticWorker();
     }
     RemovePerson(dead);
 }
예제 #27
0
파일: Village.cs 프로젝트: EmilieS/Gleipnir
 /// <summary>
 /// Remove villager from village
 /// </summary>
 /// <param name="villager"></param>
 internal void VillagerRemoved(Villager villager)
 {
     _villagePop.Current--;
 }
예제 #28
0
파일: Family.cs 프로젝트: EmilieS/Gleipnir
 // Family Member Methods
 /// <summary>
 /// Add new villager in family members list
 /// </summary>
 /// <returns></returns>
 public Villager NewFamilyMember()
 {
     if (_mother == null || _father == null)
         throw new InvalidOperationException(@"(family, NewFamilyMember) Missing parent");
     var name = this.FirstNameList.NextName;
     Villager kid = new Villager(_ownerVillage.Game, this, name);
     _familyMembersList.Add(kid);
     return kid;
 }
예제 #29
0
 /// <summary>
 /// Remove the Villager from the Job
 /// </summary>
 /// <param name="person"></param>
 internal void RemovePerson(Villager person)
 {
     if (person == null) throw new ArgumentNullException();
     if (_workers.Contains(person))
     {
         person.setJob(null);
         _workerListChanged = true;
         _workers.Remove(person);
         //_gold = ModifyGoldGeneration();//not usefull here really
     }
     else throw new InvalidOperationException();
 }
예제 #30
0
파일: Game.cs 프로젝트: EmilieS/Gleipnir
 /// <summary>
 /// Remove single man villager from single men list
 /// when the villager is dead
 /// </summary>
 /// <param name="dead"></param>
 internal void SingleManDestroyed(Villager dead)
 {
     _singleMenList.Remove(dead);
 }