public SubTextureSelector(EditorScreen parentScreen, SpriteBatch spriteBatch, TileSelector tileSelector, int layerIndex, int subLayerIndex)
            : base(parentScreen, spriteBatch, new RectangleF())
        {
            this.Color = Microsoft.Xna.Framework.Graphics.Color.White;
            textureService = (ITextureService)Game.Services.GetService(typeof(ITextureService));
            this.isSelectingSubTexture = false;
            this.layerIndex = layerIndex;
            this.subLayerIndex = subLayerIndex;

            this.tileSelector = tileSelector;

            // We make the silly assumption that there is at least one Sheet loaded. he-he-he.
            this.selectingSheet = textureService.SheetsArray[0];

            // Generate our position based on the layer/subLayer-index we have.
            int padding = 10;
            int hzOffset = -(TileMap.TileWidth + padding);
            int oneDown = padding + TileMap.TileHeight;
            int vtOffset = layerIndex*(TileMap.SubLayerCount*oneDown + 2*padding) + (subLayerIndex * oneDown) + padding;
            Position = new Vector2(tileSelector.Bounds.Left + hzOffset, tileSelector.Bounds.Top + vtOffset);

            Microsoft.Xna.Framework.Rectangle rect =
                new Microsoft.Xna.Framework.Rectangle(0, 0, TileMap.TileWidth, TileMap.TileHeight);
            this.Bounds = new RectangleF(Position.X, Position.Y, rect.Width, rect.Height);
        }
 public ConvertTextureCommandHandler(
     IDirectoryRepository directoryRepository,
     ILogger logger,
     ITextureService textureService)
 {
     _directoryRepository = directoryRepository;
     _logger         = logger;
     _textureService = textureService;
 }
        public DestructableToggler(EditorScreen parentScreen, SpriteBatch spriteBatch, RectangleF bounds, TileSelector tileSelector)
            : base(parentScreen, spriteBatch, bounds)
        {
            this.tileSelector = tileSelector;
            this.textureService = (ITextureService)Game.Services.GetService(typeof(ITextureService));

            destructable = false;
            conflict = false;
        }
        public TileMap(World world, string fileName)
        {
            this.fileName = fileName;
            XDocument fileContents = ScreenManager.Instance.Content.Load<XDocument>(fileName);
            int width, height;

            width = Int32.Parse(fileContents.Root.Attribute("Width").Value);
            height = Int32.Parse(fileContents.Root.Attribute("Height").Value);

            tileWidth = Int32.Parse(fileContents.Root.Attribute("TileWidth").Value);
            tileHeight = Int32.Parse(fileContents.Root.Attribute("TileHeight").Value);

            layerCount = Int32.Parse(fileContents.Root.Attribute("LayerCount").Value);
            subLayerCount = Int32.Parse(fileContents.Root.Attribute("SubLayerCount").Value);

            tiles = new Tile[width, height];

            textureService = (ITextureService)ScreenManager.Instance.Services.GetService(typeof(ITextureService));

            IEnumerable<XElement> allSheets = fileContents.Descendants("sh");

            SubTextureSheet[] sheets = new SubTextureSheet[allSheets.Count<XElement>()];
            Dictionary<string, int> sheetIndex = new Dictionary<string, int>();

            int i;
            foreach (XElement sheet in allSheets)
            {
                i = Int32.Parse(sheet.Attribute("i").Value);
                string sheetFileName = sheet.Attribute("fn").Value;
                sheets[i] = textureService.GetSheet(sheetFileName);
                sheetIndex.Add(sheetFileName, i);
            }

            IEnumerable<XElement> allTileElements = fileContents.Descendants("T");

            // This is kind of dangerous, here. We assume that the XML is properly formatted.
            //  If it is not, our program will crash. This is not a huge deal, but if the debugger
            //  is highlighting a line below, you can blame Lou, unless you tried to hack a TileMap XML file by hand.
            int j = 0;
            i = 0;
            foreach (XElement tileElement in allTileElements)
            {
                Tile tile = TileFromXElement(tileElement, sheets, i, j, world);
                this.SetTile(tile, i, j);

                if (j < height - 1)
                {
                    ++j;
                }
                else
                {
                    ++i;
                    j = 0;
                }
            }
        }
        // This is mainly just used for the editor when creating new empty tilemaps.
        public TileMap(int cellX, int cellY, int tileWidth, int tileHeight, int layerCount, int subLayerCount)
        {
            this.layerCount = layerCount;
            this.subLayerCount = subLayerCount;
            this.tiles = new Tile[cellX,cellY];
            this.tileWidth = tileWidth;
            this.tileHeight = tileHeight;

            this.textureService = (ITextureService)ScreenManager.Instance.Services.GetService(typeof(ITextureService));
        }
        public EdgeToggler(EditorScreen parentScreen, SpriteBatch spriteBatch, RectangleF bounds, TileSelector tileSelector)
            : base(parentScreen, spriteBatch, bounds)
        {
            this.tileSelector = tileSelector;
            this.textureService = (ITextureService)Game.Services.GetService(typeof(ITextureService));

            // By default, solid:
            this.edges = new bool[4];
            edges[0] = edges[1] = edges[2] = edges[3] = true;
            edgesConflict = false;
        }
Example #7
0
 public LoadTextureFilesCommandHandler(ITextureService textureService)
 {
     _textureService = textureService;
 }
 public SaveButton(EditorScreen parentScreen, SpriteBatch spriteBatch, RectangleF bounds, World world)
     : base(parentScreen, spriteBatch, bounds)
 {
     this.world = world;
     this.textureService = (ITextureService)Game.Services.GetService(typeof(ITextureService));
 }
 public TileEngine()
 {
     textureService = (ITextureService)ScreenManager.Instance.Services.GetService(typeof(ITextureService));
 }
Example #10
0
 public GenerateTexturePreviewCommandHandler(ITextureService textureService)
 {
     _textureService = textureService;
 }