Exemple #1
0
    private void Start()
    {
        // Set up game's stuff
        Application.targetFrameRate = 60;
        Screen.orientation          = ScreenOrientation.Portrait;
        //Screen.SetResolution(540, 960, false);

        // Load profile
        SCR_Profile.Init();
        SCR_Profile.LoadProfile();

        bossSelecting = SCR_Profile.bossSelecting;

        RefreshSoundButtonStatus();
        UpdateMoneyNumber();
        UpdateBoss();

        dgbBoss[0].GetComponentInChildren <MeshRenderer>().sharedMaterial.SetFloat("_FlashAmount", 0);

        // Music
        SCR_WaitMusic.FadeIn();
        SCR_PunchMusic.FadeOut();
        SCR_RunSound.Stop();

        // OK, confirm that menu is now the first state
        menuLoaded = true;

        // Skip right into gameplay for tutorial

        /*
         * if (SCR_Profile.showTutorial == 1) {
         *      SceneManager.LoadScene("GSGameplay/SCN_Gameplay");
         * }
         */
    }
    public void Lose()
    {
        iTween.Stop(imgSecurityProgressFG.gameObject);
        imgSecurityProgressFG.GetComponent <SCR_SecurityProgress>().UpdateFlashAmount(0);

        imgSecurityProgressBG.gameObject.SetActive(false);
        imgSecurityProgressFG.gameObject.SetActive(false);

        pnlResult.SetActive(true);
        btnReplay.SetActive(true);
        btnMainMenu.SetActive(true);

        //txtResultTitle.text = boss.GetComponent<SCR_Boss>().resultTitle[SCR_Profile.bossSelecting];
        //txtResultTitle.fontSize = boss.GetComponent<SCR_Boss>().resultTitleFontSize[SCR_Profile.bossSelecting];

        const int FONT_MIN   = 80;
        const int FONT_MAX   = 155;
        const int LENGTH_MIN = 8;
        const int LENGTH_MAX = 16;

        txtResultTitle.text = SCR_Profile.bosses[SCR_Profile.bossSelecting].name;
        int l = txtResultTitle.text.Length;

        if (l < LENGTH_MIN)
        {
            l = LENGTH_MIN;
        }
        if (l > LENGTH_MAX)
        {
            l = LENGTH_MAX;
        }
        float r = 1 - (float)(l - LENGTH_MIN) / (LENGTH_MAX - LENGTH_MIN);

        txtResultTitle.fontSize = (int)(FONT_MIN + (FONT_MAX - FONT_MIN) * r);

        SCR_WaitMusic.FadeIn();
        SCR_PunchMusic.FadeOut();

        if (maxBossY > SCR_Profile.highScore)
        {
            imgHighScore.SetActive(true);
        }
        else
        {
            imgHighScore.SetActive(false);
        }

        SCR_Profile.ReportScore(maxBossY);
        txtPunchNumber.GetComponent <Text>().text  = maxCombo.ToString();
        txtHeightNumber.GetComponent <Text>().text = maxBossY.ToString();
        txtBestNumber.GetComponent <Text>().text   = SCR_Profile.highScore.ToString();

        int money = (int)(maxBossY * 0.5);

        AddMoney(money);

        txtMoneyNumber.GetComponent <Text>().text = "$" + totalReward.ToString();

        imgSecurityProgressBG.color = new Color(1, 1, 1, 0);
        imgSecurityProgressFG.color = new Color(1, 1, 1, 0);

        // -- //
        bool found = false;

        for (int i = 0; i < SCR_Profile.bosses.Length; i++)
        {
            if (SCR_Profile.bosses[i].unlocked == 0 && SCR_Profile.money >= SCR_Profile.bosses[i].cost)
            {
                if (SCR_Profile.bosses[i].recommended == 0)
                {
                    shouldSelect = i;
                    found        = true;
                    break;
                }
            }
        }

        if (found)
        {
            imgNotice.SetActive(true);
        }
        // -- //

        SCR_UnityAnalytics.FinishGame(maxBossY);
    }