예제 #1
0
    // Use this for initialization
    void Start()
    {
        //Находим внешние скрипты
        callAchieve = FindObjectOfType <AchieveController>();
        callGui     = FindObjectOfType <GuI>();

        screenWidth = Screen.currentResolution.width;
        //Подганяем размер меню под размер экрана
        scale = new Vector3(screenWidth / 350, this.transform.localScale.y, this.transform.localScale.z);
        this.transform.localScale = scale;
    }
예제 #2
0
    void Start()
    {
        //Достаем значения переменных из кеша
        coins        = PlayerPrefs.GetInt("coins");
        health       = PlayerPrefs.GetInt("health");
        immortal     = PlayerPrefs.GetInt("immortal");
        infinity     = PlayerPrefs.GetInt("infinity");
        screenHeight = Screen.currentResolution.height;
        screenWidth  = Screen.currentResolution.width;
        //PlayerPrefs.DeleteAll();
        if (health < 10)
        {
            health += 1;
        }
        isImmortal = false;
        //Не отображать текст GameOver
        gameOver.enabled = false;
        //Находим скрипт AchieveController.
        callAchieve = FindObjectOfType <AchieveController>();

        //Расположение ГУИ обьектов по экрану...
        pointRect                    = new Rect(screenWidth * 50 / 100, screenHeight * 4 / 100, screenWidth * 40 / 100, screenHeight * 7 / 100);
        scoreRect                    = new Rect(screenWidth * 35 / 100, screenHeight * 36 / 100, screenWidth * 20 / 100, screenHeight * 10 / 100);
        bestScoreRect                = new Rect(screenWidth * 35 / 100, screenHeight * 41 / 100, screenWidth * 20 / 100, screenHeight * 10 / 100);
        coinsRect                    = new Rect(screenWidth * 35 / 100, screenHeight * 46 / 100, screenWidth * 20 / 100, screenHeight * 10 / 100);
        buttonRect                   = new Rect(Screen.width * buttonX / 100, Screen.height * buttonY / 100, Screen.width * buttonWidth / 100, Screen.height * buttonHeight / 100);
        gameOver.pixelInset          = new Rect(-screenWidth * 32 / 100, screenHeight * 9 / 100, screenWidth * 18 / 100, screenWidth * 10 / 100);
        healthRect                   = new Rect(screenWidth * 2.5f / 100, screenHeight * 9 / 100, screenWidth * 40 / 100, screenHeight * 7 / 100);
        infinityRect                 = new Rect(screenWidth * 2.5f / 100, screenHeight * 16 / 100, screenWidth * 40 / 100, screenHeight * 7 / 100);
        immortalRect                 = new Rect(screenWidth * 2.5f / 100, screenHeight * 24 / 100, screenWidth * 40 / 100, screenHeight * 7 / 100);
        heartTexture.pixelInset      = new Rect(-screenWidth * 45 / 100, screenHeight * 35 / 100, screenWidth * 4 / 100, screenWidth * 3 / 100);
        infinityHeartIcon.pixelInset = new Rect(-screenWidth * 45 / 100, screenHeight * 27 / 100, screenWidth * 4 / 100, screenWidth * 3 / 100);
        immortalIcon.pixelInset      = new Rect(-screenWidth * 45 / 100, screenHeight * 17 / 100, screenWidth * 5 / 100, screenWidth * 4 / 100);
        //Если в кеше есть лучший результат очков, достаем данное число.
        if (PlayerPrefs.HasKey("bestPoints"))
        {
            bestPoints = PlayerPrefs.GetInt("bestPoints");
        }
    }