Esempio n. 1
0
        public void Import()
        {
            FTWorldMap worldMap = this;
            string     fileName = string.Format("Text/Map/{0}", worldMap.MapID);
            MapConfig  data     = new MapConfig();

            data.Load(fileName);
            worldMap.MapID      = data.MapID;
            worldMap.MapName    = data.MapName;
            worldMap.MapType    = data.MapType;
            worldMap.AllowPK    = data.AllowPK;
            worldMap.AllowRide  = data.AllowRide;
            worldMap.AllowTrade = data.AllowTrade;
            ImportEvents(data.MapEvents, worldMap);
            ImportDCFGByElement <FTBorn, MapBorn>(data.MapBorns, worldMap);
            ImportDCFGByElement <FTArea, MapArea>(data.MapAreas, worldMap);
            ImportDCFGByElement <FTAreaMine, MapAreaMine>(data.MapAreaMines, worldMap);
            ImportDCFGByElement <FTAreaMonster, MapAreaMonster>(data.MapAreaMonsters, worldMap);
            ImportDCFGByElement <FTBarrier, MapBarrier>(data.MapBarriers, worldMap);
            ImportDCFGByElement <FTMutiPoint, MapMutiPoint>(data.MapMutiPoints, worldMap);
            ImportDCFGByElement <FTNpc, MapNpc>(data.MapNpcs, worldMap);
            ImportDCFGByElement <FTPath, MapPath>(data.MapPaths, worldMap);
            ImportDCFGByElement <FTPortal, MapPortal>(data.MapPortals, worldMap);
            ImportDCFGByElement <FTStep, MapStep>(data.MapSteps, worldMap);
            ImportDCFGByElement <FTTimer, MapTimer>(data.MapTimers, worldMap);
            MapData = data;
        }
Esempio n. 2
0
        public void Export()
        {
            FTWorldMap worldMap = this;
            MapConfig  data     = new MapConfig();

            data.MapID      = worldMap.MapID;
            data.MapName    = worldMap.MapName;
            data.MapType    = worldMap.MapType;
            data.AllowPK    = worldMap.AllowPK;
            data.AllowRide  = worldMap.AllowRide;
            data.AllowTrade = worldMap.AllowTrade;
            ExportDCFGByElement <FTBorn, MapBorn>(data.MapBorns, worldMap);
            ExportDCFGByElement <FTArea, MapArea>(data.MapAreas, worldMap);
            ExportDCFGByElement <FTAreaMine, MapAreaMine>(data.MapAreaMines, worldMap);
            ExportDCFGByElement <FTAreaMonster, MapAreaMonster>(data.MapAreaMonsters, worldMap);
            ExportDCFGByElement <FTBarrier, MapBarrier>(data.MapBarriers, worldMap);
            ExportDCFGByElement <FTMutiPoint, MapMutiPoint>(data.MapMutiPoints, worldMap);
            ExportDCFGByElement <FTNpc, MapNpc>(data.MapNpcs, worldMap);
            ExportDCFGByElement <FTPath, MapPath>(data.MapPaths, worldMap);
            ExportDCFGByElement <FTPortal, MapPortal>(data.MapPortals, worldMap);
            ExportDCFGByElement <FTStep, MapStep>(data.MapSteps, worldMap);
            ExportDCFGByElement <FTTimer, MapTimer>(data.MapTimers, worldMap);
            ExportDCFGByElement <FTEvent, MapEvent>(data.MapEvents, worldMap);
            string fileName = string.Format("{0}/Resources/Text/Map/{1}.xml", Application.dataPath, data.MapID);

            data.Save(fileName);
        }
Esempio n. 3
0
        public void ExportDCFGByElement <TElement, TDCFG>(List <TDCFG> cfgList, FTWorldMap worldMap)
            where TElement : FTComponent
            where TDCFG :    MapComponent
        {
            List <TElement> list = worldMap.GetGroup <FTGroup <TElement> >().GetElements();

            for (int i = 0; i < list.Count; i++)
            {
                cfgList.Add(list[i].Export() as TDCFG);
            }
        }
Esempio n. 4
0
        public void ImportEvents(List <MapEvent> cfgList, FTWorldMap worldMap)
        {
            FTGroupEvent group = worldMap.GetGroup <FTGroupEvent>();

            for (int i = 0; i < cfgList.Count; i++)
            {
                MapEvent     d    = cfgList[i];
                EFTEventType t    = (EFTEventType)d.EventType;
                Type         type = Type.GetType("MAP." + t.ToString());
                group.AddEvent(type);
            }
        }
Esempio n. 5
0
        public void ImportDCFGByElement <TElement, TDCFG>(List <TDCFG> cfgList, FTWorldMap worldMap)
            where TElement : FTComponent
            where TDCFG :    MapComponent
        {
            FTGroup <TElement> group = worldMap.GetGroup <FTGroup <TElement> >();

            for (int i = 0; i < cfgList.Count; i++)
            {
                TElement element = group.AddElement();
                element.Import(cfgList[i]);
            }
        }
Esempio n. 6
0
        public static void DrawEvents(FTWorldMap map, List <FTEvent> events)
        {
#if UNITY_EDITOR
            GUILayout.Space(10);
            GUI.color = Color.green;
            if (GUILayout.Button("添加事件", FTGUIStyles.FTButtonStyle, GUILayout.Height(40)))
            {
                FTEditorHelper.ShowMenu(typeof(FTEvent), (obj) =>
                {
                    FTEvent e = map.GetGroup <FTGroupEvent>().AddEvent(obj as Type);
                    events.Add(e);
                });
            }
            for (int i = 0; i < events.Count; i++)
            {
                GUILayout.Label(events[i].name);
            }
            GUILayout.Space(10);
            GUI.color = Color.white;
#endif
        }
Esempio n. 7
0
        public override void OnInspectorGUI()
        {
            GUILayout.Space(10);
            FTWorldMap worldMap = target as FTWorldMap;

            base.OnInspectorGUI();
            GUILayout.Space(10);
            GUI.color = Color.red;
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("导入", FTGUIStyles.FTButtonStyle, GUILayout.Height(40)))
            {
                worldMap.Import();
            }

            GUI.color = Color.green;
            if (GUILayout.Button("导出", FTGUIStyles.FTButtonStyle, GUILayout.Height(40)))
            {
                worldMap.Export();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10);
        }