Beispiel #1
0
        /// <summary>
        /// Load a TileSystem from data file
        /// </summary>
        public TileSystem(GameLayerTiled gameLayer, TileSystemData tileSystemData)
        {
            Construct(gameLayer, tileSystemData.NumRows, tileSystemData.NumCols);

            // ---------- Populate 2D tile array with specified data ----------
            for (int i = 0; i < _numRows; i++)
                for (int j = 0; j < _numCols; j++)
                {
                    int current1Dindex = j + (i * _numCols);
                    TileRef tile = new TileRef(tileSystemData.Tiles[current1Dindex]);
                    _tiles[i, j] = tile;
                }
        }
Beispiel #2
0
        private TileRef[,] _tiles; // 2D tile array

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Create a new TileSystem
        /// </summary>
        /// <param name="defaultTile">ReferenceID for default tile which will fill the system</param>
        public TileSystem(GameLayerTiled gameLayer, int numRows, int numCols, short defaultTile)
        {
            Construct(gameLayer, numRows, numCols);

            // ---------- Populate 2D tile array with specified tile ----------
            for (int i = 0; i < _numRows; i++)
                for (int j = 0; j < _numCols; j++)
                {
                    TileRef tile = new TileRef(defaultTile, 0);
                    _tiles[i, j] = tile;
                }
        }