//Functionality
 public void SetConditionListing(FamilyMemberClass to)
 {
     selectedMember  = to;
     depthInput.text = maximumDepth.ToString();
     UpdateCache();
     SpawnList();
 }
Exemple #2
0
    public MemberWindowScript CreateNewMemberWindow(FamilyMemberClass fromMember)
    {
        Vector3 atPosition = Camera.main.ViewportToWorldPoint(Vector3.one * 0.5f);

        atPosition.z = 0;

        Transform t = Instantiate(windowPrefab, atPosition, Quaternion.identity, nodeLayer);

        t.GetComponent <RectTransform>().anchoredPosition = atPosition;
        MemberWindowScript tempWin;

        if ((tempWin = t.GetComponent <MemberWindowScript>()) != null)
        {
            if (!wholeFamily.ContainsKey(fromMember.ID))
            {
                wholeFamily.Add(fromMember.ID, fromMember);
            }


            tempWin.SetPerson(fromMember.ID);
            tempWin.UpdatePersonInformation();

            if (!correspondingWindowsForFamily.ContainsKey(fromMember.ID))
            {
                correspondingWindowsForFamily.Add(fromMember.ID, tempWin);
            }

            return(tempWin);
        }

        return(null);
    }
    public void CreateNewMember()
    {
        if (!string.IsNullOrEmpty(firstNameField.text) && !string.IsNullOrEmpty(lastNameField.text) &&
            !string.IsNullOrEmpty(DOBField.monthField.text) && !string.IsNullOrEmpty(DOBField.dayField.text) && !string.IsNullOrEmpty(DOBField.yearField.text))
        {
            DateClass dob;
            if (DateClass.ConvertStringsToDate(DOBField.monthField.text, DOBField.dayField.text, DOBField.yearField.text, out dob))
            {
                DateClass dod;
                if (!string.IsNullOrEmpty(DODField.monthField.text) || !string.IsNullOrEmpty(DODField.dayField.text) || !string.IsNullOrEmpty(DODField.yearField.text))
                {
                    if (!DateClass.ConvertStringsToDate(DODField.monthField.text, DODField.dayField.text, DODField.yearField.text, out dod))
                    {
                        LogError("Only enter numbers in the date fields!");
                    }
                    else
                    {
                        FamilyMemberClass newMember = new FamilyMemberClass(firstNameField.text, middleNameField.text, lastNameField.text, (Gender)gender.value, dob, dod);
                        newMember.ID = id;
                        newMember.SetConditions(CreateListFromDictionary());

                        //if (relationToMember == relationship.Father || relationToMember == relationship.Mother)
                        //{
                        //    newMember.AddOffspring(relatedMember);
                        //}
                        //else
                        //{
                        //    newMember.SetParent(relatedMember);
                        //}

                        FamilyManager.instance.CreateNewMemberWindow(newMember);

                        CloseFormulary();
                    }
                }
                else
                {
                    dod = new DateClass(-1, -1, -1);

                    FamilyMemberClass newMember = new FamilyMemberClass(firstNameField.text, middleNameField.text, lastNameField.text, (Gender)gender.value, dob, dod);
                    newMember.ID = id;
                    newMember.SetConditions(CreateListFromDictionary());

                    FamilyManager.instance.CreateNewMemberWindow(newMember);

                    CloseFormulary();
                }
            }
            else
            {
                LogError("Only enter numbers in the date fields!");
            }
        }
        else
        {
            LogError("Please fill all fields.");
        }
    }
Exemple #4
0
    public void RemoveOffspring(FamilyMemberClass member)
    {
        int ind = offspring.FindIndex(x => x == member.ID);

        if (ind >= 0)
        {
            offspring.RemoveAt(ind);
        }
    }
Exemple #5
0
    public void AddOffspring(FamilyMemberClass member)
    {
        offspring.Add(member.ID);

        //if (sex == Gender.Female)
        //{
        //    member.motherID = ID;
        //}
        //else
        //{
        //    member.fatherID = ID;
        //}
    }
