コード例 #1
0
    void UpdateTexts()
    {
        score.text                = "Points: " + WBH.GetScore().ToString();
        scoreMax.text             = "Max Level Score: " + WBH.GetMaxScore().ToString();
        scoreUntillNextMedal.text = "Next Medal: " + CalculateRemainingParticlesForNextMedal().ToString();
        int bags = GM.GetRemainingBags() + 1;

        remainingBags.text = "Bags Left: ";
        gold.text          = GM.GetGold().ToString();
        int test = 0;

        test = bagsLeft.Length - bags;

        if (test != 0)
        {
            bagsLeft[test - 1].SetActive(false);
        }

        if (GM.GetRemainingBags() == 0 && GameObject.FindGameObjectWithTag("bag") == null)
        {
            for (int i = 0; i < bagsLeft.Length; i++)
            {
                bagsLeft[i].SetActive(false);
            }
        }
    }
コード例 #2
0
    void SaveLevelInfo(int worldIndex, float p_levelScore, float p_levelMaxScore)
    {
        float goldAmount = GM.GetGold() * PE.GetGoldMultiplier();

        FH.WriteGoldAmount(goldAmount.ToString());

        bool p_completed;

        if (m_score > GM.GetMedalValue(0) * maxScore)
        {
            p_completed = true;
        }
        else
        {
            p_completed = false;
        }

        string fileDirectory;

        fileDirectory = "/world_" + worldIndex.ToString() + "_data.txt";
        fileDirectory = Application.dataPath + fileDirectory;
        if (!File.Exists(fileDirectory)) // If the file is there
        {
            int index = Application.loadedLevel;
            for (int u = 0; u < 10; u++)
            {
                System.IO.File.WriteAllText(fileDirectory, "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n ");
            }
            var lines = File.ReadAllLines(fileDirectory);
            lines[index] = Convert.ToInt32(p_completed).ToString() + ':' + p_levelScore.ToString() + ':' + p_levelMaxScore.ToString();
            File.WriteAllLines(fileDirectory, lines);
        }
        else
        {
            int index = Application.loadedLevel;
            var lines = File.ReadAllLines(fileDirectory);
            lines[index] = Convert.ToInt32(p_completed).ToString() + ':' + p_levelScore.ToString() + ':' + p_levelMaxScore.ToString();
            File.WriteAllLines(fileDirectory, lines);
        }
    }