// Load a previous snapshot of the map state
    public void LoadSnapshot(MapSnapshot snapshot)
    {
        if (dynamicTiles.Count != snapshot.dynamicTilesOccupation.Length || dynamicTiles.Count != snapshot.dynamicTilesPassability.Length)
        {
            throw new System.ArgumentException("Invalid Snapshot. Size does not match.");
        }

        for (int i = 0; i < dynamicTiles.Count; i++)
        {
            // Load passability
            if (snapshot.dynamicTilesPassability[i])
            {
                dynamicTiles[i].MakePassable();
            }
            else
            {
                dynamicTiles[i].MakeImpassable();
            }

            // Load occupation
            if (snapshot.dynamicTilesOccupation[i])
            {
                dynamicTiles[i].Occupy();
            }
            else
            {
                dynamicTiles[i].DeOccupy();
            }
        }
    }
 public void OnSnapshotReady(MapSnapshot p0)
 {
     using (var stream = new MemoryStream()) {
         p0.Bitmap.Compress(Bitmap.CompressFormat.Png, 100, stream);
         tcs.TrySetResult(stream.ToArray());
     }
 }
Esempio n. 3
0
 public GameSnapshot(MapSnapshot mapState, PlayerSnapshot playerState)
 {
     this.mapState    = mapState;
     this.playerState = playerState;
 }