Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
    //反序列化
    public static CameraInfoList DeserializeCameraInfoFromXml(string path)
    {
        FileStream     fs             = new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
        XmlSerializer  xml            = new XmlSerializer(typeof(CameraInfoList));
        CameraInfoList cameraInfoList = (CameraInfoList)xml.Deserialize(fs);

        fs.Close();
        return(cameraInfoList);
    }
Ejemplo n.º 3
0
    //序列化
    public static void SerializeCameraInfo2Xml(string path, Transform cameraRootTrans)
    {
        if (cameraRootTrans == null)
        {
            return;
        }

        CameraInfoList cameraInfoList = new CameraInfoList();
        int            count          = cameraRootTrans.childCount;
        Transform      tempTrans      = null;
        Camera         tempCamera     = null;
        CameraInfo     cameraInfo     = null;

        for (int i = 0; i < count; ++i)
        {
            tempTrans = cameraRootTrans.GetChild(i);
            Info4Camera info4Camera = tempTrans.GetComponent <Info4Camera>();
            tempCamera                    = tempTrans.GetComponent <Camera>();
            cameraInfo                    = new CameraInfo();
            cameraInfo.CameraIndex        = (UInt16)i;
            cameraInfo.CameraName         = tempTrans.gameObject.name;
            cameraInfo.CameraType         = info4Camera.CctvCameraType;
            cameraInfo.PositionX          = tempTrans.localPosition.x;
            cameraInfo.PositionY          = tempTrans.localPosition.y;
            cameraInfo.PositionZ          = tempTrans.localPosition.z;
            cameraInfo.EulerAngleX        = tempTrans.localEulerAngles.x;
            cameraInfo.EulerAngleY        = tempTrans.localEulerAngles.y;
            cameraInfo.EulerAngleZ        = tempTrans.localEulerAngles.z;
            cameraInfo.ClippingPlanesNear = tempCamera.nearClipPlane;
            cameraInfo.ClippingPlanesFar  = tempCamera.farClipPlane;
            cameraInfoList.m_cameraInfoList.Add(cameraInfo);
        }

        if (File.Exists(path))
        {
            File.Delete(path);
        }

        FileStream fileStream = new FileStream(path,
                                               FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
        StreamWriter  sw  = new StreamWriter(fileStream, System.Text.Encoding.UTF8);
        XmlSerializer xml = new XmlSerializer(cameraInfoList.GetType());

        xml.Serialize(sw, cameraInfoList);
        sw.Close();
        fileStream.Close();
    }