示例#1
0
 public virtual void Read(SymBinaryReader reader)
 {
     LocalPos buf;
     reader.Read(out buf.X);
     reader.Read(out buf.Y);
     Pos = buf;
     bool buf2;
     reader.Read(out buf2);
     Blocking_ = buf2;
 }
示例#2
0
    public void Read(SymBinaryReader reader)
    {
        Name = reader.ReadString();
        StoryEvent = reader.ReadBoolean();
        Description = reader.ReadString();
        BaseProbability = Probability = reader.ReadSingle();

        byte terrainsCount = (byte)(System.Enum.GetNames(typeof(TerrainType)).Length - 1);
        TerrainWeights = new Dictionary<TerrainType, sbyte>(terrainsCount);
        byte weightsCount = reader.ReadByte();
        for (byte i = 0; i < weightsCount; ++i)
            TerrainWeights.Add((TerrainType)(1 << i), reader.ReadSByte());
        for (byte i = weightsCount; i < terrainsCount; ++i)
            TerrainWeights.Add((TerrainType)(1 << i), 0);

        TimeWeight = new GameEvent.TimeWeights
        (
             reader.ReadSByte(),
             reader.ReadSByte()
        );

        StateWeight = new GameEvent.StateWeights();
        //

        byte reactionCount = reader.ReadByte();
        Reactions = new List<GameEvent.Reaction>(reactionCount);
        for (byte i = 0; i < reactionCount; ++i)
        {
            string reacDesc = reader.ReadString();

            byte resultCount = reader.ReadByte();
            List<GameEvent.Reaction.Result> results = new List<GameEvent.Reaction.Result>(resultCount);
            for (byte j = 0; j < resultCount; ++j)
                results.Add(new GameEvent.Reaction.Result
                (
                     reader.ReadString(),
                    reader.ReadSingle()
                ));

            Reactions.Add(new GameEvent.Reaction(reacDesc, results));
        }
    }
示例#3
0
    public override void Read(SymBinaryReader reader)
    {
        base.Read(reader);
        for (ushort y = 0; y < Height; ++y)
            for (ushort x = 0; x < Width; ++x)
                reader.Read(out HeightMatrix[y, x]);

        for (ushort y = 0; y < Height; ++y)
            for (ushort x = 0; x < Width; ++x)
                reader.Read(out ForestMatrix[y, x]);

        for (ushort y = 0; y < Height; ++y)
            for (ushort x = 0; x < Width; ++x)
            {
                short buf;
                reader.Read(out buf);
                RiverSpriteID_Matrix[y, x] = buf == -1 ? null : (byte?)buf;
            }
        for (ushort y = 0; y < Height; ++y)
            for (ushort x = 0; x < Width; ++x)
                reader.Read(out RiverSpriteRotationMatrix[y, x]);

        for (ushort y = 0; y < Height; ++y)
            for (ushort x = 0; x < Width; ++x)
            {
                short buf;
                reader.Read(out buf);
                ClusterSpriteID_Matrix[y, x] = buf == -1 ? null : (byte?)buf;
            }

        for (ushort y = 0; y < Height; ++y)
            for (ushort x = 0; x < Width; ++x)
            {
                short buf;
                reader.Read(out buf);
                RoadSpriteID_Matrix[y, x] = buf == -1 ? null : (byte?)buf;
            }
        for (ushort y = 0; y < Height; ++y)
            for (ushort x = 0; x < Width; ++x)
                reader.Read(out RoadSpriteRotationMatrix[y, x]);

        byte riversCount;
        reader.Read(out riversCount);
        Rivers = new List<List<LocalPos>>(riversCount);
        for (byte i = 0; i < riversCount; ++i)
        {
            ushort riverLength;
            reader.Read(out riverLength);
            Rivers.Add(new List<LocalPos>(riverLength));
            for (ushort j = 0; j < riverLength; ++j)
            {
                LocalPos buf;
                reader.Read(out buf.X);
                reader.Read(out buf.Y);
                Rivers[i].Add(buf);
            }
        }
        byte clusterCount;
        reader.Read(out clusterCount);
        Clusters = new List<List<LocalPos>>(clusterCount);
        for (byte i = 0; i < clusterCount; ++i)
        {
            byte clusterSize;
            reader.Read(out clusterSize);
            Clusters.Add(new List<LocalPos>(clusterSize));
            for (byte j = 0; j < clusterSize; ++j)
            {
                LocalPos buf;
                reader.Read(out buf.X);
                reader.Read(out buf.Y);
                Clusters[i].Add(buf);
            }
        }
        byte roadCount;
        reader.Read(out roadCount);
        Roads = new List<List<LocalPos>>(roadCount);
        for (byte i = 0; i < roadCount; ++i)
        {
            ushort roadLength;
            reader.Read(out roadLength);
            Roads.Add(new List<LocalPos>(roadLength));
            for (ushort j = 0; j < roadLength; ++j)
            {
                LocalPos buf;
                reader.Read(out buf.X);
                reader.Read(out buf.Y);
                Roads[i].Add(buf);
            }
        }
    }
