コード例 #1
0
 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();
 }
コード例 #2
0
    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();
        }
    }
コード例 #3
0
    // 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");
            }
        }
    }