Beispiel #1
0
    private bool Init()
    {
        sceneConfigPath = Application.dataPath + "/" + sceneConfigPath;
        Scene curScene = SceneManager.GetActiveScene();

        if (curScene == null)
        {
            window.Close();
            window = null;
            UnityEditor.EditorUtility.DisplayDialog("Title", "请先打开场景", "是");
            return(false);
        }
        m_sceneName = curScene.name;

        LoadGroups();

        string configPath = SceneTools.getConfigPath();

        try
        {
            baseItemsData.Clear();
            System.Reflection.PropertyInfo[] proInfo;
            ConfHelper.LoadFromExcel <BaseItem>(configPath + "exhibit.xlsx", 0, out baseItemsData, out proInfo);
        }
        catch (IOException ex)
        {
            window.Close();
            window = null;
            UnityEditor.EditorUtility.DisplayDialog("Title", "先关表!!!", "是");
            return(false);
        }
        return(true);
    }
Beispiel #2
0
        /// <summary>
        /// Инициализация конфигурации приложения
        /// </summary>
        /// <returns></returns>
        public static bool InitConfiguration()
        {
            try {
                string confPath = Path.Combine(CurrentDirectory, "settings.conf");
                ConfHelper = new ConfHelper(confPath);
                if (!File.Exists(confPath))
                {
                    Global gl = new Global();
                    gl.Sql = new Sql();
                    ConfHelper.SaveConfig(gl, Encoding.UTF8, true);
                    CreateMessage("Файл конфигурации приложения не был обнаружен. Создан файл конфигурации с параметрами по умолчанию.", MessageType.Warning, true);
                }
                Configuration = ConfHelper.LoadConfig <Global>();
                if (!ConfHelper.Success)
                {
                    CreateMessage("Ошибка при загрузке конфигурации:\r\n" + ConfHelper.LastError.ToString(), MessageType.Error, true);
                    return(false);
                }

                return(true);
            }
            catch (Exception ex) {
                CreateMessage("Ошибка при загрузке конфигурации:\r\n" + ex.ToString(), MessageType.Error, true);
                return(false);
            }
        }
Beispiel #3
0
    void Init()
    {
        string configPath = SceneTools.getConfigPath();

        System.Reflection.PropertyInfo[] proInfo;
        ConfHelper.LoadFromExcel <BaseItem>(configPath + "BaseItem.xlsx", 0, out baseItemsData, out proInfo);
        Scene scene = SceneManager.GetActiveScene();

        if (scene == null)
        {
            return;
        }
        sceneName = scene.name;
        dataDir   = Application.streamingAssetsPath + "/SceneData/" + sceneName + "/";
        string lightJsonStr = SceneTools.getJsonFile(dataDir + "lightData/" + sceneName + "_0_light.json");

        //object ooo = fastJSON.JSON.Parse(lightJsonStr);
        //objLightData = (SceneObjLightData)fastJSON.JSON.Parse(lightJsonStr);
        objLightData = fastJSON.JSON.ToObject <SceneObjLightData>(lightJsonStr);
        string itemJsonStr = SceneTools.getJsonFile(dataDir + sceneName + "_0.json");

        sceneItem = fastJSON.JSON.ToObject <SceneItemJson>(itemJsonStr);

        //sceneItem = (SceneItemJson)fastJSON.JSON.ToObject(itemJsonStr);
        for (int i = 0; i < sceneItem.items.Count; i++)
        {
            itemState.Add(false);
        }
        tex = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Res/Scene/" + sceneName + "/Lightmap-0_comp_light.exr");
    }
Beispiel #4
0
        private void LoadResSceneData()
        {
            string configPath = SceneTools.getConfigPath();

            System.Reflection.PropertyInfo[] sceneProInfo;
            ConfHelper.LoadFromExcel <SceneConfig>(configPath + "sceneResEditor.xlsx", 0, out sceneConfig, out sceneProInfo);
        }