示例#4
0
    public virtual void Read(SymBinaryReader reader)
    {
        for (ushort y = 0; y < Height; ++y)
            for (ushort x = 0; x < Width; ++x)
            {
                int buf;
                reader.Read(out buf);
                TerrainMatrix[y, x] = (TerrainType)buf;
            }

        for (ushort y = 0; y < Height; ++y)
            for (ushort x = 0; x < Width; ++x)
            {
                short buf;
                reader.Read(out buf);
                HexSpriteID_Matrix[y, x] = buf == -1 ? null : (ushort?)buf;
            }
    }
示例#5
0
 public override void Read(SymBinaryReader reader)
 {
     base.Read(reader);
     reader.Read(out freeID);
     for (ushort y = 0; y < Height; ++y)
         for (ushort x = 0; x < Width; ++x)
         {
             byte objCount;
             reader.Read(out objCount);
             ObjectMatrix[y, x] = new Dictionary<ushort, Entity>(objCount);
             for (byte i = 0; i < objCount; ++i)
             {
                 UnityEngine.GameObject entBuf = new UnityEngine.GameObject(); //TODO
                 ushort idBuf;
                 reader.Read(out idBuf);
                 entBuf.AddComponent<Entity>().Read(reader);
                 ObjectMatrix[y, x].Add(idBuf, entBuf.GetComponent<Entity>()
                 );
             }
         }
 }
示例#6
0
 /// <summary>
 /// Пытается загрузить локальные карты чанка из файла.
 /// </summary>
 /// <returns><c>true</c>, если карты загружены, иначе <c>false</c>.</returns>
 /// <param name="chunkY">Координата по y.</param>
 /// <param name="chunkX">Координата по pos.X.</param>
 bool TryLoadFiledChunkLocalMaps(int chunkY, int chunkX)
 {
     string filePath = Path.Combine(ChunksDirectoryPath, chunkY + "_" + chunkX + "lm");
     if (File.Exists(filePath))
     {
         using (SymBinaryReader reader = new SymBinaryReader(File.Open(filePath, FileMode.Open)))
         {
             for (ushort y = 0; y < ChunkSize; ++y)
                 for (ushort x = 0; x < ChunkSize; ++x)
                     if (reader.ReadString() == "null")
                         LocalMaps[y, x] = null;
                     else
                     {
                         LocalMaps[y, x] = new LocalMap(LocalMapSize.X, LocalMapSize.Y);
                         LocalMaps[y, x].Read(reader);
                     }
         }
         return true;
     }
     return false;
 }
示例#7
0
 /// <summary>
 /// Пытается загрузить из файла чанк по координатам.
 /// </summary>
 /// <returns><c>true</c>, если чанк загружен, иначе <c>false</c>.</returns>
 /// <param name="chunkY">Координата по y.</param>
 /// <param name="chunkX">Координата по pos.X.</param>
 /// <param name="chunk">[out] Чанк.</param>
 bool TryLoadFiledChunk(int chunkY, int chunkX, out Chunk chunk)
 {
     string filePath = Path.Combine(ChunksDirectoryPath, chunkY + "_" + chunkX);
     if (File.Exists(filePath))
     {
         chunk = new Chunk(ChunkSize, ChunkSize);
         using (SymBinaryReader reader = new SymBinaryReader(File.Open(filePath, FileMode.Open)))
         {
             chunk.Read(reader);
         }
         return true;
     }
     chunk = null;
     return false;
 }
 void LoadEventsFromFile(string filename)
 {
     if (File.Exists(filename))
     {
         using (SymBinaryReader reader = new SymBinaryReader(File.Open(filename, FileMode.Open)))
         {
             while (reader.PeekChar() != -1)
             {
                 GameEvent buf = new GameEvent();
                 buf.Read(reader);
                 Events.Add(buf);
             }
         }
     }
     else
         throw new IOException("File with events do not exist.");
 }