예제 #1
0
        private static LevelMapXMLData CreateMapData(DBLayoutPanel layout)
        {
            int index = 0;

            TileXMLData[] tiles = new TileXMLData[layout.Controls.Count];
            for (int row = 0; row < layout.RowCount; row++)
                for (int col = 0; col < layout.ColumnCount; col++)
                {
                    Tile c = layout.GetControlFromPosition(col, row) as Tile;

                    if (c.Color == null)
                        c.Color = new Color(255, 255, 255);

                    tiles[index] = new TileXMLData
                    {
                        Coordinates = new Vector2((col * c.Width), (row * c.Height)),
                        Dimensions = new Vector2(c.Width, c.Height),
                        TexturePath = "Tiles\\" + TrimExtension(c.TexturePath),
                        SoundEffectPath = c.SoundFxPath,
                        Color = c.Color,
                        Solid = c.Solid,
                        Empty = c.Empty
                    };
                    index++;
                }

            LevelMapXMLData mapData = new LevelMapXMLData();
            mapData.TileMapData = tiles;
            mapData.TilesAcross = layout.ColumnCount;
            mapData.TilesDown = layout.RowCount;

            return mapData;
        }
예제 #2
0
 public MapEditorForm(LevelMapXMLData mapData)
 {
     InitializeControls();
     PositionControls();
     SubscribeToControlEvents();
     LoadTileImages();
     openMapCancelSource = new System.Threading.CancellationTokenSource();
     AssignLayoutFromXmlData(mapData);
     InitializeComponent();
 }
예제 #3
0
        public static  async Task<DBLayoutPanel> MapDataToLayout(LevelMapXMLData mapData)
        {
            Task<DBLayoutPanel> task = new Task<DBLayoutPanel>(() =>
            {
                return CreateDBTablelayout(mapData);
            });

            task.Start();
            return await
                task;

        }
예제 #4
0
        private static DBLayoutPanel CreateDBTablelayout(LevelMapXMLData mapData)
        {
            int rows = mapData.TilesDown;
            int cols = mapData.TilesAcross;
            int index = 0;

            DBLayoutPanel layout = new DBLayoutPanel();
            layout.RowCount = rows;
            layout.ColumnCount = cols;
            for (int row = 0; row < layout.RowCount; row++)
                for (int col = 0; col < layout.ColumnCount; col++)
                {
                    layout.Controls.Add(new Tile(mapData.TileMapData[index]) { Row = row, Column = col }, col, row);
                    index++;
                }
            return layout;
        }
예제 #5
0
 public MazeMap(LevelMapXMLData mapData)
     : base(mapData)
 {
     foreach (Tile t in Map)
         t.Color = Color.White;
 }
예제 #6
0
 private async void AssignLayoutFromXmlData(LevelMapXMLData mapdata)
 {
     formLoaded = true;
     layout =
         await GetMapFromXmlData(mapdata);
     InitializeLayout();
 }//used by 2nd constructor
예제 #7
0
        private Task<DBLayoutPanel> GetMapFromXmlData(LevelMapXMLData mapData)
        {
            Task<DBLayoutPanel> openMapTask = Task<TableLayoutPanel>.Run(() =>
            {
                DBLayoutPanel newLayout =
                    LayoutConverter.MapDataToLayout(mapData).Result;

                return newLayout;
            });

            return openMapTask;
        }