コード例 #1
0
    public void save()
    {
        //Save score
        switch (stageName)
        {
        case "Small":
            if (ScoreManager.smallDays < dm.getDays())
            {
                ScoreManager.smallDays = dm.getDays();
            }
            if (ScoreManager.smallScore < pm.getScore())
            {
                ScoreManager.smallScore = pm.getScore();
            }
            break;

        case "Medium":
            if (ScoreManager.medDays < dm.getDays())
            {
                ScoreManager.medDays = dm.getDays();
            }
            if (ScoreManager.medScore < pm.getScore())
            {
                ScoreManager.medScore = pm.getScore();
            }
            break;

        case "Large":
            if (ScoreManager.largeDays < dm.getDays())
            {
                ScoreManager.largeDays = dm.getDays();
            }
            if (ScoreManager.largeScore < pm.getScore())
            {
                ScoreManager.largeScore = pm.getScore();
            }
            break;

        case "Mountain":
            if (ScoreManager.mountainDays < dm.getDays())
            {
                ScoreManager.mountainDays = dm.getDays();
            }
            if (ScoreManager.mountainScore < pm.getScore())
            {
                ScoreManager.mountainScore = pm.getScore();
            }
            break;

        case "Zen":
            if (ScoreManager.zenDays < dm.getDays())
            {
                ScoreManager.zenDays = dm.getDays();
            }
            if (ScoreManager.zenScore < pm.getScore())
            {
                ScoreManager.zenScore = pm.getScore();
            }
            break;
        }

        ScoreManager.save();

        //Save plant data
        pm.save(stageName);

        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/" + stageName + name + ".dat");

        SaveData data = new SaveData();

        data.weather = wm.getWeather();
        data.season  = sm.getSeason();
        data.dayNum  = dm.getDays();
        data.money   = ItemManager.money;

        //Items
        data.water      = ItemManager.waters;
        data.fertilizer = ItemManager.fertilizer;
        data.synth      = ItemManager.synth;
        data.heater     = ItemManager.heaters;
        data.spray      = ItemManager.sprays;
        data.cover      = ItemManager.cover;
        data.music      = ItemManager.music;

        bf.Serialize(file, data);
        file.Close();
    }