Ejemplo n.º 1
0
        public Person(Person mother = null, Person father = null)
        {
            DetermineGender();

            if (mother != null && father != null)
            {
                // Calculate genes based on parents
                Hair = (Hair) FightGenes(mother.Hair, father.Hair);
                Eyes = (Eyes) FightGenes(mother.Eyes, father.Eyes);
                Age = 0;
            }
            else // No parents: generate randomly
            {
                Hair = RandomHair();
                Eyes = RandomEyes();
                Age = RNG.Instance.RandInt(16, 60);

                AddLifeEvent(new Birth { Year = TimeManager.Year - Age});
            }

            Name = RNG.Instance.RandName(Gender);
        }
Ejemplo n.º 2
0
        public Person MakeBaby(Person other)
        {
            if (other == null && Spouse.Person != null)
                other = Spouse.Person;
            else if (Spouse.Person == null)
            {
                throw new Exception("No-one to make baby with!"); // teehee
            }

            if (other == null)
                throw new Exception("No-one to make baby with!");

            Person mother;
            Person father;
            if (Gender == Gender.Female)
            {
                father = other;
                mother = this;
            }
            else
            {
                father = this;
                mother = other;
            }

            var baby = new Person(mother, father);

            Console.WriteLine("{0} and {1} are the proud new parents of baby {2}!", mother.Name, father.Name, baby.Name);

            Pregnant = false;
            other.Pregnant = false;

            Children.Add(new Relationship { Person = baby, RelationType = Relation.Child });
            baby.Mother = new Relationship
            {
                Person = mother,
                RelationType = Relation.Mother
            };

            baby.Father = new Relationship
            {
                Person = father,
                RelationType = Relation.Father
            };

            baby.AddLifeEvent(new Birth { Year = TimeManager.Year });
            return baby;
        }
Ejemplo n.º 3
0
        public bool GiveSignificantOther(Person other)
        {
            if (other.Spouse != null && other.Spouse.Person.Equals(this))
                return false;

            // Half your age plus 7 rules
            if ((Age/2) + 7 > other.Age)
            {
                //Console.WriteLine("{0} is too young for {1} ({2} vs {3})", other.Name, Name, other.Age, Age);
                return false;
            }
            if ((other.Age / 2) + 7 > Age)
            {
                //Console.WriteLine("{0} is too old for {1} ({2} vs {3})", other.Name, Name, other.Age, Age);
                return false;
            }

            Spouse = new Relationship { Person = other };
            Spouse.Person.Spouse = new Relationship { Person = this };

            return true;
        }