Пример #1
0
    public bool Load(int saveid)
    {
        if (File.Exists(Application.persistentDataPath + "/ship" + saveid + ".ass"))
        {
            print("Loading Ship...");
            BinaryFormatter bf = new BinaryFormatter();
            FileStream      fs = File.Open(Application.persistentDataPath + "/ship" + saveid + ".ass", FileMode.Open);

            SerialShip saveData = (SerialShip)bf.Deserialize(fs);
            fs.Close();

            foreach (int i in saveData.unlockedParts)
            {
                boughtParts.Add(i);
            }

            for (int i = 0; i < upgrades.Length; i++)
            {
                upgrades[i].bought = saveData.upgrades[i].unlocked;
            }

            cockpitColor = unshittyColor(saveData.cockpitColor);
            engineColor  = unshittyColor(saveData.engineColor);
            hullColor    = unshittyColor(saveData.hullColor);
            weaponColor  = unshittyColor(saveData.weaponColor);
            wingColor    = unshittyColor(saveData.wingColor);

            cockpitIndex = saveData.cockpitIndex;
            engineIndex  = saveData.engineIndex;
            hullIndex    = saveData.hullIndex;
            weaponIndex  = saveData.weaponIndex;
            wingIndex    = saveData.wingIndex;

            currentSaveID = saveid;

            UpdateSelected();

            return(true);
        }

        return(false);
    }
Пример #2
0
    public void Save()
    {
        SerialShip saveData = new SerialShip();

        int[]           partData    = new int[boughtParts.Count];
        SerialUpgrade[] upgradeData = new SerialUpgrade[upgrades.Length];

        saveData.cockpitColor = shittyColor(cockpitColor);
        saveData.engineColor  = shittyColor(engineColor);
        saveData.hullColor    = shittyColor(hullColor);
        saveData.weaponColor  = shittyColor(weaponColor);
        saveData.wingColor    = shittyColor(wingColor);

        saveData.cockpitIndex = cockpitIndex;
        saveData.engineIndex  = engineIndex;
        saveData.hullIndex    = hullIndex;
        saveData.weaponIndex  = weaponIndex;
        saveData.wingIndex    = wingIndex;

        int i = 0;

        foreach (Upgrade u in upgrades)
        {
            upgradeData[i++] = u.Save();
        }

        i = 0;
        foreach (int j in boughtParts)
        {
            partData[i++] = j;
        }

        saveData.unlockedParts = partData;
        saveData.upgrades      = upgradeData;

        BinaryFormatter bf = new BinaryFormatter();

        FileStream fs = File.Create(Application.persistentDataPath + "/ship" + currentSaveID + ".ass");

        bf.Serialize(fs, saveData);
        fs.Close();
    }
Пример #3
0
	public void Save() {
		SerialShip saveData 	    = new SerialShip();
		int[] partData 				= new int[boughtParts.Count];
		SerialUpgrade[] upgradeData = new SerialUpgrade[upgrades.Length];

		saveData.cockpitColor = shittyColor (cockpitColor);
		saveData.engineColor	= shittyColor (engineColor);
		saveData.hullColor		= shittyColor (hullColor);
		saveData.weaponColor	= shittyColor (weaponColor);
		saveData.wingColor		= shittyColor (wingColor);

		saveData.cockpitIndex = cockpitIndex;
		saveData.engineIndex 	= engineIndex;
		saveData.hullIndex 		= hullIndex;
		saveData.weaponIndex 	= weaponIndex;
		saveData.wingIndex 		= wingIndex;

		int i = 0;
		foreach (Upgrade u in upgrades)
			upgradeData[i++] = u.Save();

		i = 0;
		foreach (int j in boughtParts) 
			partData[i++] = j;

		saveData.unlockedParts 	= partData;
		saveData.upgrades				= upgradeData;

		BinaryFormatter bf = new BinaryFormatter();
		
		FileStream fs = File.Create (Application.persistentDataPath + "/ship" + currentSaveID + ".ass");
		
		bf.Serialize (fs, saveData);
		fs.Close ();
	}