public void Start() { PlayerDataUtil.LoadPlayerData(); // LevelUtil.printTutorialContent(); if (PlayerDataUtil.playerData.soundEnabled) { bgMusic.Play(); } else { bgMusic.Pause(); } }
public void toogleSound() { PlayerDataUtil.playerData.soundEnabled = !PlayerDataUtil.playerData.soundEnabled; if (PlayerDataUtil.playerData.soundEnabled) { BackgroundMusicController.Instance.bgMusic.Play(); soundImg.sprite = SpriteManager.Instance.spriteAtlas.GetSprite("sound_on"); } else { BackgroundMusicController.Instance.bgMusic.Pause(); soundImg.sprite = SpriteManager.Instance.spriteAtlas.GetSprite("sound_off"); } PlayerDataUtil.SavePlayerData(); }
public void JumpDoneValidate() { if (IsCurrentLadderIsLast()) { AudioManager.Instance.playSound(Constants.ResourcesName.winSound); // Save unlocked checkpoint to player data PlayerDataUtil.playerData.unlockedCheckpoint++; PlayerDataUtil.SavePlayerData(); // Load next level Level level = LevelUtil.LoadLevelData(LevelUtil.getCurrentLevel().index + 1); LevelUtil.setCurrentLevel(level); Refresh(); } }
// All logic when end a game level public IEnumerator EndGameLogic(float delay) { yield return(new WaitForSeconds(delay)); if (!ended && clickedNumber >= numberOfClick && !isAnimating && findGameObjectsWithTag("bullet").Length <= 0) { ended = true; RemoveAllCurrentBombs(); RemoveAllCurrentWalls(); StopCoroutine(coroutine); // End this level, show the result panel resultPanel.SetActive(true); resultPanel.transform.DOScale(new Vector3(0.5f, 0.5f, 0), 1); // Animate to show result panel // Unlocked level if need int remainBombs = findGameObjectsWithTag("bomb").Length; bool isNextLevelUnlocked = false; if (level.index < Constants.TOTAL_LEVEL - 1) { isNextLevelUnlocked = level.index + 1 <= PlayerDataUtil.playerData.unlockedLevelIndex; if (remainBombs <= 0) { if (!isNextLevelUnlocked) { // Unlock next level if it was locked PlayerDataUtil.playerData.unlockedLevelIndex += 1; isNextLevelUnlocked = true; } } } // Fill result panel ResultPanelController resultsPanelController = resultPanel.GetComponent <ResultPanelController>(); resultsPanelController.fillData(remainBombs, isNextLevelUnlocked); PlayerDataUtil.playerData.totalMatch++; PlayerDataUtil.SavePlayerData(); // Show ads depend on total match of player if (PlayerDataUtil.playerData.totalMatch % Constants.MATCH_COUNT_EACH_POPUP_ADS == 0) { // TODO: Display popup ads Debug.LogError("Display ads"); } } }
// Use this for initialization void Start() { PlayerDataUtil.SavePlayerDataFirstTime(); PlayerDataUtil.LoadPlayerData(); for (int i = 0; i < Constants.TOTAL_LEVEL; i++) { GameObject levelPrefabClone = Instantiate(levelPrefab); // Add levelPrefab to levels canvas levelPrefabClone.transform.SetParent(transform); // Set properties for level prefabs children components // Set level name levelPrefabClone.GetComponentInChildren <Text>().text = (i + 1) + ""; // Set level image, depend on status of level of players // Get user data bool unlocked = i + 1 <= PlayerDataUtil.playerData.unlockedLevelIndex; // Set level data and even when click Button b = levelPrefabClone.GetComponent <Button>(); if (unlocked) { levelPrefabClone.GetComponentInChildren <Image>().sprite = levelUnlocked; b.onClick.AddListener(() => GoToLevel(i)); latestLevelUnlockedPrefab = levelPrefabClone; } else { levelPrefabClone.GetComponentInChildren <Image>().sprite = levelLocked; b.interactable = false; } } SnapTo(latestLevelUnlockedPrefab.GetComponent <RectTransform>()); }
void Awake() { PlayerDataUtil.SavePlayerDataFirstTime(); // TODO: remove in production PlayerDataUtil.LoadPlayerData(); }