public override void Init() { //读取 CCTV服务器信息(包括ServerName, ServerPort) SingletonMgr.GameGlobalInfo.ServerInfo = ServerInfo.DeserializeServerInfoFromXml(); //读取 站台信息 SingletonMgr.GameGlobalInfo.StationInfoList = StationInfoList.DeserializeStationInfoListFromXml(); // //读取 站台0闸机信息, 不是很有必要初始化该类数据 // SingletonMgr.GameGlobalInfo.ZhaJiDeviceInfoCollectionStation0 = ZhaJiDeviceInfoCollection.DeserializedZhaJiDeviceInfoCollectionAtStation0(); //读取 站台设备与位置点关联信息 // Stopwatch sw = new Stopwatch(); // sw.Start(); SingletonMgr.GameGlobalInfo.StationDeviceAndPointInfo = DeviceAndPointInfo.DeserializationDeviceAndPointInfo4Xml(); // sw.Stop(); // TimeSpan ts2 = sw.Elapsed; // UnityEngine.Debug.Log("LaunchModule总共花费" + ts2.TotalMilliseconds + "ms."); //读取 Station摄像头信息 Dictionary <System.UInt16, CameraInfoList> m_cameraInfoListDict = new Dictionary <ushort, CameraInfoList>(); //赵营 CameraInfoList zhaoYingCameraInfoList = CameraInfoList.DeserializeCameraInfoFromXml(AppConfigPath.ZhaoYingCameraInfoXmlPath); m_cameraInfoListDict.Add(5, zhaoYingCameraInfoList); SingletonMgr.GameGlobalInfo.CameraInfoListDict = m_cameraInfoListDict; }
//public static System.Device.Location.GeoCoordinateWatcher GeoCoordinateWatcher //{ // get // { // if (coordinateWatcher == null) // { // coordinateWatcher = new System.Device.Location.GeoCoordinateWatcher(); // if (coordinateWatcher.Status != System.Device.Location.GeoPositionStatus.Disabled) // { // coordinateWatcher.Start(); // } // } // return coordinateWatcher; // } //} public static void SaveState(IDictionary <string, object> state) { if (ListService.LastResult != null) { var infos = new StationInfoList(); infos.AddRange(listService.LastResult); state["application-list-service"] = infos; } }
public static StationInfoList DeserializeStationInfoListFromXml() { FileStream fs = new FileStream(AppConfigPath.StationInfoXmlPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); XmlSerializer xml = new XmlSerializer(typeof(StationInfoList)); StationInfoList stationInfoList = (StationInfoList)xml.Deserialize(fs); fs.Close(); return(stationInfoList); }
public static void SerializeStationInfoList2Xml() { StationInfoList list = new StationInfoList(); StationInfo station = new StationInfo(); station.Index = 5; station.Name = "赵营"; station.EngName = "ZhaoYing"; station.BuyTicketPointCount = 48; station.BuyTicketRestAreaPointCount = 8; station.EnterCheckTicketPointCount = 35; station.EnterCheckTicketRestAreaPointCount = 8; station.WaitTrainUpPointCount = 144; station.WaitTrainDownPointCount = 144; station.DownTrainUpPointCount = 72; station.DownTrainDownPointCount = 72; station.ExitCheckTicketPointCount = 35; station.ExitCheckTicketRestAreaPointCount = 8; station.EnterStationUpMaxNpcCount = 15; station.EnterStationDownMaxNpcCount = 15; station.ExitStationUpMaxNpcCount = 15; station.ExitStationUpGenerateNpcCount = 10; station.ExitStationDownMaxNpcCount = 15; station.ExitStationDownGenerateNpcCount = 10; station.GenerateNpcIntervalTime = 2.0f; list.stationInfoList.Add(station); if (File.Exists(AppConfigPath.StationInfoXmlPath)) { File.Delete(AppConfigPath.StationInfoXmlPath); } FileStream fileStream = new FileStream(AppConfigPath.StationInfoXmlPath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); StreamWriter sw = new StreamWriter(fileStream, System.Text.Encoding.UTF8); XmlSerializer xml = new XmlSerializer(list.GetType()); xml.Serialize(sw, list); sw.Close(); fileStream.Close(); }
private static void CreateStationInfoXml() { StationInfoList.SerializeStationInfoList2Xml(); Debug.Log("生成StationInfo.xml成功."); AssetDatabase.Refresh(); }