Exemplo n.º 1
0
    void Start()
    {
        level            = GameObject.FindGameObjectWithTag("Level");
        levelScript      = level.GetComponent <Level>();
        symbolScript     = GameObject.Find("Symbol").GetComponent <Symbol>();
        goalScript       = GameObject.Find("Goal").GetComponent <Goal>();
        backgroundScript = GameObject.Find("Background").GetComponent <ParallaxBackground> ();
        getActions();

        runningSprite = transform.GetChild(0).gameObject;
        slidingSprite = transform.GetChild(1).gameObject;

        if (GameObject.FindGameObjectWithTag("EndlessManager") != null)
        {
            endlessScript = GameObject.FindGameObjectWithTag("EndlessManager").GetComponent <EndlessManager>();
        }
    }
Exemplo n.º 2
0
    private void Start()
    {
        cameraController = FindObjectOfType <CameraController>();
        player           = FindObjectOfType <PlayerController>();
        StartCoroutine(LoadPlayButton(0.2f)); //load the big play button when the level loads, play that after 0.2 seconds
        pauseTab.SetActive(false);            //set the pause tab false
        succesTab.SetActive(false);           //set the succes tab false
        gameOverTab.SetActive(false);         //set the game over tab false
        uiTab.SetActive(true);                //set the ui active
        pauseButton.enabled = false;
        Camera.main.gameObject.AddComponent <CameraShake>();
        anim = startTab.GetComponentInChildren <Animator>();
        AdsManager.Instance.canShowAd = true;

        if (FindObjectOfType <AudioManager>().IsPlaying("MenuTheme"))
        {
            StartCoroutine(FindObjectOfType <AudioManager>().FadeOut("MenuTheme", .25f));
        }

        if (!FindObjectOfType <AudioManager>().IsPlaying("LevelTheme"))
        {
            StartCoroutine(FindObjectOfType <AudioManager>().FadeIn("LevelTheme", .5f));
        }

        endless              = FindObjectOfType <EndlessManager>();
        totalDiamonds        = GameObject.FindGameObjectsWithTag("Diamond").Length;
        totalSpecialDiamonds = GameObject.FindGameObjectsWithTag("SuperDiamond").Length;

        if (!Manager.Instance.soundOn)
        {
            soundButton.GetComponent <Image>().sprite = Manager.Instance.soundSprites[0];
        }
        else
        {
            soundButton.GetComponent <Image>().sprite = Manager.Instance.soundSprites[1];
        }
    }
Exemplo n.º 3
0
    public void OnGameSucces()
    {
        cameraController.Play(.2f, false);
        AudioManager.instance.PlaySound("SuccesSound");
        StartCoroutine(WaitThenUnplay(2.2f, .2f));
        gameOver = true;
        succesTab.SetActive(true);
        uiTab.SetActive(false);
        highScoreDiamonds.text                    = string.Format("{0} / {1}", diamonds, totalDiamonds);
        highScoreSpecialDiamonds.text             = string.Format("{0} / {1}", specialDiamonds, totalSpecialDiamonds);
        SaveManager.Instance.data.diamonds       += diamonds;
        SaveManager.Instance.data.specialDiamond += specialDiamonds;
        AdsManager.Instance.canShowAd             = true;

        if (isEndlessLevel)
        {
            EndlessManager endless = FindObjectOfType <EndlessManager>();
            PlayGamesPlatform.Instance.LoadScores(
                GPGSIds.leaderboard_blitexs_endless,
                LeaderboardStart.PlayerCentered,
                1,
                LeaderboardCollection.Public,
                LeaderboardTimeSpan.AllTime,
                (LeaderboardScoreData data) =>
            {
                if (data.Valid)
                {
                    long total = data.PlayerScore.value + (long)endless.score;
                    PlayServices.AddScoreToLeaderBoard(GPGSIds.leaderboard_blitexs_endless, total);
                }
            });
        }

        if (SaveManager.Instance.data.completedLevels == 0)
        {
            //first level that is played
            PlayServices.UnlockAchievement(GPGSIds.achievement_first_level);
        }
        if (!isSnowLevel)
        {
            SaveManager.Instance.CompleteLevel(Manager.Instance.sceneIndex, false);

            if (SaveManager.Instance.data.completedLevels >= 15 && !SaveManager.Instance.data.hasUnlockedSnowTheme)
            {
                //player has completed 15 levels so now he unlocks snow theme
                print("Congrats u unlocked snow theme");
                PlayServices.UnlockAchievement(GPGSIds.achievement_unlocked_snow_theme);
                unlockedSnowTheme.SetActive(true);
                SaveManager.Instance.data.hasUnlockedSnowTheme = true;
                SaveManager.Instance.Save();
            }
        }

        else if (isSnowLevel)
        {
            print("It is a snow level and now calling complete level");
            SaveManager.Instance.CompleteLevel(Manager.Instance.sceneIndex, true);
        }

        PlayGamesPlatform.Instance.LoadScores(
            GPGSIds.leaderboard_blitexs_diamonds,
            LeaderboardStart.PlayerCentered,
            1,
            LeaderboardCollection.Public,
            LeaderboardTimeSpan.AllTime,
            (LeaderboardScoreData data) =>
        {
            if (data.Valid)
            {
                long total = data.PlayerScore.value + (long)diamonds;
                PlayServices.AddScoreToLeaderBoard(GPGSIds.leaderboard_blitexs_diamonds, total);
            }
        });

        PlayServices.IncrementAchievement(GPGSIds.achievement_100_diamonds, diamonds);
        PlayServices.IncrementAchievement(GPGSIds.achievement_1000_diamonds, diamonds);
        PlayServices.IncrementAchievement(GPGSIds.achievement_10_000_diamonds, diamonds);

        StartCoroutine(WaitThenDestroy(1.5f));
    }