public void init()
 {
     allFamilies.Clear();
     Family zeroFamily = new Family(0, 0, 0, "");
     addToAllFamilies(zeroFamily);
     // This will serve as the root of the tree and Generation 0, Adam and Eve can be Generation 1
     myPeople.init();
 }
        public void init()
        {
            BachelorPersonIndexList = new List<int>();
            BachelorettePersonIndexList = new List<int>();
            courtHouse.allFamilies = new List<Family>();
            courtHouse.myPeople.init();

            Family zeroFamily = new Family(0, 0, 0, "");
            addToAllFamilies(zeroFamily);
            // THis will serve as the root of the tree and Generation 0, Adam and Eve can be Generation 1
        }
        public int StartFamily(int treePersonIndex, int treePersonSpouceIndex, string year)
        {
            Family myFamily = null;
            int familyIndex = -1;

            FamilyEvent marriageevent = MakeMarriageEvent(treePersonIndex, treePersonSpouceIndex, year ?? "");
            if (marriageevent != null)
            {
                myFamily = new Family(marriageevent.Generation, marriageevent.BridePersonIndex,
                    marriageevent.GroompersonIndex, marriageevent.Date);
                familyIndex = addToAllFamilies(myFamily);
                marriageevent.FamilyIndex = familyIndex;
                myPeople.allPeople[marriageevent.BridePersonIndex].MarriedFamilyIndex = familyIndex;
                myPeople.allPeople[marriageevent.GroompersonIndex].MarriedFamilyIndex = familyIndex;
                myPeople.allPeople[marriageevent.BridePersonIndex].AddEvent(marriageevent);
                myPeople.allPeople[marriageevent.GroompersonIndex].AddEvent(marriageevent);
            }

            return familyIndex;
        }
        public void doWeddings(int currentYear)
        {

            //foreach( int BoyPersonIndex in BachelorPersonIndexList) DOES NOT work because we modify the list see Remove below
            for (int i = 0; i < BachelorPersonIndexList.Count; i++)
            {
                FamilyEvent marriageevent = makeMatch(BachelorPersonIndexList[i], currentYear);
                if (marriageevent != null)
                {
                    Family myFamily = new Family(marriageevent.Generation, marriageevent.BridePersonIndex,
                        marriageevent.GroompersonIndex, marriageevent.Date);
                    int familyIndex = addToAllFamilies(myFamily);
                    marriageevent.FamilyIndex = familyIndex;
                    courtHouse.myPeople.allPeople[marriageevent.BridePersonIndex].MarriedFamilyIndex = familyIndex;
                    courtHouse.myPeople.allPeople[marriageevent.GroompersonIndex].MarriedFamilyIndex = familyIndex;
                    courtHouse.myPeople.allPeople[marriageevent.BridePersonIndex].AddEvent(marriageevent);
                    courtHouse.myPeople.allPeople[marriageevent.GroompersonIndex].AddEvent(marriageevent);

                }
            }
        }
 public int addToAllFamilies(Family family)
 {
     allFamilies.Add(family);
     return allFamilies.IndexOf(family);
 }
 public int addToAllFamilies(Family family)
 {
     courtHouse.allFamilies.Add(family);
     return courtHouse.allFamilies.IndexOf(family);
 }
        public bool BabyTime(Family myFamily, int currentYear)
        {
           // Debug.WriteLine("Are we having a baby?");
            bool retGotaBaby = false;
            // consider Marriage date
            int iMarriageDate;
            if (!Int32.TryParse(myFamily.MarriageDate, out iMarriageDate)) return retGotaBaby;
            if ((currentYear - iMarriageDate) <= _firstChildAfterMarriage) return retGotaBaby;
            //Debug.Log ("Marriage Date looks good");
            // consider we need both a Bride and Groom
            if (courtHouse.myPeople.allPeople[myFamily.GroomPersonIndex].isDead()) return retGotaBaby;
            if (courtHouse.myPeople.allPeople[myFamily.BridePersonIndex].isDead()) return retGotaBaby;
            //Debug.Log ("We have a Bride and Groom!");
            // consider age of Bride

            if (courtHouse.myPeople.allPeople[myFamily.BridePersonIndex].age(currentYear) >= _childBearingAge) return retGotaBaby;
            //Debug.Log ("The Bride is not too old.");
            // consider yougest childs birth year/age
            int iYoungestChildBirth = 0;
            if (myFamily.ChildrenPersonIndexList.Count != 0)
            {
                foreach (int ChildPersonIndex in myFamily.ChildrenPersonIndexList)
                {
                    int iChildBirth;
                    if (!Int32.TryParse(courtHouse.myPeople.allPeople[ChildPersonIndex].Birth, out iChildBirth))
                        return retGotaBaby;
                    if (iChildBirth > iYoungestChildBirth) iYoungestChildBirth = iChildBirth;
                }
                if ((currentYear - iYoungestChildBirth) < _babySpacingYears) return retGotaBaby;
            }
            //Debug.Log ("There has been enough time since the last child!");
            // Okay all is well - lets also throw in a random chance
            int iRand = StaticRandom.RandomNumber(0, 100);
            if (iRand < _chanceForABaby)
            {
                retGotaBaby = true;
                //Debug.WriteLine(courtHouse.myPeople.allPeople[myFamily.BridePersonIndex].Name + " & " +
                //                courtHouse.myPeople.allPeople[myFamily.GroomPersonIndex].Name +
                //                " Are going to have a baby! iRand =" + iRand.ToString());
            }

            return retGotaBaby;
        }