コード例 #1
0
    public Util.LinkedList <byte> Serialize()
    {
        Util.LinkedList <byte> bytes = new Util.LinkedList <byte>();
        bytes.Append(BitConverter.GetBytes((int)Type));

        foreach (CelestialBodyType type in Enum.GetValues(typeof(CelestialBodyType)))
        {
            bytes.Append(BitConverter.GetBytes(Address[type]));
        }

        bytes.Prepend(BitConverter.GetBytes(bytes.Length + 4));
        return(bytes);
    }
コード例 #2
0
ファイル: Network.cs プロジェクト: MatthewGoff/MapGenerator
    public Util.LinkedList <byte> Serialize()
    {
        Util.LinkedList <byte> bytes = new Util.LinkedList <byte>();
        bytes.Append(BitConverter.GetBytes(Edges.Count));

        foreach (CelestialBodies.CelestialBody[] edge in Edges)
        {
            bytes.Append(edge[0].ID.Serialize());
            bytes.Append(edge[1].ID.Serialize());
        }

        bytes.Prepend(BitConverter.GetBytes(bytes.Length + 4));
        return(bytes);
    }
コード例 #3
0
    private void SaveMap()
    {
        Util.LinkedList <byte> linkedList = Map.Serialize();
        linkedList.Append(Network.Serialize());
        byte[] bytes = new byte[linkedList.Length];
        int    i     = 0;

        foreach (byte b in linkedList)
        {
            bytes[i++] = b;
        }
        System.IO.File.WriteAllBytes("MapInfo.dat", bytes);
    }