Example #1
0
 public Map(int rows, int columns)
 {
     this.Rows              = rows;
     this.Columns           = columns;
     this.Cells             = new MapCellList();
     this.Patterns          = new MapPatternList();
     this.IncludeDimensions = true;
     this.Reduction         = ReductionType.None;
 }
Example #2
0
        private MapCellList ParseTMXData(TMXData dat)
        {
            MapCellList list = new MapCellList();

            string[] values = dat.Value.Split(',').Select(sValue => sValue.Trim()).ToArray();
            foreach (string val in values)
            {
                list.Add(new MapCell(Int32.Parse(val)));
            }
            return(list);
        }
Example #3
0
        public ElementList ToElementList(string layerName)
        {
            TMXLayer thisLayer = this.Map.Layers.FirstOrDefault(s => s.Name == layerName);

            if (thisLayer == null)
            {
                throw new Exception("Unable to find layer '" + layerName + "'");
            }

            ElementList newElementList = new ElementList();
            MapCellList list           = ParseTMXData(thisLayer.Data);

            int tileX = 0;
            int tileY = 0;

            foreach (MapCell cell in list)
            {
                if (cell.TileID > 0)
                {
                    TMXTile tile = GetTileById(cell.TileID);
                    string  type = tile.Properties.FirstOrDefault(p => p.Name.ToLower() == "type").Value;
                    if (type == null)
                    {
                        type = "0";
                    }
                    string state = tile.Properties.FirstOrDefault(p => p.Name.ToLower() == "state").Value;
                    if (state == null)
                    {
                        state = "0";
                    }

                    Element ele = new Element()
                    {
                        Type  = type,
                        State = state,
                        X     = (tileX * this.Map.TileWidth),
                        Y     = (tileY * this.Map.TileHeight)
                    };
                    newElementList.Add(ele);
                }

                tileX++;
                if (tileX > this.Map.Width)
                {
                    tileX = 0;
                    tileY++;
                }
            }

            return(newElementList);
        }
Example #4
0
 public Map()
 {
     this.Cells     = new MapCellList();
     this.Reduction = ReductionType.None;
     this.Patterns  = new MapPatternList();
 }
Example #5
0
 public MapPattern()
 {
     this.Cells = new MapCellList();
     this.Count = 1;
 }