예제 #1
0
    public bool Load(string name)
    {
        string filename = Application.persistentDataPath + DIRECTORY;

        if (!Directory.Exists(filename))
        {
            Directory.CreateDirectory(filename);
            return(false);
        }
        filename += ("/" + name);

        if (!File.Exists(filename))
        {
            Debug.LogWarning("File doesn't exsist!");
            return(false);
        }

        BinaryFormatter formatter = GetBinaryFormatter();
        FileStream      stream    = new FileStream(filename, FileMode.Open);
        SAV_Game        gameSav   = formatter.Deserialize(stream) as SAV_Game;

        // Apply data
        M_BuildingManager.SAddBuildings(gameSav.GetBuildings());
        M_SettlersManager.SAddSettlers(gameSav.settlers);
        M_InGameResourcesManager.SApplySavedData(gameSav.resources);



        return(true);
    }