/// <summary> /// If the last open level was passed, then go to the contentBalls. /// Otherwise, turn on the next level. /// </summary> public static void Press() { int currentLevel = 0; GlobalSceneObjects.continueButton.GetComponent <Animator>().SetTrigger("HideTrigger"); GlobalSounds.pressButton.Play(); GlobalSounds.transfer.PlayDelayed(0.15f); int countTask = 0; switch (GlobalVariables.activeNameLevel) { case (int)GlobalVariables.NameAnimation.LightTests: countTask = (int)GlobalVariables.CountTask.LightTests; break; case (int)GlobalVariables.NameAnimation.BestPractices: countTask = (int)GlobalVariables.CountTask.BestPractices; break; case (int)GlobalVariables.NameAnimation.ScientistsNotes: countTask = (int)GlobalVariables.CountTask.ScientistsNotes; break; case (int)GlobalVariables.NameAnimation.ExperimentalProcess: countTask = (int)GlobalVariables.CountTask.ExperimentalProcess; break; case (int)GlobalVariables.NameAnimation.AcademicDegree: countTask = (int)GlobalVariables.CountTask.AcademicDegree; break; case (int)GlobalVariables.NameAnimation.SimpleLever: countTask = (int)GlobalVariables.CountTask.SimpleLever; break; case (int)GlobalVariables.NameAnimation.ElementaryLaws: countTask = (int)GlobalVariables.CountTask.ElementaryLaws; break; case (int)GlobalVariables.NameAnimation.Mechanics: countTask = (int)GlobalVariables.CountTask.Mechanics; break; case (int)GlobalVariables.NameAnimation.LatestDevelopments: countTask = (int)GlobalVariables.CountTask.LatestDevelopments; break; } currentLevel = 0; for (int row = 0; row < GlobalSceneObjects.contentBalls.transform.GetChild(GlobalVariables.activeNameLevel - 7).Find("Content").childCount; row++) { if (GlobalSceneObjects.contentBalls.transform.GetChild(GlobalVariables.activeNameLevel - 7).Find("Content").GetChild(row).name.Contains("Level")) { for (int column = 0; column < GlobalSceneObjects.contentBalls.transform.GetChild(GlobalVariables.activeNameLevel - 7).Find("Content").GetChild(row).childCount; column++) { if (GlobalSceneObjects.contentBalls.transform.GetChild(GlobalVariables.activeNameLevel - 7).Find("Content").GetChild(row).GetChild(column).name.Contains("Level")) { currentLevel++; if (currentLevel == SaveInGame.numberLvlClick + 1 || SaveInGame.numberLvlClick == countTask) { if (GlobalSceneObjects.contentBalls.transform.GetChild(GlobalVariables.activeNameLevel - 7).Find("Content").GetChild(row).GetChild(column).Find("Level").GetComponent <Button>().interactable == false || SaveInGame.numberLvlClick == countTask) { HideLevelContent.Invoke(); GlobalVariables.stateForAnimation = GlobalVariables.activeNameLevel; GlobalSounds.transfer.PlayDelayed(0.15f); } else { GlobalVariables.stateForAnimation = (int)GlobalVariables.NameAnimation.NewLevel; } } } } } } }
/// <summary> /// Handles pressing the back button in android. /// Go from aboutUs to the MainMenu. /// Go from writeToUs to the MainMenu. /// Go from achievmentsInCanvas to the MainMenu. /// Go from PossessedTasks to the MainMenu. /// Go from LogicTasks to the MainMenu. /// Go from ContentBalls to the PossessedTasks. /// Go from ContentBalls to the LogicTasks. /// Go from GameLevel to the ContentBalls. /// </summary> void Update() { if (Input.GetKeyDown(KeyCode.Escape)) //МЫ НАЖАЛИ НА КНОПКУ НАЗАД { if (GlobalSceneObjects.aboutUs.activeInHierarchy == true) //если у нас открыто Об Игре { AboutUs.Exit(); GlobalSounds.transfer.PlayDelayed(0.15f); } if (GlobalSceneObjects.writeToUs.activeInHierarchy == true)//если у нас открыто Об Игре { WriteToUs.Exit(); GlobalSounds.transfer.PlayDelayed(0.15f); } if (GlobalSceneObjects.achievmentsInCanvas.activeInHierarchy == true)//если у нас открыто Об Игре { Achievments.Exit(); GlobalSounds.transfer.PlayDelayed(0.15f); } if ((GlobalSceneObjects.logicTasks.activeInHierarchy == true || GlobalSceneObjects.possessedTasks.activeInHierarchy == true)) { GlobalSounds.transfer.PlayDelayed(0.15f); coroutines.InvokeHideTextLevelHouse(GlobalSceneObjects.showNextPage.transform.Find("Text").GetComponent <TextMeshProUGUI>().text); if (GlobalVariables.isPossessedHouse) { GlobalSceneObjects.showNextPage.GetComponent <Animator>().SetTrigger("HideLogicTrigger"); GlobalSceneObjects.logicTasks.GetComponent <Animator>().SetTrigger("HideTrigger"); } else { GlobalSceneObjects.showNextPage.GetComponent <Animator>().SetTrigger("HidePossessedTrigger"); GlobalSceneObjects.possessedTasks.GetComponent <Animator>().SetTrigger("HideTrigger"); } GlobalVariables.stateForAnimation = (int)GlobalVariables.NameAnimation.MainMenu; } for (int numberBall = 0; numberBall < GlobalSceneObjects.contentBalls.transform.childCount; numberBall++) { if (GlobalSceneObjects.contentBalls.transform.GetChild(numberBall).gameObject.activeInHierarchy == true)//если мы в каком либо шаре , то есть выбираем номер уровня, то скрываем эти уровни и переходим к шарикам { HideContentBalls.Invoke(); GlobalVariables.stateForAnimation = (int)GlobalVariables.NameAnimation.PlayButton; GlobalSounds.pressButton.Play(); //звук нажатия GlobalSounds.transfer.PlayDelayed(0.15f); //звук скрытия } } if (GlobalSceneObjects.gameLevels.activeInHierarchy == true)//если у нас открыт уровень, который мы проходим и мы нажали назад,то { HideLevelContent.Invoke(); HideLevelButtons.Invoke(); GlobalVariables.stateForAnimation = GlobalVariables.activeNameLevel; GlobalSounds.transfer.PlayDelayed(0.15f); } } }
/// <summary> /// Subscribing listeners to all other buttons. /// </summary> public static void SetReactionButtons() { Coroutines coroutines = GameObject.FindObjectOfType(typeof(Coroutines)) as Coroutines; GlobalSceneObjects.mainMenu.transform.Find("Content").Find("ButtonPlay").GetComponent <Button>().onClick.AddListener(delegate { StartGame.Invoke(); }); GlobalSceneObjects.mainMenu.transform.Find("Content").Find("ButtonAboutUs").GetComponent <Button>().onClick.AddListener(delegate { AboutUs.Invoke(); }); GlobalSceneObjects.mainMenu.transform.Find("Content").Find("ButtonWriteToUs").GetComponent <Button>().onClick.AddListener(delegate { WriteToUs.Invoke(); }); GlobalSceneObjects.mainMenu.transform.Find("AchievmentButton").GetComponent <Button>().onClick.AddListener(delegate { Achievments.Invoke(); }); GlobalSceneObjects.aboutUs.transform.Find("Frame").Find("Cross").GetComponent <Button>().onClick.AddListener(delegate { AboutUs.Exit(); }); GlobalSceneObjects.aboutUs.transform.Find("Frame").Find("Table").Find("InstMadm1nd").GetComponent <Button>().onClick.AddListener(delegate { AboutUs.TransferURL(1); }); GlobalSceneObjects.aboutUs.transform.Find("Frame").Find("Table").Find("InstPilgrim").GetComponent <Button>().onClick.AddListener(delegate { AboutUs.TransferURL(2); }); GlobalSceneObjects.aboutUs.transform.Find("Frame").Find("Table").Find("CreditsButton").GetComponent <Button>().onClick.AddListener(delegate { AboutUs.TransferURL(3); }); GlobalSceneObjects.aboutUs.transform.Find("Frame").Find("Table").Find("InstRaben_krausz").GetComponent <Button>().onClick.AddListener(delegate { AboutUs.TransferURL(4); }); GlobalSceneObjects.aboutUs.transform.Find("Frame").Find("Table").Find("VKOleg").GetComponent <Button>().onClick.AddListener(delegate { AboutUs.TransferURL(5); }); GlobalSceneObjects.writeToUs.transform.Find("Frame").Find("Cross").GetComponent <Button>().onClick.AddListener(delegate { WriteToUs.Exit(); }); GlobalSceneObjects.achievmentsInCanvas.transform.Find("Frame").Find("Cross").GetComponent <Button>().onClick.AddListener(delegate { Achievments.Exit(); }); GlobalSceneObjects.mainMenu.transform.Find("Sounds").GetComponent <Button>().onClick.AddListener(delegate { Sounds.Invoke(); SaveData.Save(); }); GlobalSceneObjects.mainMenu.transform.Find("Language").Find("ButtonLanguageRus").GetComponent <Button>().onClick.AddListener(delegate { Language.SetRussian(); }); GlobalSceneObjects.mainMenu.transform.Find("Language").Find("ButtonLanguageEng").GetComponent <Button>().onClick.AddListener(delegate { Language.SetEnglish(false); }); GlobalSceneObjects.showNextPage.GetComponent <Button>().onClick.AddListener(delegate { NextPage.Invoke(); }); GlobalSceneObjects.possessedTasks.transform.Find("BallLatestDevelopments").GetComponent <Button>().onClick.AddListener(delegate { SelectBall.Invoke("LatestDevelopments"); }); GlobalSceneObjects.possessedTasks.transform.Find("BallMechanics").GetComponent <Button>().onClick.AddListener(delegate { SelectBall.Invoke("Mechanics"); }); GlobalSceneObjects.possessedTasks.transform.Find("BallElementaryLaws").GetComponent <Button>().onClick.AddListener(delegate { SelectBall.Invoke("ElementaryLaws"); }); GlobalSceneObjects.possessedTasks.transform.Find("BallSimpleLever").GetComponent <Button>().onClick.AddListener(delegate { SelectBall.Invoke("SimpleLever"); }); GlobalSceneObjects.logicTasks.transform.Find("BallAcademicDegree").GetComponent <Button>().onClick.AddListener(delegate { SelectBall.Invoke("AcademicDegree"); }); GlobalSceneObjects.logicTasks.transform.Find("BallExperimentalProcess").GetComponent <Button>().onClick.AddListener(delegate { SelectBall.Invoke("ExperimentalProcess"); }); GlobalSceneObjects.logicTasks.transform.Find("BallScientistsNotes").GetComponent <Button>().onClick.AddListener(delegate { SelectBall.Invoke("ScientistsNotes"); }); GlobalSceneObjects.logicTasks.transform.Find("BallBestPractices").GetComponent <Button>().onClick.AddListener(delegate { SelectBall.Invoke("BestPractices"); }); GlobalSceneObjects.logicTasks.transform.Find("BallLightTests").GetComponent <Button>().onClick.AddListener(delegate { SelectBall.Invoke("LightTests"); }); GlobalSceneObjects.mainMenuBack.GetComponent <Button>().onClick.AddListener(delegate { GlobalVariables.stateForAnimation = (int)GlobalVariables.NameAnimation.MainMenu; HideLevelContent.Invoke(); HideLevelButtons.Invoke(); }); GlobalSceneObjects.selectLvlBack.GetComponent <Button>().onClick.AddListener(delegate { GlobalVariables.stateForAnimation = GlobalVariables.activeNameLevel; HideLevelContent.Invoke(); HideLevelButtons.Invoke(); }); GlobalSceneObjects.continueButton.GetComponent <Button>().onClick.AddListener(delegate { ContinueButton.Press(); }); GlobalSceneObjects.helpButton.transform.Find("CountHelp").Find("PictureHelp").GetComponent <Button>().onClick.AddListener(delegate { coroutines.InvokePressHelp(); }); GlobalSceneObjects.helpButton.transform.Find("HelpButton").GetComponent <Button>().onClick.AddListener(delegate { HelpButton.Press(); }); GlobalSceneObjects.skipLvl.GetComponent <Button>().onClick.AddListener(delegate { Skip.PressSkip(); }); GlobalSceneObjects.helpBoard.transform.Find("Cross").GetComponent <Button>().onClick.AddListener(delegate { GlobalSceneObjects.helpBoard.GetComponent <Animator>().SetTrigger("HideTrigger"); GlobalVariables.stateForAnimation = (int)GlobalVariables.NameAnimation.HelpBoard; }); GlobalSceneObjects.tableSkip.transform.Find("Yes").GetComponent <Button>().onClick.AddListener(delegate { Skip.PressYes(); }); GlobalSceneObjects.tableSkip.transform.Find("No").GetComponent <Button>().onClick.AddListener(delegate { Skip.PressNo(); }); GlobalSceneObjects.tableRate.transform.Find("Yes").GetComponent <Button>().onClick.AddListener(delegate { RateGame.PressYes(); }); GlobalSceneObjects.tableRate.transform.Find("Later").GetComponent <Button>().onClick.AddListener(delegate { RateGame.PressLater(); }); GlobalSceneObjects.tableRate.transform.Find("No").GetComponent <Button>().onClick.AddListener(delegate { RateGame.PressNo(); }); }