public void startRobotGame(TESTS test) { currentTest = test; switch (test) { case TESTS.FIELD: prepareScene(typeof(Field)); break; case TESTS.BUILD_HUB: prepareScene(typeof(BuildHub)); break; } }
private void loadScene(CancellationToken token, string sceneName) { for (int sceneIndex = 0; sceneIndex < SceneManager.sceneCount; ++sceneIndex) { Scene scene = SceneManager.GetSceneAt(sceneIndex); if (sceneName != scene.name) { foreach (GameObject gameObject in scene.GetRootGameObjects()) { RobotGame robotGame = gameObject.GetComponent <RobotGame>(); if (robotGame != null) { experience = robotGame.getExperience(); credits = robotGame.getCredits(); humanRobot = robotGame.getHumanRobot(); humanRobotParts = robotGame.getHumanRobotParts(); obstaclesData = robotGame.getObstaclesData(); currentSettings = robotGame.getCurrentSettings(); previousRoundDamageDifference = robotGame.getPreviousRoundDamageDifference(); previousRoundMaxDamageDifference = robotGame.getPreviousRoundMaxDamageDifference(); previousRoundTimeElapsed = robotGame.getPreviousRoundTimeElapsed(); buildHubStatesData = robotGame.getBuildHubStatesData(); fieldStatesData = robotGame.getFieldStatesData(); trainingMode = robotGame.getTrainingMode(); if (trainingMode) { currentTest = TESTS.AI_AGENT_TRAINING; } foreach (Part part in humanRobotParts) { currentHumanRobotParts.Add(part.clone(true)); } foreach (Robot robot in myRobots) { currentMyRobots.Add(robot.clone(true)); } foreach (Setting setting in settingList) { currentSettingValueList.Add(setting.currentValue); } } SplashScreen splashScreen = gameObject.GetComponent <SplashScreen>(); if (splashScreen != null) { List <GameObject> gameObjectsInOldScene = new List <GameObject>(scene.GetRootGameObjects()); GameObject splashScreenCanvas = gameObjectsInOldScene.Find(g => g.name == "SplashScreenCanvas"); SceneManager.MoveGameObjectToScene(splashScreenCanvas, SceneManager.GetActiveScene()); GameObject loadingSplashScreen = splashScreenCanvas.transform.Find("LoadingSplashScreen").gameObject; List <GameObject> gameObjectsInCurrentScene = new List <GameObject>(FindObjectsOfType <GameObject>()); GameObject currentSplashScreenCanvas = gameObjectsInCurrentScene.Find(g => g.name.Contains("SplashScreenCanvas")); loadingSplashScreen.transform.SetParent(currentSplashScreenCanvas.transform); splashScreen.transform.SetParent(GameObject.Find("Directional Light").transform); } } SceneManager.UnloadSceneAsync(scene); } } splashScreenLoader = SceneManager.LoadSceneAsync(SPLASH_SCREEN_SCENE_NAME, LoadSceneMode.Additive); splashScreenLoader.allowSceneActivation = false; initializeScene(sceneName); }
void ShowTest(List <string> Tests, int Test_number, string FileName) { Test TEST = new Test(); if (!TEST.Creat_test(Tests[Test_number])) { MessageBox.Show($"Ошибка: Файл - \"{Tests[Test_number]}\" содержит ошибку."); this.Close(); throw new Exception($"Ошибка: Файл - \"{Tests[Test_number]}\" содержит ошибку."); } TESTS.Add(TEST); // add test in list this.Text = TEST._Header.Name; LABEL_TEST_NAME.Text = TEST._Header.Name; // test name LABEL_TEST_DESCRIPTION.Text = TEST._Header.Description; // test description List <Questions_Form> LIST_OF_LABELS_TEST_QUESTIONS = new List <Questions_Form>(); // список вопросов for (int i = 0; i < TEST._Questions.Count; i++) { Questions_Form temp = new Questions_Form(); Form_FQ(TEST._Questions[i], temp, i); LIST_OF_LABELS_TEST_QUESTIONS.Add(temp); } Button BUTTON_TEST_FINISH = new Button { Size = new System.Drawing.Size(200, 45), Text = "Завершить тестирование", UseVisualStyleBackColor = true }; Design.Design_for_button(BUTTON_TEST_FINISH); BUTTON_TEST_FINISH.Click += new System.EventHandler(BUTTON_TEST_FINISH_Click); Auto_Size(LABEL_TEST_NAME, LABEL_TEST_DESCRIPTION, LIST_OF_LABELS_TEST_QUESTIONS, BUTTON_TEST_FINISH); void BUTTON_TEST_FINISH_Click(object sender, EventArgs e) // Кновка закончить тест. { Answers_to_Test answers_to_the_Test = new Answers_to_Test(); Create_Answer_list(LIST_OF_LABELS_TEST_QUESTIONS, answers_to_the_Test);//формируем список вопросов и ответов на эти вопросы. if (TEST._Header.Verifier == VerificationDescriptors._ONLY_ONE) { for (int i = 0; i < answers_to_the_Test.Count; i++) { if (answers_to_the_Test[i].Count != 1) { string Err = "Ошибка: на вопрос: "; for (; i < answers_to_the_Test.Count; i++) { if (answers_to_the_Test[i].Count != 1) { Err += $" {Convert.ToString(i + 1)}"; } } MessageBox.Show($"{Err} должен быть один."); return; } } } if (TEST._Header.Verifier == VerificationDescriptors._AT_LEAST_ONE) { for (int i = 0; i < answers_to_the_Test.Count; i++) { if (answers_to_the_Test[i].Count == 0) { string Err = "Ошибка: вы не ответили на вопрос: "; for (; i < answers_to_the_Test.Count; i++) { if (answers_to_the_Test[i].Count == 0) { Err += $" {Convert.ToString(i + 1)}"; } } MessageBox.Show(Err); return; } } } Answer_to_all_tests.Add(answers_to_the_Test); if (Test_number < Tests.Count - 1) { this.Controls.Clear(); ShowTest(Tests, Test_number + 1, FileName); } else { Test_parser.Create_an_automatic_resume(TESTS, Answer_to_all_tests, FileName); this.Close(); } } }