Ejemplo n.º 1
0
        /// <summary>
        /// 根据xml结点创建地图元素
        /// </summary>
        /// <param name="xmlNode">xml结点</param>
        /// <returns>地图结点元素</returns>
        public static ElementNode GetNode(XElement xmlNode)
        {
            Background back = Background.CreateInstance(xmlNode.Element("oneBack"), Coord.Empty);
            MapEvent   eve  = MapEvent.CreateInstance(xmlNode.Element("oneEvent"), Coord.Empty);

            return(new ElementNode(back, eve));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取事件元素的副本
 /// </summary>
 /// <param name="pos">副本出现的坐标</param>
 public MapEvent GetEvent(Coord pos)
 {
     if (_Event == null)
     {
         return(MapEvent.CreateInstance(MapEvent.EmptyXml, pos));
     }
     return(MapEvent.CreateInstance(_Event.XmlRecord, pos));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 加载事件层
        /// </summary>
        /// <param name="oneFloorArgs">事件层参数</param>
        /// <param name="oneFloor">待加载的楼层对象</param>
        private static void LoadEventLayer(XElement oneFloorArgs, FloorNode oneFloor)
        {
            XElement floorEventArgs = oneFloorArgs.Element("eventLayer");

            for (int row = 0; row < oneFloor.FloorSize.Row; row++)
            {
                //这里引入中间变量,为了提高查询速度
                XElement rowEventArgs = floorEventArgs.Elements("oneRow").ElementAt(row);
                for (int col = 0; col < oneFloor.FloorSize.Col; col++)
                {
                    try
                    {
                        oneFloor.EventMap[row, col] = MapEvent.CreateInstance(
                            rowEventArgs.Elements("oneEvent").ElementAt(col), new Coord(col, row));
                    }
                    catch (Exception)
                    {
                        oneFloor.EventMap[row, col] = null;
                    }
                }
            }
        }