コード例 #1
0
        public bool deleteLayer(string name)
        {
            TileLayer found = null;

            foreach (TileLayer layer in _layers)
            {
                if (layer.Layername == name)
                {
                    found = layer;
                    break;
                }
            }
            if (found == null)
            {
                return(false);
            }
            else
            {
                _layers.Remove(found);
            }
            return(true);
        }
コード例 #2
0
        public TileLayer MakeLayer(string layerName, string[] tileNames, int[,] tileMap, List<TileRef> _tileRefs, int tileWidth, int tileHeight)
        {
            int tileMapHeight = tileMap.GetLength(0); // row int[row,col]
            int tileMapWidth = tileMap.GetLength(1); // dim 0 = row, dim 1 = col
            TileLayer layer = new TileLayer();
            layer.Tiles = new Tile[tileMapHeight, tileMapWidth];
            layer.TileRefs = _tileRefs;
            layer.Layername = layerName;
            layer.TileWidth = tileWidth;
            layer.TileHeight = tileHeight;

                for (int x = 0; x < tileMapWidth; x++)  // look at columns in row
                    for (int y = 0; y < tileMapHeight; y++) // look at rows
                    {
                        layer.Tiles[y, x] =
                            new Tile
                            {
                                X = x,
                                Y = y,
                                Id = tileMap[y, x],
                                TileName = tileNames[tileMap[y, x]],
                                TileWidth = layer.TileWidth,
                                TileHeight = layer.TileHeight,
                                Passable = true,
                                TileRef = layer.TileRefs[tileMap[y,x]]
                            };
                    }
                return layer;
        }