Beispiel #1
0
    /// <summary>
    /// saving the game
    /// </summary>
    public void SaveSlot1()
    {
        FileStream  fs = null;
        LoadingSave ls;

        try
        {
            if (savedUsedPoint.Count == 0)
            {
                ls = new LoadingSave();
            }
            else
            {
                addInPosition();
                ls = new LoadingSave(spawnPosX, spawnPosY, savedUsedPoint);
                print("Save " + spawnPosX[0] + " " + spawnPosY[0]);
            }

            fs = new FileStream(SAVEGAMEDATALOCATION + SAVESLOT, FileMode.Create);
            BinaryFormatter bf = new BinaryFormatter();
            bf.Serialize(fs, ls);
            fs.Close();
        }
        catch (Exception e)
        {
            print(e);
        }
        finally
        {
            if (fs != null)
            {
                fs.Close();
            }
        }
    }
Beispiel #2
0
    /// <summary>
    /// loading gamedata
    /// </summary>
    public void LoadSlot1()
    {
        FileStream fs = null;

        try
        {
            fs = new FileStream(SAVEGAMEDATALOCATION + SAVESLOT, FileMode.Open);
            BinaryFormatter bf = new BinaryFormatter();
            LoadingSave     ls = (LoadingSave)bf.Deserialize(fs);

            spawnPosX      = ls.spawnPosX;
            spawnPosY      = ls.spawnPosY;
            savedUsedPoint = ls.loadingUsedPoint;
            GetComponent <SpawnHouse_Lloyd>().getUsedLocation = ls.loadingUsedPoint;
            recreatingBuilding(spawnPosX, spawnPosY, savedUsedPoint);
            print("Load " + spawnPosX[0] + " " + spawnPosY[0]);
            print("Load");
            fs.Close();
        }
        catch (Exception e)
        {
            print(e);
        }
        finally
        {
            if (fs != null)
            {
                fs.Close();
            }
        }
    }