Example #1
0
 void myInit(TreePerson myTreePerson)
 {
     treePersonIndex = myTreePerson.treePersonIndex;
     Birth           = HELPER_DateToInt(myTreePerson.Birth);
     Death           = HELPER_DateToInt(myTreePerson.Death);
     if (Death < 1.0f)
     {
         Death = DateTime.Today.Year;
     }
     Name                  = myTreePerson.Name;
     PortraitURI           = myTreePerson.PortraitURI;
     Sex                   = myTreePerson.Sex;
     Generation            = myTreePerson.Generation;
     FamilyGenerationIndex = myTreePerson.FamilyGenerationIndex;
     FamilyPersonIndex     = myTreePerson.FamilyPersonIndex;
     PreviousHouseEdge     = myTreePerson.PreviousHouseEdge;
 }
Example #2
0
    public TreePerson(PersonType Type, string birth = "", TreePerson familySearchTreePerson = null)

    {
        switch (Type)
        {
        case PersonType.Null:
            Name  = Death = "";
            Sex   = PersonSex.NotSet;
            Birth = birth;
            break;

        case PersonType.Unique:
            if (Random.Range(0, 2) == 0)
            {
                Sex   = PersonSex.Male;
                Name  = MaleNames[Random.Range(0, MaleNames.Length)];
                Birth = birth;
            }
            else
            {
                Sex   = PersonSex.Female;
                Name  = FemaleNames[Random.Range(0, FemaleNames.Length)];
                Birth = birth;
            }
            break;

        case PersonType.Adam:
            Sex              = PersonSex.Male;
            Name             = "Adam";
            Birth            = birth;
            BirthFamilyIndex = 0;              // from Generation 0
            break;

        case PersonType.Eve:
            Sex              = PersonSex.Female;
            Name             = "Eve";
            Birth            = birth;
            BirthFamilyIndex = 0;             // from Generation 0
            break;

        case PersonType.FamilySearch:
            break;
        }

        myEvents = new List <FamilyEvent>();
    }
Example #3
0
    public TreePerson(PersonType Type, string birth = "", TreePerson familySearchTreePerson = null)
    {
        switch (Type)
        {
        case PersonType.Null:
            Name = Death = "";
            Sex = PersonSex.NotSet;
            Birth = birth;
            break;

        case PersonType.Unique:
            if (Random.Range(0, 2) == 0)
            {
                Sex = PersonSex.Male;
                Name = MaleNames[Random.Range(0,MaleNames.Length)];
                Birth = birth;
            }
            else
            {
                Sex = PersonSex.Female;
                Name = FemaleNames[Random.Range(0,FemaleNames.Length)];
                Birth = birth;
            }
            break;

        case PersonType.Adam:
            Sex = PersonSex.Male;
            Name = "Adam";
            Birth = birth;
            BirthFamilyIndex = 0;  // from Generation 0
            break;

        case PersonType.Eve:
            Sex = PersonSex.Female;
            Name = "Eve";
            Birth = birth;
            BirthFamilyIndex = 0; // from Generation 0
            break;

            case PersonType.FamilySearch:
                break;
        }

            myEvents = new List<FamilyEvent>();
    }