Beispiel #5
0
 private void InitConfiguration()
 {
     try {
         string confPath = Path.Combine(CD, "settings.conf");
         if (!File.Exists(confPath))
         {
             throw new Exception("Файл конфигурации приложения не был обнаружен");
         }
         ConfHelper    = new ConfHelper(confPath);
         Configuration = ConfHelper.LoadConfig <Global>();
         if (!ConfHelper.Success)
         {
             throw new Exception(ConfHelper.LastError.ToString());
         }
     }
     catch (Exception ex) {
         MessageBox.Show("Ошибка при загрузке конфигурации:\r\n" + ex.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Load += (s, e) => Application.Exit();
     }
 }
Beispiel #6
0
        /// <summary>
        /// Инициализация конфигурации приложения
        /// </summary>
        /// <returns></returns>
        public static bool InitConfiguration()
        {
            try {
                string confPath = Path.Combine(CurrentDirectory, "settings.conf");
                ConfHelper = new ConfHelper(confPath);
                if (!File.Exists(confPath))
                {
                    Global defConf = new Global();
                    defConf.PlaceInfoParms              = new PlaceInfoParms();
                    defConf.PlaceInfoParms.Database     = "";
                    defConf.PlaceInfoParms.Datasource   = "localhost";
                    defConf.PlaceInfoParms.EncodingList = new List <string>()
                    {
                        "ASCII", "KOI8R", "KOI8U", "UTF8", "WIN1251"
                    };
                    defConf.PlaceInfoParms.Encoding = "WIN1251";
                    defConf.PlaceInfoParms.Username = "******";
                    defConf.PlaceInfoParms.Password = "******";
                    defConf.PlaceInfoParms.HostList = new Dictionary <string, string>();
                    defConf.PlaceInfoParms.HostList.Add("localhost", "localhost");
                    ConfHelper.SaveConfig(defConf, Encoding.UTF8, true);
                    CreateMessage("Файл конфигурации приложения не был обнаружен. Создан файл конфигурации с параметрами по умолчанию.", MessageType.Warning, true);
                }

                Configuration = ConfHelper.LoadConfig <Global>();
                if (!ConfHelper.Success)
                {
                    CreateMessage("Ошибка при загрузке конфигурации:\r\n" + ConfHelper.LastError.ToString(), MessageType.Error, true);
                    return(false);
                }

                return(true);
            }
            catch (Exception ex) {
                CreateMessage("Ошибка при загрузке конфигурации:\r\n" + ex.ToString(), MessageType.Error, true);
                return(false);
            }
        }
Beispiel #7
0
        public void SetConfig(string config, string path)
        {
            if (!File.Exists(config))
            {
                return;
            }
            regx_monster  = "(\\s\\S*?)";
            regx_pendulum = "(\\s\\S*?)";
            //设置文件名
            configName = MyPath.getFullFileName(MSEConfig.TAG, config);

            replaces = new SortedList <string, string>();

            typeDic = new SortedList <long, string>();
            raceDic = new SortedList <long, string>();
            string[] lines = File.ReadAllLines(config, Encoding.UTF8);
            foreach (string line in lines)
            {
                if (string.IsNullOrEmpty(line) || line.StartsWith("#"))
                {
                    continue;
                }
                if (line.StartsWith(TAG_CN2TW))
                {
                    Iscn2tw = ConfHelper.getBooleanValue(line);
                }
                else if (line.StartsWith(TAG_SPELL))
                {
                    str_spell = ConfHelper.getValue(line);
                }
                else if (line.StartsWith(TAG_HEAD))
                {
                    head = ConfHelper.getMultLineValue(line);
                }
                else if (line.StartsWith(TAG_END))
                {
                    end = ConfHelper.getMultLineValue(line);
                }
                else if (line.StartsWith(TAG_TEXT))
                {
                    temp_text = ConfHelper.getMultLineValue(line);
                }
                else if (line.StartsWith(TAG_TRAP))
                {
                    str_trap = ConfHelper.getValue(line);
                }
                else if (line.StartsWith(TAG_REG_PENDULUM))
                {
                    regx_pendulum = ConfHelper.getValue(line);
                }
                else if (line.StartsWith(TAG_REG_MONSTER))
                {
                    regx_monster = ConfHelper.getValue(line);
                }
                else if (line.StartsWith(TAG_MAXCOUNT))
                {
                    maxcount = ConfHelper.getIntegerValue(line, 0);
                }
                else if (line.StartsWith(TAG_WIDTH))
                {
                    width = ConfHelper.getIntegerValue(line, 0);
                }
                else if (line.StartsWith(TAG_HEIGHT))
                {
                    height = ConfHelper.getIntegerValue(line, 0);
                }
                else if (line.StartsWith(TAG_PEND_WIDTH))
                {
                    pwidth = ConfHelper.getIntegerValue(line, 0);
                }
                else if (line.StartsWith(TAG_PEND_HEIGHT))
                {
                    pheight = ConfHelper.getIntegerValue(line, 0);
                }
                else if (line.StartsWith(TAG_NO_TEN))
                {
                    no10 = ConfHelper.getBooleanValue(line);
                }
                else if (line.StartsWith(TAG_NO_START_CARDS))
                {
                    string   val = ConfHelper.getValue(line);
                    string[] cs  = val.Split(',');
                    noStartCards = new long[cs.Length];
                    int i = 0;
                    foreach (string str in cs)
                    {
                        long l = 0;
                        long.TryParse(str, out l);
                        noStartCards[i++] = l;
                    }
                }
                else if (line.StartsWith(TAG_IMAGE))
                {
                    //如果路径不合法,则为后面的路径
                    imagepath = MyPath.CheckDir(ConfHelper.getValue(line), MyPath.Combine(path, PATH_IMAGE));
                    //图片缓存目录
                    imagecache = MyPath.Combine(imagepath, "cache");
                    MyPath.CreateDir(imagecache);
                }
                else if (line.StartsWith(TAG_REPALCE))
                {                //特数字替换
                    string word = ConfHelper.getValue(line);
                    string p    = ConfHelper.getRegex(ConfHelper.getValue1(word));
                    string r    = ConfHelper.getRegex(ConfHelper.getValue2(word));
                    if (!string.IsNullOrEmpty(p))
                    {
                        replaces.Add(p, r);
                    }
                }
                else if (line.StartsWith(TAG_RACE))
                {                //种族
                    ConfHelper.DicAdd(raceDic, line);
                }
                else if (line.StartsWith(TAG_TYPE))
                {                //类型
                    ConfHelper.DicAdd(typeDic, line);
                }
                else if (line.StartsWith(TAG_REIMAGE))
                {
                    reimage = ConfHelper.getBooleanValue(line);
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Выролняет проверку наличия обновлений
        /// </summary>
        /// <returns></returns>
        public static void CheckUpdates()
        {
            if (IsUpdateRunning)
            {
                return;
            }
            IsUpdateRunning = true;

            try {
                if (ARGS.Length > 0)
                {
                    foreach (string arg in ARGS)
                    {
                        if (arg.ToLower() == "-u" && !UpdatesInstalled)
                        {
                            Process[] processes = Process.GetProcessesByName("Updater");
                            if (processes.Length > 0)
                            {
                                Process         proc = processes[0];
                                FileVersionInfo info = FileVersionInfo.GetVersionInfo(proc.MainModule.FileName);
                                if (info.CompanyName == "ФГУП Почта Крыма")
                                {
                                    proc.Kill();
                                }
                            }

                            string path = Path.Combine(CurrentDirectory, "Updater.exe");
                            if (File.Exists(path))
                            {
                                File.Delete(path);
                            }
                            File.WriteAllBytes(path, Properties.Resources.Updater);

                            // Создаем сообщение об успешной установке обновления
                            CreateMessage("Обновление успешно установлено", MessageType.Information, false, true, true);

                            UpdatesInstalled = true;
                        }
                    }
                }
            }
            catch (Exception ex) {
                CreateMessage("Ошибка при установке обновлений: " + ex.ToString(), MessageType.Error, true, false, true);
            }

            try {
                // Установка модуля обновления при его отсутствии
                string updaterPath = Path.Combine(CurrentDirectory, "Updater.exe");
                if (!File.Exists(updaterPath))
                {
                    File.WriteAllBytes(updaterPath, Properties.Resources.Updater);
                }
            }
            catch (Exception ex) {
                CreateMessage("Ошибка при распаковке клиента обновлений: " + ex.ToString(), MessageType.Error, false, false, false);
            }

            try {
                CreateMessage("Проверка обновлений конфигурационного файла...", MessageType.Information, false, false, true);
                if (UpdatesHelper.CheckConfigUpdates(Path.Combine(CurrentDirectory, "settings.upd"), Configuration))
                {
                    // Сохраняем изменения в конфигурационный файл
                    ConfHelper.SaveConfig(Configuration, Encoding.UTF8, true);
                    Configuration = ConfHelper.LoadConfig <Global>();
                    CreateMessage("Выполнено обновление конфигурационного файла", MessageType.Information, false, false, true);
                }
            }
            catch (Exception ex) {
                CreateMessage("Ошибка при установке обновлений конфигурационного файла: " + ex.ToString(), MessageType.Error, false, false, true);
            }

            try {
                CreateMessage("Проверка обновлений...", MessageType.Information, false, false, true);
                if (UpdatesHelper.CheckUpdates(Configuration.Updates.ServerName, Version, ProductName))
                {
                    Process.Start(Path.Combine(CurrentDirectory, "Updater.exe"), string.Format("{0} {1} {2}", Version, Configuration.Updates.ServerName, ProductName));
                    GUIController.ExitOnLoaded();
                    return;
                }
            }
            catch (Exception ex) {
                CreateMessage("Ошибка при проверке обновлений: " + ex.ToString(), MessageType.Error, false, false, true);
            }

            IsUpdateRunning = false;
        }
Beispiel #9
0
    bool Init()
    {
        //load base item for table
        Scene scene = SceneManager.GetActiveScene();

        if (scene != null)
        {
            sceneName = scene.name;
            pathDir   = "Assets" + pathDir + scene.name + "/"; //+ ".asset";
        }

        if (string.IsNullOrEmpty(sceneName) || sceneName.Equals("EmptyScene") || sceneName.Equals("main_ui"))
        {
            UnityEditor.EditorUtility.DisplayDialog("Title", "当前场景为空!!!", "是");
            return(false);
        }

        m_allItemInfo = JsonToSceneData.RevertAsset();

        lightTempPath += sceneName;
        scenePath     += sceneName;

        jsonPath = Application.dataPath + jsonPath + sceneName + "/";
        string configPath = SceneTools.getConfigPath();

        try {
            System.Reflection.PropertyInfo[] proInfo;
            ConfHelper.LoadFromExcel <BaseItem>(configPath + "exhibit.xlsx", 0, out baseItemsData, out proInfo);

            List <SceneConfig> sceneConfig;
            System.Reflection.PropertyInfo[] sceneProInfo;
            ConfHelper.LoadFromExcel <SceneConfig>(configPath + "sceneResEditor.xlsx", 0, out sceneConfig, out sceneProInfo);
            sceneID = getSceneID(sceneConfig);
            //if (!Directory.Exists(pathDir))
            //{
            //    Directory.CreateDirectory(pathDir);
            //    //创建asset
            //    itemInfos = ScriptableObject.CreateInstance<SceneItemInfo>();
            //    itemInfos.items = new List<ItemInfo>();
            //    AssetDatabase.CreateAsset(itemInfos, pathDir + sceneName + "_0.asset");
            //    AssetDatabase.Refresh();
            //}
            //string[] allAssetPath = Directory.GetFiles(pathDir, "*.asset");
            for (int i = 0; i < m_allItemInfo.Count; i++)
            {
                m_allAssetName.Add(m_allItemInfo[i].jsonName);
            }
            LoadAssetData();

            GameObject[] cameraPoint = GameObject.FindGameObjectsWithTag("cameraPoint");
            m_allCameraNode.Add("MainCamera");
            for (int i = 0; i < cameraPoint.Length; i++)
            {
                m_allCameraNode.Add(cameraPoint[i].name);
            }
            UserLog.OpenSceneLog();
        }
        catch (IOException ex)
        {
            window.Close();
            window = null;
            UnityEditor.EditorUtility.DisplayDialog("Title", "先关表!!!", "是");
            return(false);
        }
        return(true);
    }