void OnEnable() { isStatusPopupShow = false; NextButton.interactable = true; RetryButton.interactable = true; RetryFailButton.interactable = true; MapButton.interactable = true; hideGageIcons(); MonsterGageSliderA.gameObject.SetActive(false); // MonsterGageSliderB.gameObject.SetActive (false); isWin = GameplayController.Instance.CurrentLevelStars > 0; GameObject go = GameObject.Find("monster"); if (go != null) { MonsterSpritesController msc = go.GetComponent <MonsterSpritesController> (); if (msc != null && msc.monster != null) { monster = msc.monster; } Animator animController; animController = go.GetComponentInChildren <Animator> (); if (animController != null) { animController.SetInteger("IdleState", 0); // animController.SetInteger ("EmotionState", 0); animController.SetInteger("EatState", 0); animController.SetInteger("EmotionState", (isWin) ? monster.HappyStates [UnityEngine.Random.Range(0, monster.HappyStates.Count)] : monster.SadStates [UnityEngine.Random.Range(0, monster.SadStates.Count)]); } } particles.enabled = isWin; transform.GetChild(0).gameObject.GetComponent <Image> ().sprite = isWin ? WinScreen : LoseScreen; statusQueue.Enqueue(status.FirstZoomIn); if (isWin) { AudioController.Instance.PlaySound(GameWonFanfare); Invoke("UnPauseMusic", 1.4f); Analitics.Instance.treckScreen("Level " + (GameplayController.Instance.CurrentLevelIndex + 1) + " Success - Profile: " + UsersController.Instance.CurrentProfileId); Analitics.Instance.treckEvent(AnaliticsCategory.GamePlay, AnaliticsAction.LevelSuccess + "_" + (GameplayController.Instance.CurrentLevelIndex + 1).ToString(), GameplayController.Instance.SucsessSegment.ToString() + " puzzles"); } else { AudioController.Instance.PlaySound(GameLostFanfare); Analitics.Instance.treckScreen("Level " + (GameplayController.Instance.CurrentLevelIndex + 1) + " Fail - Profile: " + UsersController.Instance.CurrentProfileId); Analitics.Instance.treckEvent(AnaliticsCategory.GamePlay, AnaliticsAction.LevelFail + "_" + (GameplayController.Instance.CurrentLevelIndex + 1).ToString(), GameplayController.Instance.SucsessSegment.ToString() + " puzzles"); } UIController.Instance.ClosePopup(UIController.Instance.GamePanel); // if (GameplayController.Instance != null && GameplayController.Instance.CurrentActive != null) { // GameplayController.Instance.CurrentActive.SetMonsterState (isWin ? MonsterCalloutController.MonsterState.Happy : MonsterCalloutController.MonsterState.Sad); // } if (isWin && GameplayController.Instance.NumOfLevels >= GameplayController.Instance.CurrentLevelIndex + 1) { UserInfo.Instance.SetHighestOpenLevel(GameplayController.Instance.CurrentLevelIndex + 1); } //NextButton.gameObject.SetActive (UserInfo.Instance.GetHighestOpenLevel() >= GameplayController.Instance.CurrentLevelIndex + 1 ); bool hasNextLevel = GameplayController.Instance.CurrentLevelIndex != GameplayController.Instance.NumOfLevels - 1; // button for win NextButton.gameObject.SetActive(isWin && hasNextLevel); RetryButton.gameObject.SetActive(isWin); // buttons for lose RetryFailButton.gameObject.SetActive(!isWin); Stars.SetActive(isWin); ScoreText.text = GameplayController.Instance.CurrentLevelScore.ToString(); // this is to stop loop of happy / sad animations // if (GameplayController.Instance != null && GameplayController.Instance.CurrentActive != null) { // GameplayController.Instance.CurrentActive.SetMonsterState (MonsterCalloutController.MonsterState.Idle); // } transform.localScale = new Vector3(3.1f, 3.1f, 3.1f); Camera.main.orthographicSize = 5f; }
void OnEnable() { //isStatusPopupShow = false; NextButton.interactable = true; RetryButton.interactable = true; RetryFailButton.interactable = true; MapButton.interactable = true; GameCompleteButton.interactable = true; hideGageIcons(); MonsterGageSliderA.gameObject.SetActive(false); //MonsterGageSliderB.gameObject.SetActive (false); isWin = GameplayController.Instance.CurrentLevelStars > 0; GameObject go = GameObject.Find("monster"); if (go != null) { MonsterSpritesController msc = go.GetComponent <MonsterSpritesController>(); if (msc != null && msc.monster != null) { monster = msc.monster; } Animator animController; animController = go.GetComponentInChildren <Animator>(); if (animController != null) { animController.SetInteger("IdleState", 0); //animController.SetInteger ("EmotionState", 0); animController.SetInteger("EatState", 0); animController.SetInteger("EmotionState", (isWin) ? monster.HappyStates[UnityEngine.Random.Range(0, monster.HappyStates.Count)] : monster.SadStates[UnityEngine.Random.Range(0, monster.SadStates.Count)]); } } particles.enabled = isWin; transform.GetChild(0).gameObject.GetComponent <Image>().sprite = isWin ? WinScreen : LoseScreen; if (!addAddVoiceTutorial(isWin)) { onVoiceTutorialDone(); } if (isWin) { AudioController.Instance.PlaySound(GameWonFanfare); Invoke("UnPauseMusic", 1.4f); Analytics.Instance.TrackScene(FirebaseCustomSceneNames.LevelWinScene); AnalyticsLogger.TrackSpecificLevelComplete(GameplayController.Instance.CurrentLevelIndex + 1); Analytics.Instance.TrackEvent(FirebaseCustomEventNames.EventLevelWin, new Parameter(FirebaseCustomParameterNames.ParameterLevel, GameplayController.Instance.CurrentLevelIndex + 1)); } else { AudioController.Instance.PlaySound(GameLostFanfare); Analytics.Instance.TrackScene(FirebaseCustomSceneNames.LevelFailScene); Analytics.Instance.TrackEvent(FirebaseCustomEventNames.EventLevelFail, new Parameter(FirebaseCustomParameterNames.ParameterLevel, GameplayController.Instance.CurrentLevelIndex + 1)); } UIController.Instance.ClosePopup(UIController.Instance.GamePanel); //if (GameplayController.Instance != null && GameplayController.Instance.CurrentActive != null) { //GameplayController.Instance.CurrentActive.SetMonsterState (isWin ? MonsterCalloutController.MonsterState.Happy : MonsterCalloutController.MonsterState.Sad); //} if (isWin && GameAssets.Instance.NumOfLevels >= GameplayController.Instance.CurrentLevelIndex + 1) { if (UsersController.Instance.userData().setHighestOpenLevel(GameplayController.Instance.CurrentLevelIndex + 1)) { int newItemId = DressingController.Instance.isNewItemAvailable(GameplayController.Instance.CurrentLevelIndex); if (newItemId > 0) { UsersController.Instance.userData().setNewAvailableAccessorie(newItemId); } } } //NextButton.gameObject.SetActive (UserInfo.Instance.GetHighestOpenLevel() >= GameplayController.Instance.CurrentLevelIndex + 1 ); bool hasNextLevel = GameplayController.Instance.CurrentLevelIndex != GameAssets.Instance.NumOfLevels - 1; if (isWin && !hasNextLevel) { GameCompleteButton.gameObject.SetActive(true); NextButton.gameObject.SetActive(false); RetryButton.gameObject.SetActive(false); RetryFailButton.gameObject.SetActive(false); MapButton.gameObject.SetActive(false); } else { GameCompleteButton.gameObject.SetActive(false); // button for win NextButton.gameObject.SetActive(isWin && hasNextLevel); RetryButton.gameObject.SetActive(isWin); // buttons for lose RetryFailButton.gameObject.SetActive(!isWin); MapButton.gameObject.SetActive(true); } Stars.SetActive(isWin); ScoreText.text = GameplayController.Instance.CurrentLevelScore.ToString(); transform.localScale = new Vector3(3.1f, 3.1f, 3.1f); Camera.main.orthographicSize = 5f; }