示例#1
0
    void Initialize() //Levels data constructor
    {
        hintsCost = new int[6];

        try
        {
            CurrentTask temp = DataManager.Instance.GetData();
            type                = temp.gameType;
            infoTosave          = temp.savedData;
            rightAnswer         = temp.rightAnswer.ToLower();
            rightAnswerNoSpaces = rightAnswer.Replace(" ", string.Empty);
            imageText           = temp.imageText;
            completeLvlCoins    = temp.levelCost;
            int letterCount = rightAnswerNoSpaces.ToCharArray().Length;
            hintsCost[2] = DataManager.Instance.solveTaskCost;
            hintsCost[3] = DataManager.Instance.pixelateCost;
            hintsCost[4] = DataManager.Instance.plankCost;
            hintsCost[5] = DataManager.Instance.erasureCost;

            //Calculations to balance hints cost depending on the words length
            if (hintsCost[2] >= 100)
            {
                hintsCost[1] = Mathf.CeilToInt((hintsCost[2] / 1.8f) / 10) * 10;
                hintsCost[0] = Mathf.CeilToInt((hintsCost[2] * 2.5f / letterCount) / 10) * 10;
            }
            else
            {
                hintsCost[1] = Mathf.CeilToInt(hintsCost[2] / 1.8f);
                hintsCost[0] = Mathf.CeilToInt(hintsCost[2] * 2.5f / letterCount);
            }
            fullList = CreateListOfLetters(DataManager.Instance.randomLetters);
            StaticBehaviors.Shuffle(fullList);
        }
        catch (Exception)
        {
            Debug.LogError("You should start the game from 'StartMenu' scene. Or some references are broken");
        }
    }