コード例 #1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.G))
        {
            WorldSaver.SaveWorld();
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            WorldSaver.ClearSave();
        }

        if (Input.GetKeyDown(KeyCode.H))
        {
            WorldSaver.LoadWorld(Application.dataPath + "/Saves/WORLDSAVE02.06.2021.bingus");
        }
    }
コード例 #2
0
    public static void InitializeWorld(WorldLoader _worldLoader)
    {
        chunks      = new Dictionary <int, int, Chunk>();
        worldLoader = _worldLoader;

        // Load saved chunks
        if (!System.IO.File.Exists(Application.dataPath + "/Saves/WORLDSAVE02.06.2021.bingus"))
        {
            return;
        }
        ChunkData[] worldChunkData = WorldSaver.LoadWorld(Application.dataPath + "/Saves/WORLDSAVE02.06.2021.bingus");
        foreach (ChunkData chunkData in worldChunkData)
        {
            int x = chunkData.x;
            int y = chunkData.y;
            chunks[x, y] = GenerateChunkFromData(chunkData);
            worldLoader.InstantiateChunk(x, y);
        }
    }