Exemplo n.º 1
0
 public void Write(FileBytesWriter buffer)
 {
     buffer.WriteData(id);
     buffer.WriteData(type);
     buffer.WriteData(localX);
     buffer.WriteData(localY);
     buffer.WriteData(isRoot);
     buffer.WriteData(grids.Count);
     for (int i = 0; i < MaxGrid; i++)
     {
         if (i < grids.Count)
         {
             buffer.WriteData(grids[i].col);
             buffer.WriteData(grids[i].row);
         }
         else
         {
             buffer.WriteData(0);
             buffer.WriteData(0);
         }
     }
     buffer.WriteData(connections.Count);
     for (int i = 0; i < MaxConnection; i++)
     {
         if (i < connections.Count)
         {
             buffer.WriteData(connections[i]);
         }
         else
         {
             buffer.WriteData(0);
         }
     }
 }
Exemplo n.º 2
0
 public void Write(FileBytesWriter buffer)
 {
     buffer.WriteData(FileFlag);
     buffer.WriteData(FileVersion);
     WriteHeader(buffer);
     WriteBalls(buffer);
 }
Exemplo n.º 3
0
 private void WriteHeader(FileBytesWriter buffer)
 {
     buffer.WriteData(HeaderFlag);
     buffer.WriteData((int)mapType);
     buffer.WriteData(minCol);
     buffer.WriteData(maxBallId);
     buffer.WriteData(ballRadius);
 }
Exemplo n.º 4
0
 private void WriteBalls(FileBytesWriter buffer)
 {
     buffer.WriteData(BallFlag);
     buffer.WriteData(balls.Count);
     for (int i = 0; i < balls.Count; i++)
     {
         balls[i].Write(buffer);
     }
 }
Exemplo n.º 5
0
        public void Export()
        {
            LevelMapData data = new LevelMapData();

            data.mapType    = MapType;
            data.ballRadius = GridRadius;
            data.minCol     = MaxCol;
            data.maxBallId  = 0;

            foreach (var ball in Balls)
            {
                BallData ballData = new BallData();
                ballData.id     = ball.Value.Id;
                ballData.type   = (int)ball.Value.Type;
                ballData.localX = ball.Value.gameObject.transform.localPosition.x;
                ballData.localY = ball.Value.gameObject.transform.localPosition.y;
                ballData.grids.Add(new GridPosition(ball.Key.col, ball.Key.row));
                ballData.IsRoot = ball.Key.col == 0;
                foreach (var connect in ball.Value.Connections)
                {
                    ballData.connections.Add(connect.Id);
                }

                data.balls.Add(ballData);

                if (ballData.id > data.maxBallId)
                {
                    data.maxBallId = ballData.id;
                }
                if (ball.Key.col < data.minCol)
                {
                    data.minCol = ball.Key.col;
                }
            }

            FileStream      file   = new FileStream(GetLevelDataPath(LevelId), FileMode.Create);
            FileBytesWriter writer = new FileBytesWriter(file);

            data.Write(writer);
            file.Flush();
            file.Close();
        }