示例#1
0
 public MapResponse(List <Brick> plst_Bricks, MatrixMapCell pmtx_MapCell, int pint_TileWidth, int pint_TileHeight)
 {
     fint_TileWidth  = pint_TileWidth;
     fint_TileHeight = pint_TileHeight;
     lstBricks       = plst_Bricks;
     mtxMapCell      = pmtx_MapCell;
 }
示例#2
0
        public MapInformation(MatrixMapCell mtxMapCell, List <Brick> lstBricks, int pint_TileWidth, int pint_TileHeight)
        {
            columns    = mtxMapCell.Columns;
            rows       = mtxMapCell.Rows;
            tileWidth  = pint_TileWidth;
            tileHeight = pint_TileHeight;
            brickIndex = new int[columns * rows];

            #region bricks
            bricks = new Brick[lstBricks.Count];
            for (int i = 0; i < lstBricks.Count; i++)
            {
                Brick brk = lstBricks[i];
                brk.fint_Index = i;
                bricks[i]      = brk;
            }
            #endregion

            #region brickIndex
            int index = 0;
            for (int x = 0; x < columns; x++)
            {
                for (int y = 0; y < rows; y++)
                {
                    MapCell cell = mtxMapCell[x, y];
                    brickIndex[index] = (cell != null) ? mtxMapCell[x, y].Brick.fint_Index : -1;
                    index++;
                }
            }
            #endregion
        }
示例#3
0
        public static MatrixMapCell FromMatrixMapCell(MatrixMapCell mmcMatrix, int pint_Columns, int pint_Rows)
        {
            MatrixMapCell newMatrix = new MatrixMapCell(pint_Columns, pint_Rows);

            mmcMatrix.CopyTo(newMatrix);
            return(newMatrix);
        }
示例#4
0
        public static void Save(string pstr_FullPathFileName, MatrixMapCell mtxMapCell, List <Brick> lstBricks, int pint_TileWidth, int pint_TileHeight)
        {
            string path = FileControler.GetPath(pstr_FullPathFileName);

            SaveBricks(lstBricks, path);
            MapInformation info        = new MapInformation(mtxMapCell, lstBricks, pint_TileWidth, pint_TileHeight);
            XmlSerializer  xSerializer = new XmlSerializer(typeof(MapInformation));

            System.IO.StreamWriter sWriter = new System.IO.StreamWriter(pstr_FullPathFileName, false);
            xSerializer.Serialize(sWriter, info);
            sWriter.Close();
        }
示例#5
0
        public void CopyTo(MatrixMapCell mtxMapCell, int startX, int startY)
        {
            int columns = this.Columns < mtxMapCell.Columns ? this.Columns : mtxMapCell.Columns;
            int rows    = this.Rows < mtxMapCell.Rows ? this.Rows : mtxMapCell.Rows;

            for (int x = startX; x < columns; x++)
            {
                for (int y = startY; y < rows; y++)
                {
                    mtxMapCell[x, y] = this[x, y];
                }
            }
        }
示例#6
0
        public MapResponse ToMapResponse()
        {
            MatrixMapCell mtx       = new MatrixMapCell(columns, rows);
            List <Brick>  lstBricks = this.ToBrickList();

            int ind = 0;

            for (int x = 0; x < columns; x++)
            {
                for (int y = 0; y < rows; y++)
                {
                    int brkInd = brickIndex[ind];
                    if (brkInd != -1)
                    {
                        mtx.AddBrick(x, y, lstBricks[brkInd]);
                    }
                    ind++;
                }
            }

            return(new MapResponse(lstBricks, mtx, tileWidth, tileHeight));
        }