Example #4
0
    private void myInit(Family myFamily)
    {
        FamilyName = myFamily.FamilyName;
        var myscript = GameObject.Find("Myscript").GetComponent <Myscript>();

        TreePerson.timeSpan[] personTimeSpans = new TreePerson.timeSpan[25];
        // TODO replace this with a LIST, use Add instead of a limited 0 .. 25 initialization
        for (int i = 0; i < 25; i++)
        {
            personTimeSpans[i].Start = personTimeSpans[i].End = 0;
        }
        int currentYear = DateTime.Today.Year;

        Generation            = myFamily.Generation;
        FamilyGenerationIndex = myFamily.FamilyGenerationIndex;
        NumberOfPeople        = myFamily.NumberOfPeople;
        PreviousHouseEdge     = myFamily.PreviousHouseEdge;



        int startDate = HELPER_DateToInt(myFamily.MarriageDate);

        if (startDate < 1.0f)
        {
            var gBirthDate = HELPER_DateToInt(myscript.myPeople.allPeople[myFamily.BridePersonIndex].Birth);
            var bBirthDate = HELPER_DateToInt(myscript.myPeople.allPeople[myFamily.GroomPersonIndex].Birth);
            startDate = Math.Max(gBirthDate, bBirthDate) + 16; // the Max wards off Zeros
        }
        int endDate     = startDate;
        int peopleCount = myFamily.ChildrenPersonIndexList.Count + 2;

        if (Generation != 0)
        {
            #region Get endDate for Family

            for (int p = 0; p < peopleCount; p++)
            {
                if (p == 0) // Bride
                {
                    TreePerson mySpouse = myscript.myPeople.allPeople[myFamily.BridePersonIndex];
                    personTimeSpans[p].Start = startDate;
                    if (mySpouse.Death == "")
                    {
                        // Not Dead
                        //allow for future time travel
                        personTimeSpans[p].End = currentYear; // I am ALIVE, and not married
                    }
                    else
                    {
                        // Dead
                        personTimeSpans[p].End = HELPER_DateToInt(mySpouse.Death);
                    }
                }
                else if (p == 1) // Groom
                {
                    TreePerson mySpouse = myscript.myPeople.allPeople[myFamily.GroomPersonIndex];
                    personTimeSpans[p].Start = startDate;
                    if (mySpouse.Death == "")
                    {
                        // Not Dead
                        personTimeSpans[p].End = currentYear; // I am ALIVE, and not married
                    }
                    else
                    {
                        // Dead
                        personTimeSpans[p].End = HELPER_DateToInt(mySpouse.Death);
                    }
                }
                else //Children get their timespan in the house
                {
                    TreePerson mychild = myscript.myPeople.allPeople[myFamily.ChildrenPersonIndexList[p - 2]];
                    personTimeSpans[p].Start = HELPER_DateToInt(mychild.Birth);
                    //TODO Incorporate Marriage Dates
                    //   if (!mychild.isMarried())
                    //   {
                    if (mychild.Death == "")
                    {
                        // Not Married, Not Dead
                        personTimeSpans[p].End = currentYear; // I am ALIVE, and not married
                    }
                    else
                    {
                        //Not Married, But Dead
                        personTimeSpans[p].End = HELPER_DateToInt(mychild.Death);
                    }

                    //  }
                    //  else
                    //  { // Married!
                    //      personTimeSpans[p].End = HELPER_DateToInt(mychild.marriageDate());
                    //  }
                }
                // who is the last left in the house?
                if (personTimeSpans[p].End > endDate)
                {
                    endDate = personTimeSpans[p].End;
                }
            }

            #endregion

            #region Draw House

            StartYear = startDate;
            EndYear   = endDate;

            float zscale = (float)(endDate - StartYear);
            float xscale = (float)peopleCount * (_myScriptScale.PersonWidth + _myScriptScale.InterPersonSpacing);

            float xscaleFrontDoor = (float)2.0f * (_myScriptScale.PersonWidth) + _myScriptScale.InterPersonSpacing;

            float y = ((Generation - 1) * _myScriptScale.GenerationGap) - 0.01f;
            float x = PreviousHouseEdge + _myScriptScale.InterHouseSpacing;
            float z = StartYear;

            // Mark the corners
            HELPER_MarkThisPoint("LeftEdgeStart", x, y, z * _myScriptScale.ZScale);
            HELPER_MarkThisPoint("LeftEdgeEnd", x, y, (z + zscale) * _myScriptScale.ZScale);
            HELPER_MarkThisPoint("RightEdgeStart", x + xscale, y, (z) * _myScriptScale.ZScale);
            HELPER_MarkThisPoint("RightEdgeEnd", x + xscale, y, (z + zscale) * _myScriptScale.ZScale);


            //GameObject newHouse = GameObject.CreatePrimitive(PrimitiveType.Cube);
            GameObject newHouse =
                (GameObject)Instantiate(MyPlatform, new Vector3(0.0f, 0.0f, 0.0f), transform.rotation);

            newHouse.transform.parent   = this.transform;
            newHouse.transform.position = new Vector3(x, y, z * _myScriptScale.ZScale);

            childrenTransforms = GetComponentsInChildren <Transform>();
            //ZTransformBackBoard = childrenTransforms[8];

            foreach (Transform childTransform in childrenTransforms)
            {
                if (childTransform.name.Contains("TransformBackBoard"))
                {
                    childTransform.transform.localScale = new Vector3(xscale, 1.0f, zscale * _myScriptScale.ZScale);
                }
                if (childTransform.name.Contains("ROT TRANSFORM SIGN"))
                {
                    //childTransform.transform.localScale = new Vector3(xscaleFrontDoor,xscaleFrontDoor, 1.0f);
                }
            }

            childrenRenderers = GetComponentsInChildren <Renderer>();
            // BackBoard = childrenRenderers[0];
            // TextPanel = childrenRenderers[1];
            foreach (Renderer childRender in childrenRenderers)
            {
                if (childRender.name.Contains("SignBoard"))
                {
                    // Nothing for now
                }
                if (childRender.name.Contains("FamilyName"))
                {
                    childRender.GetComponent <TextMesh>().text = "The " + FamilyName + " Family";
                }
            }

            #endregion
        }
    }
Example #5
0
 public int addToAllPeople(TreePerson treePerson)
 {
     allPeople.Add(treePerson);
     return(allPeople.IndexOf(treePerson));
 }