Example #1
0
        public LayMapTilePattern(LayEntity parentEntity)
        {
            m_ParentEntity = parentEntity;

            m_Filename = parentEntity.GetProperty("PatternFilename");
            m_Index = parentEntity.GetProperty("PatternIndex");
            m_Status = parentEntity.GetProperty("Status");
            int x = parentEntity.GetProperty("PatternX").Value.ToInteger()-1;
            int y = parentEntity.GetProperty("PatternY").Value.ToInteger()-1;
            m_Location = new Point(x, y);
        }
        public LayMapTilePattern(LayEntity parentEntity)
        {
            m_ParentEntity = parentEntity;

            m_Filename = parentEntity.GetProperty("PatternFilename");
            m_Index    = parentEntity.GetProperty("PatternIndex");
            m_Status   = parentEntity.GetProperty("Status");
            int x = parentEntity.GetProperty("PatternX").Value.ToInteger() - 1;
            int y = parentEntity.GetProperty("PatternY").Value.ToInteger() - 1;

            m_Location = new Point(x, y);
        }
Example #3
0
        private void ProcessPattern()
        {
            //throw new NotImplementedException();
            LayProperty pattern = GetProperty("PatternMatchData");

            if (pattern == null)
            {
                return;
            }

            Pattern = new LayMapTilePattern(this);
        }
Example #4
0
        public LayEntity(List <LayProperty> properties, int index)
        {
            for (int i = index; i < properties.Count; i++)
            {
                LayProperty prop = properties[i];
                switch (prop.Key)
                {
                case "EntityDescriptionID":
                    if (m_DescriptionID != "")
                    {
                        ProcessData();
                        TilesGrid = new LayMapTileGrid(this);
                        if (GetProperty("PatternMatchData") != null)
                        {
                            Pattern = new LayMapTilePattern(this);
                        }
                        ProcessGrids();
                        ProcessPattern();
                        return;
                    }
                    m_DescriptionID = prop.Value;
                    break;

                case "EndEntityList":
                    ProcessData();
                    TilesGrid = new LayMapTileGrid(this);
                    if (GetProperty("PatternMatchData") != null)
                    {
                        Pattern = new LayMapTilePattern(this);
                    }
                    ProcessGrids();
                    ProcessPattern();
                    return;
                }

                m_Properties.Add(prop);
            }
            ProcessData();

            TilesGrid = new LayMapTileGrid(this);
            if (GetProperty("PatternMatchData") != null)
            {
                Pattern = new LayMapTilePattern(this);
            }
            ProcessGrids();
            ProcessPattern();
        }
Example #5
0
 // Pushes the updated fields into the LayFile object
 public void ApplyChanges()
 {
     for (int y = 0; y < m_Y; y++)
     {
         LayProperty prop = m_TileProperties[y];
         prop.Key = "";
         for (int x = 0; x < m_X; x++)
         {
             if (x + 1 < m_X)
             {
                 prop.Key += Tiles[x, y].RawId + ",";
             }
             else
             {
                 prop.Key += Tiles[x, y].RawId;
             }
         }
     }
 }
Example #6
0
        public LayMap(LayFile lf)
        {
            bool foundMap = false;

            string[] tempStrings;

            // Load the map
            for (int i = 0; i < lf.Properties.Count; i++)
            {
                LayProperty prop = lf.Properties[i];

                if (prop.Key == "GridDimensions")
                {
                    tempStrings = prop.Value.Explode(",");

                    if (tempStrings.Length != 2)
                    {
                        throw new Exception("Invalid map: size incorrect");
                    }


                    Size       = new Size(int.Parse(tempStrings[0]), int.Parse(tempStrings[1]));
                    Tiles      = new LayMapTile[Size.Width, Size.Height];
                    m_tmpTiles = new LayMapTile[Size.Width, Size.Height];
                    foundMap   = true;
                    continue;
                }

                if (!foundMap)
                {
                    continue;
                }

                if (prop.Key == "")
                {
                    continue;
                }

                if (prop.Key == "DynamicATNData")
                {
                    break;
                }
                m_Y++;

                string[] parts = prop.Key.Explode(",");

                m_X = 0;

                try
                {
                    foreach (string part in parts)
                    {
                        Tiles[m_X, m_Y]      = new LayMapTile(part, m_X, m_Y);
                        m_tmpTiles[m_X, m_Y] = Tiles[m_X, m_Y];

                        m_X++;

                        LayEntity le = lf.FindEntityByGridLocation(m_X - 1, m_Y);
                        if (le != null)
                        {
                            le.TilesGrid.Tiles.Add(Tiles[m_X - 1, m_Y]);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ex = ex;
                }
                m_TileProperties.Add(prop);

                string mapPart = prop.Key;
                mapPart  = mapPart.Replace("20006A", "20000A");
                prop.Key = mapPart;
            }

            if (!foundMap)
            {
                throw new Exception("No map data found!");
            }

            for (int x = 0; x < Size.Width; x++)
            {
                for (int y = 0; y < Size.Height; y++)
                {
                    // Tiles[x, y] = m_tmpTiles[Size.Width - x - 1, y];       // something for later :P
                }
            }
        }