Exemple #1
0
    public void Education_Func(Human item)
    {
        //-----------------------------------------------------------Поступление в начальную школу------------------------------------------------------------
        if ((item.age.years >= 6) && (item.age.years < 8) && (item.education.current_education.name == null))
        {
            int rand = Random.Range(0, 4);
            if ((rand == 1) || (item.age.years >= 7 && item.age.month > 5))
            {
                List <Education_Place> schools = new List <Education_Place>();
                foreach (var item_place in education_places)
                {
                    if (item_place.education_given == 1)
                    {
                        schools.Add(item_place);
                    }
                }
                item.education.current_education      = schools[Random.Range(0, schools.Count - 1)];
                item.education.current_education_time = 0;
                Debug.Log("Went to school at " + item.age.years + " " + item.age.month);
                main_screen_script.Add_TextCode("11", item);
            }
        }
        //---------------------------------------------------------------------------------------------------------------------------------------------------



        //-----------------------------------------------------------Поступление в среднюю школу------------------------------------------------------------
        if ((item.education.education.education_given == 1) && (item.education.current_education.name == null))
        {
            List <Education_Place> schools = new List <Education_Place>();
            foreach (var item_place in education_places)
            {
                if (item_place.education_given == 2)
                {
                    schools.Add(item_place);
                }
            }
            item.education.current_education      = schools[Random.Range(0, schools.Count - 1)];
            item.education.current_education_time = 0;
            main_screen_script.Add_TextCode("11", item);
        }
        //---------------------------------------------------------------------------------------------------------------------------------------------------


        //-----------------------------------------------------------Поступление в старшую школу------------------------------------------------------------
        if ((item.education.education.education_given == 2) && (item.education.current_education.name == null))
        {
            List <Education_Place> schools = new List <Education_Place>();
            foreach (var item_place in education_places)
            {
                if (item_place.education_given == 3)
                {
                    schools.Add(item_place);
                }
            }
            item.education.current_education      = schools[Random.Range(0, schools.Count - 1)];
            item.education.current_education_time = 0;
            main_screen_script.Add_TextCode("11", item);
        }
        //---------------------------------------------------------------------------------------------------------------------------------------------------


        //if ((item.education.current_education.education_given=="primary school"))
        //{
        //    item.education.mark = 5;
        //    item.stats.intelligence += 1;
        //    item.education.current_education_time += 1;
        //}
        //

        //-----------------------------------------------------------Действия в уч. заведении------------------------------------------------------------
        if (item.education.current_education.name != null)
        {
            Debug.Log("--------------Education--------------");
            Debug.Log("Education time: " + item.education.current_education_time);
            float intelligence_koeff = 0.5f + item.stats.intelligence / 60f;
            if (intelligence_koeff > 1.5f)
            {
                intelligence_koeff = 1.5f;
            }

            float persistance_koeff = (0.85f + item.stats.persistance / 300f);


            foreach (Subject item_ed in item.education.current_education.schedule)
            {
                item.skills.Find(mySkill => mySkill.name == item_ed.name).Plus_progress(1 * persistance_koeff * intelligence_koeff * (0.5f + item.skills.Find(mySkill => mySkill.name == item_ed.name).interest / 100f));
                Debug.Log(item.skills.Find(mySkill => mySkill.name == item_ed.name).name + ": " + item.skills.Find(mySkill => mySkill.name == item_ed.name).progress);
            }


            float education_level_koeff = item.education.current_education.education_level / 10f;


            //Debug.Log(education_level_koeff + " " + item.education.current_education.name + " " + item.stats.stats_check("intelligence") + " " + (1 + item.stats.persistance / 500f));
            item.stats.intelligence += education_level_koeff * item.stats.stats_koeff("intelligence") * (1 + item.stats.persistance / 500f);
            Debug.Log("Intelligence: " + item.stats.intelligence);

            //Оценка
            float education_given_koeff = 0;
            //if (item.education.current_education.education_given == 1) education_given_koeff =
            foreach (Subject subject_item in item.education.current_education.schedule)
            {
                subject_item.mark = item.skills.Find(mySkill => mySkill.name == subject_item.name).progress / (item.education.current_education_time / item.education.current_education.months) / 5;
                //if (subject_item.mark > 5) subject_item.mark = 5;
                Debug.Log(subject_item.name + ": " + subject_item.mark);
            }

            //Время обучения
            item.education.current_education_time += 1;
            Debug.Log("--------------Education end--------------");
        }
        //-----------------------------------------------------------------------------------------------------------------------------------------------


        //-----------------------------------------------------------Окончание уч. заведения------------------------------------------------------------
        if ((item.education.current_education_time >= item.education.current_education.months) && (item.education.current_education.name != null))
        {
            item.education.education         = item.education.current_education;
            item.education.current_education = new Education_Place();
            List <Education_Place> universities = new List <Education_Place>();

            if ((item.education.education.education_given == 3) && (item.education_agreement == true))
            {
                int i = 0;
                foreach (Skill skill in item.skills)
                {
                    item.main_exam.Add(new Main_Exam());
                    item.main_exam[i].name = skill.name;
                    item.main_exam[i].mark = Mathf.RoundToInt(skill.progress);
                    Debug.Log("Exam: " + item.main_exam[i].name + " - " + item.main_exam[i].mark);
                    i++;
                }
                foreach (var item_place in education_places)
                {
                    if (item_place.education_given == 4)
                    {
                        bool valid_exams = true;
                        foreach (Main_Exam exam in item_place.exams)
                        {
                            if (item.main_exam.Exists(myExam => myExam.name == exam.name))
                            {
                                if (item.main_exam.Find(myExam => myExam.name == exam.name).mark < exam.mark)
                                {
                                    valid_exams = false;
                                    Debug.Log(item.name + " valid exams = " + valid_exams + " because of bad exam");
                                }
                            }
                            else
                            {
                                valid_exams = false;
                            }
                        }
                        if (valid_exams == true)
                        {
                            universities.Add(item_place);
                        }
                        item.education.current_education      = universities[Random.Range(0, universities.Count)];
                        item.education.current_education_time = 0;
                    }
                }
            }
        }
        //-----------------------------------------------------------------------------------------------------------------------------------------------
    }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        main_screen_script = GameObject.Find("Main Screen").GetComponent <Main_screen_Script>();

        GameObject.Find("Plus age Button").GetComponent <Button>().onClick.AddListener(Plus_Age);
        GameObject.Find("EL up Button").GetComponent <Button>().onClick.AddListener(Text_Up);
        GameObject.Find("EL down Button").GetComponent <Button>().onClick.AddListener(Text_Down);

        mark         = GameObject.Find("Mark_debug").GetComponent <Text>();
        intelligence = GameObject.Find("Intelligence_debug").GetComponent <Text>();


        string       line;
        StreamReader reader;
        TextAsset    reader_file = Resources.Load <TextAsset>("Education_places");

        if (reader_file != null)
        {
            using (reader = new StreamReader(new MemoryStream(reader_file.bytes)))
            {
                int i = 0;
                int g = 0;
                //-------------------------------------------------------
                while ((line = reader.ReadLine()) != null)
                {
                    education_places.Add(new Education_Place());
                    education_places[i].name            = line;
                    education_places[i].education_given = int.Parse(reader.ReadLine());
                    education_places[i].education_level = int.Parse(reader.ReadLine());
                    education_places[i].sphere          = reader.ReadLine();
                    education_places[i].months          = int.Parse(reader.ReadLine());
                    education_places[i].break_school    = int.Parse(reader.ReadLine());
                    g = 0;
                    if (education_places[i].education_given == 4)
                    {
                        g = 2;
                    }
                    for (int j = 0; j < g; ++j)
                    {
                        education_places[i].exams.Add(new Main_Exam());
                        string temp = reader.ReadLine();
                        for (int k = 0; k < temp.IndexOf("-"); ++k)
                        {
                            education_places[i].exams[j].name += temp[k];
                        }
                        temp = temp.Remove(0, temp.IndexOf("-") + 1);


                        education_places[i].exams[j].mark = int.Parse(temp);
                    }

                    g = 0;
                    if (education_places[i].education_given == 1)
                    {
                        g = 4;
                    }
                    else if (education_places[i].education_given == 2)
                    {
                        g = 4;
                    }
                    else if (education_places[i].education_given == 3)
                    {
                        g = 4;
                    }
                    else if (education_places[i].education_given == 4)
                    {
                        g = 4;
                    }
                    else
                    {
                        g = 0;
                    }
                    for (int j = 0; j < g; ++j)
                    {
                        education_places[i].schedule.Add(new Subject());
                        education_places[i].schedule[j].name = reader.ReadLine();
                    }
                    i++;
                }
                //-------------------------------------------------------
            }
        }



        protagonist = new Human(new Human(null, null, "father"), new Human(null, null, "mother"), "protagonist");
        main_family_list.Add(protagonist);
        main_family_list.Add(protagonist.father);
        main_family_list.Add(protagonist.mother);

        main_screen_script.New_Age(protagonist.age.years, protagonist.age.month);
        main_screen_script.Add_TextCode("2", protagonist.mother);
    }