示例#1
0
 public void Create(int width, int height)
 {
     this.width = width;
     this.height = height;
     groundData = new Cell[width,height];
     entityData = new Cell[width, height];
     for (int y = 0; y < height; y++)
     {
         for (int x = 0; x < width; x++)
         {
             groundData[x, y] = new Cell();
             entityData[x, y] = new Cell();
         }
     }
 }
示例#2
0
        public void Load(string filename)
        {
            System.IO.BinaryReader br = new System.IO.BinaryReader(System.IO.File.Open(filename, System.IO.FileMode.Open));

            width = br.ReadInt32();
            height = br.ReadInt32();

            Create(width, height);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int attrCnt = 0;

                    groundData[x, y].type = br.ReadInt32();
                    attrCnt = br.ReadInt32();
                    for (int k = 0; k < attrCnt; k++)
                    {
                        int attr;
                        attr = br.ReadInt32();
                        groundData[x, y].attributes.Add(attr);
                    }
                }
            }

            int entityCnt = 0;
            entityCnt = br.ReadInt32();
            for (int e = 0; e < entityCnt; e++)
            {
                Cell entityCell = new Cell();
                int x, y, attrCnt;
                entityCell.type = br.ReadInt32();
                entityCell.empty = false;
                x = br.ReadInt32();
                y = br.ReadInt32();

                attrCnt = br.ReadInt32();
                for (int k = 0; k < attrCnt; k++)
                {
                    entityCell.attributes.Add(br.ReadInt32());
                }

                entityData[x, y] = entityCell;
            }
            br.Close();
        }