Beispiel #1
0
        protected override void Parse()
        {
            m_xreader.ReadRootNode();

            foreach (XmlElement node in m_xreader.rootChildNodes)
            {
                MapMeta meta = new MapMeta(node.GetAttribute("id"));
                meta.NameKey = node.GetAttribute("name");
                meta.Cols    = int.Parse(node.GetAttribute("cols"));
                meta.Rows    = int.Parse(node.GetAttribute("rows"));

                var monsterRoot = node.SelectSingleNode("Monsters");
                m_xreader.TryReadChildNodesAttr(monsterRoot, "Monster", meta.Monsters);

                MapMetaManager.AddMeta(meta);
            }
        }
Beispiel #2
0
        private void CreateMapData()
        {
            MapMeta m_mapMeta = MapMetaManager.GetMeta(LevelId);

            if (m_mapMeta == null)
            {
                Debug.LogError("Invalid Level id .. " + LevelId);
                return;
            }

            TMap.Instance.Init(m_mapMeta);
            m_builder = new DungeonMapBuilder(m_mapMeta);
            m_builder.CreateMap();
            m_builder.CopyUnWalkableToGrid(TMap.Instance.WalkableGrid);
            m_builder.CreateActor(TMap.Instance.WalkableGrid);
            m_builder.CopyActorUnWalkableToGrid(TMap.Instance.WalkableGrid);

            //读取加载地形数据, 并组装terrain3d comp
            m_terrainLayer = gameObject.GetOrCreateComponent <TileTerrainLayerComp>();
            m_terrainLayer.SetAssetGrid(m_builder.TerrainGrid);

            //读取加载没有逻辑的障碍
            m_blockLayer = gameObject.GetOrCreateComponent <TileBlockLayerComp>();
            m_blockLayer.SetAssetGrid(m_builder.BlockGrid);

            //加载没有逻辑的贴花
            m_decalLayer = gameObject.GetOrCreateComponent <TileDecalLayerComp>();
            m_decalLayer.SetAssetGrid(m_builder.DecalGrid);

            //加载角色数据
            m_actorLayer = gameObject.GetOrCreateComponent <TileActorLayerComp>();
            m_actorLayer.SetAssetGrid(m_builder.ActorGrid);

            //创建可通行debug层
            m_debugLayer = gameObject.GetOrCreateComponent <TileDebugLayerComp>();
            m_debugLayer.SetStarGrid(TMap.Instance.WalkableGrid);
        }