示例#1
0
        public void UpdateSpawnRate(ContentManager content)
        {
            // Check if the tiles at the end needs to be removed
            if (layers[0][0].GetX() < -tileSize * 2)
            {
                List <BackgroundTile> currentLayer;
                BackgroundTile        newTile;
                float nextX = NextTileX();

                for (var layer = 0; layer < layers.Count - 1; layer++)
                {
                    newTile = new BackgroundTile(wall, tileSize, nextX, tileSize * layer);
                    newTile.LoadContent(content);
                    currentLayer = layers[layer];
                    currentLayer.Add(newTile);
                    currentLayer.RemoveAt(0);
                }

                newTile = new BackgroundTile(floor, tileSize, nextX, tileSize * (layers.Count - 1));
                newTile.LoadContent(content);
                currentLayer = layers[layers.Count - 1];
                currentLayer.Add(newTile);
                currentLayer.RemoveAt(0);
            }

            UpdateTiles();
        }
示例#2
0
        float NextTileX()
        {
            List <BackgroundTile> layer   = layers[0];
            BackgroundTile        endTile = layer[layer.Count - 1];
            float nextX = endTile.GetX() + tileSize;

            return(nextX);
        }