Exemple #6
0
 public void SetParent(FamilyMemberClass to)
 {
     if (to.sex == Gender.Female)
     {
         motherID = to.ID;
         to.AddOffspring(this);
     }
     else
     {
         fatherID = to.ID;
         to.AddOffspring(this);
     }
 }
    public void CreateTempMember()
    {
        if (!string.IsNullOrEmpty(firstNameField.text) && !string.IsNullOrEmpty(lastNameField.text) &&
            !string.IsNullOrEmpty(DOBField.monthField.text) && !string.IsNullOrEmpty(DOBField.dayField.text) && !string.IsNullOrEmpty(DOBField.yearField.text))
        {
            DateClass dob;
            if (DateClass.ConvertStringsToDate(DOBField.monthField.text, DOBField.dayField.text, DOBField.yearField.text, out dob))
            {
                DateClass dod;
                if (!string.IsNullOrEmpty(DODField.monthField.text) || !string.IsNullOrEmpty(DODField.dayField.text) || !string.IsNullOrEmpty(DODField.yearField.text))
                {
                    if (!DateClass.ConvertStringsToDate(DODField.monthField.text, DODField.dayField.text, DODField.yearField.text, out dod))
                    {
                        LogError("Only enter numbers in the date fields!");
                    }
                    else
                    {
                        FamilyMemberClass newMember = new FamilyMemberClass(firstNameField.text, middleNameField.text, lastNameField.text, (Gender)gender.value, dob, dod);
                        newMember.ID = id;
                        newMember.SetConditions(CreateListFromDictionary());

                        selectedMember = newMember;
                    }
                }
                else
                {
                    dod = new DateClass(-1, -1, -1);

                    FamilyMemberClass newMember = new FamilyMemberClass(firstNameField.text, middleNameField.text, lastNameField.text, (Gender)gender.value, dob, dod);
                    newMember.ID = id;
                    newMember.SetConditions(CreateListFromDictionary());

                    selectedMember = newMember;
                }
            }
            else
            {
                LogError("Only enter numbers in the date fields!");
            }
        }
        else
        {
            LogError("Please fill all fields.");
        }
    }
    public void LogConditionsIntoDictionary(int fromID, Dictionary <string, List <int> > records, int currentDepth, int comingFromID)
    {
        Debug.Log("Currently checking depth for " + fromID);
        FamilyMemberClass temp = FamilyManager.instance.GetMemberByID(fromID);

        foreach (ConditionInstanceClass c in temp.listedConditions)
        {
            if (records.ContainsKey(c.condition.name))
            {
                if (!records[c.condition.name].Contains(fromID))
                {
                    records[c.condition.name].Add(fromID);
                }
            }
            else
            {
                records.Add(c.condition.name, new List <int>()
                {
                    fromID
                });
            }
        }

        if (currentDepth < maximumDepth)
        {
            foreach (int i in temp.offspring)
            {
                if (comingFromID != i && i >= 0)
                {
                    LogConditionsIntoDictionary(i, records, currentDepth + 1, fromID);
                }
            }

            if (comingFromID != temp.motherID && temp.motherID >= 0)
            {
                LogConditionsIntoDictionary(temp.motherID, records, currentDepth + 1, fromID);
            }

            if (comingFromID != temp.fatherID && temp.fatherID >= 0)
            {
                LogConditionsIntoDictionary(temp.fatherID, records, currentDepth + 1, fromID);
            }
        }
    }
    void ResetFormulary()
    {
        selectedMember = FamilyManager.instance.GetMemberByID(id);
        if (selectedMember == null)
        {
            ClearFields();

            createButton.transform.gameObject.SetActive(true);
            submitButton.transform.gameObject.SetActive(false);
        }
        else
        {
            FillFields();

            createButton.transform.gameObject.SetActive(false);
            submitButton.transform.gameObject.SetActive(true);
        }

        ClearError();
    }
    public void UpdatePersonInformation()
    {
        FamilyMemberClass assignedMember = FamilyManager.instance.GetMemberByID(assignedMemberID);

        // Debug.Log("Updating");
        if (assignedMember != null)
        {
            //Debug.Log("Pass");
            if (assignedMember.sex == Gender.Male)
            {
                windowSprite.color = ConstantColors.maleWindowsColor;
            }
            else
            {
                windowSprite.color = ConstantColors.femaleWindowsColor;
            }

            if (assignedMember.middleName.Length > 0)
            {
                nameField.text = assignedMember.lastName + ", " + assignedMember.firstName + " " + assignedMember.middleName[0];
            }
            else
            {
                nameField.text = assignedMember.lastName + ", " + assignedMember.firstName;
            }

            DoBField.text = "DoB: " + assignedMember.dayOfBirth.month + "/" + assignedMember.dayOfBirth.day + "/" + assignedMember.dayOfBirth.year;

            if (assignedMember.dayOfDeath.month < 0)
            {
                DoDField.text = "Alive";
            }
            else
            {
                DoDField.text = "DoB: " + assignedMember.dayOfDeath.month + "/" + assignedMember.dayOfDeath.day + "/" + assignedMember.dayOfDeath.year;
            }

            idField.text = "#" + assignedMember.ID;
        }
    }
Exemple #11
0
    public void DeleteMember(int withID)
    {
        Debug.Log("Deleting member...");
        if (correspondingWindowsForFamily.ContainsKey(withID) && wholeFamily.ContainsKey(correspondingWindowsForFamily[withID].assignedMemberID))
        {
            FamilyMemberClass temp = wholeFamily[correspondingWindowsForFamily[withID].assignedMemberID];

            if (correspondingWindowsForFamily.ContainsKey(temp.motherID))
            {
                RemoveOffspringFromID(temp.motherID, temp.ID);
            }

            if (correspondingWindowsForFamily.ContainsKey(temp.fatherID))
            {
                RemoveOffspringFromID(temp.fatherID, temp.ID);
            }

            if (temp.sex == Gender.Female)
            {
                foreach (int i in temp.offspring)
                {
                    RemoveMotherFromID(i);
                }
            }
            else
            {
                foreach (int i in temp.offspring)
                {
                    RemoveMotherFromID(i);
                }
            }

            correspondingWindowsForFamily.Remove(withID);
            wholeFamily.Remove(withID);
        }

        SaveFamily();
    }
Exemple #12
0
    public bool UpdateMember(FamilyMemberClass to)
    {
        if (wholeFamily.ContainsKey(to.ID))
        {
            wholeFamily[to.ID] = to;

            if (correspondingWindowsForFamily.ContainsKey(to.ID))
            {
                correspondingWindowsForFamily[to.ID].SetPerson(to.ID);
                correspondingWindowsForFamily[to.ID].UpdatePersonInformation();
            }
            else
            {
                CreateNewMemberWindow(wholeFamily[to.ID]);
            }

            return(true);
        }
        else
        {
            return(false);
        }
    }
 public void SetMother(FamilyMemberClass to)
 {
     FamilyManager.instance.SetMotherToID(assignedMemberID, to.ID);
     //assignedMember.motherID = to.ID;
 }
 public void RemoveOffspring(FamilyMemberClass withID)
 {
     FamilyManager.instance.RemoveOffspringFromID(assignedMemberID, withID.ID);
     //assignedMember.RemoveOffspring(withID);
 }
 public void AddOffspring(FamilyMemberClass to)
 {
     FamilyManager.instance.AddOffspringToID(assignedMemberID, to.ID);
     //assignedMember.AddOffspring(to);
 }