//return an editor tile layer data object, which will hold the necessary data for processing on the handler / manager layers
        public static EditorTileLayerDO OpenEditorLayer(string fileName, TextureHandler textureHandler, TexturePreviewHandler texturePreviewHandler)
        {
            try
            {
                EditorTileLayerDO openedTileLayerDO = EngineFileHandler.OpenEditorLayer(fileName);

                //loop through each texture name, load the texture and add it to the layer.
                //We need to decide what to do when textures have been deleted / no longer exist in that directory.. should we not load the level at all?
                //Or maybe have each tile hold a reference to the texture file, and just not draw the textures who's files have not been loaded in
                List<string> modifiedTextureFileNames = new List<string>();
                foreach (string textureFile in openedTileLayerDO.LayerTextureNameList)
                {
                    string trimmedTextureFile = FileUtility.GetFileNameWithParentFolder(textureFile);
                    if (textureHandler.HandleFile(textureFile))
                    {
                        texturePreviewHandler.HandleFile(textureFile);
                        //we just successfully handled that texture, it should be stored in memory now
                        openedTileLayerDO.EditorTileLayer.AddNewTexture(textureHandler.GetTexture(trimmedTextureFile));
                        //now add it to our modified texture file names, so we can pass it back to the client for display
                        modifiedTextureFileNames.Add(trimmedTextureFile);
                    }
                    else
                    {
                        //The texture still exists in memory, just add it to the tile layers texture list. It will be added in the correct index
                        //just make sure the texture handler contains it...
                        if (textureHandler.ContainsTexture(trimmedTextureFile))
                            openedTileLayerDO.EditorTileLayer.AddNewTexture(textureHandler.GetTexture(trimmedTextureFile));
                    }
                }

                openedTileLayerDO.LayerTextureNameList.Clear();
                foreach (string modifiedFile in modifiedTextureFileNames)
                {
                    openedTileLayerDO.LayerTextureNameList.Add(modifiedFile);
                }
                //return new Tuple with all texture that are handled correctly, and have had their file names modified

                return openedTileLayerDO;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #2
0
        public void DrawTileSides(SpriteBatch spriteBatch, int i, int j)
        {
            if (DrawSides(spriteBatch, i, j))
            {
                Rectangle rect1    = DrawRect();//gets the draw rect
                Texture2D texture  = TextureHandler.GetTexture(sideTexture);
                Point     drawPos  = (rect1.Location + new Point(i, j).MultBy(TileHandler.tileSize));
                Point     drawSize = (texture.Size() * GameMain.spriteScaling).ToPoint();

                spriteBatch.Draw(texture, new Rectangle(drawPos, drawSize).WorldToScreenCoords(), null, Color.White, default, new Vector2(texture.Width, 0), default, default);
Example #3
0
 public void DrawTileBottom(SpriteBatch spriteBatch, int i, int j)
 {
     if (DrawBottom(spriteBatch, i, j))
     {
         Rectangle rect1    = DrawRect();//gets the draw rect
         Texture2D texture  = TextureHandler.GetTexture(bottomTexture);
         Point     drawPos  = ((rect1.Location + new Point(0, rect1.Size.Y)) + (new Point(i, j).MultBy(TileHandler.tileSize)));
         Point     drawSize = new Point(rect1.Size.X, (int)(texture.Height * GameMain.spriteScaling));
         spriteBatch.Draw(texture, new Rectangle(drawPos, drawSize).WorldToScreenCoords(), Color.White);
     }
 }
Example #4
0
        protected override void Draw(GameTime gameTime)
        {
            //TODO UNCOMMENT THESE
            this.GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here

            this.spriteBatch.Begin();
            //begin draw

            //this.spriteBatch.Draw(this.camera.CameraTexture, this.camera.CameraPossition);
            this.map.Tiles.ForEach(tile => this.spriteBatch.Draw(TextureHandler.GetTexture(tile.Type), tile.Position));
            this.player.Draw(this.spriteBatch);
            this.shadow.Draw(this.spriteBatch);
            this.skeleton.Draw(this.spriteBatch);
            this.goblin.Draw(this.spriteBatch);
            this.gargoyle.Draw(this.spriteBatch);
            this.death.Draw(this.spriteBatch);
            this.sorceror.Draw(this.spriteBatch);

            //end draw
            this.spriteBatch.End();
            base.Draw(gameTime);
        }