Esempio n. 1
0
        public override void InitManager()
        {
            base.InitManager();

            //初始化与战斗有关的单例控制器
            BattleCalculator.Instance.Init();           //战斗计算器
            MapNavigator.Instance.Init();               //导航器
            BattleFieldRenderer.Instance.Init();        //初始化战场显示器

#if UNITY_EDITOR
            //收集战斗数据

            //保存路径
            string brFolder = UtilityHelper.ConvertToObsPath(string.Format("{0}/../BR", Application.dataPath));
            if (!Directory.Exists(brFolder))
            {
                Directory.CreateDirectory(brFolder);
            }

            brPath = string.Format("{0}/{1}_{2}_{3}_{4}_{5}.csv",
                                   brFolder,
                                   System.DateTime.Now.Month,
                                   System.DateTime.Now.Day,
                                   System.DateTime.Now.Hour,
                                   System.DateTime.Now.Minute,
                                   System.DateTime.Now.Second);
#endif
        }
Esempio n. 2
0
        public static void ProcessUIViewConfig()
        {
            string prefabPath = UtilityHelper.ConvertToObsPath(PrefabPath);

            string[] allUIPrefab = Directory.GetFiles(
                prefabPath,
                "*.prefab",
                SearchOption.TopDirectoryOnly)
                                   .Where(
                file => file.EndsWith(".prefab") && file.ToLower().Contains("uiview_")).ToArray();

            List <string> newConfigs = new List <string>();
            int           count      = 0;

            foreach (var item in allUIPrefab)
            {
                string fileName = Path.GetFileNameWithoutExtension(item);
                string soPath   = UtilityHelper.ConvertToObsPath(string.Format("{0}/{1}.asset", OutputPath, fileName));
                ++count;
                if (!File.Exists(soPath))
                {
                    //不存在这个so,创建新的
                    SO_UIViewConfig newConfig = ScriptableObject.CreateInstance <SO_UIViewConfig>();
                    newConfig.assetName = fileName;
                    AssetDatabase.CreateAsset(newConfig, string.Format("{0}/{1}.asset", OutputPath, fileName));
                    newConfigs.Add(string.Format(string.Format("(新建) {0}. {1} -> {2} ", count, fileName, OutputPath)));
                    EditorUtility.SetDirty(newConfig);
                }
                else
                {
                    newConfigs.Add(string.Format(string.Format("(已存在) {0}. {1} -> {2} ", count, fileName, OutputPath)));
                }
            }
            if (newConfigs.Count > 0)
            {
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                //显示界面
                UIViewConfigHelperWindow.Show("刷新界面配置文件", newConfigs, new Rect(200, 200, 600, newConfigs.Count * 22 + 50));
            }
            else
            {
                EditorUtility.DisplayDialog("Complete", "There isn't any view config need to be created.", "OK");
            }
        }
Esempio n. 3
0
        //初始化界面配置
        private void InitViewConfig()
        {
            //加载界面配置
#if UNITY_EDITOR
            //编辑器下读取
            string   configPath = "Assets/HalfSLG/ScriptableObjects/UIView";
            string[] configs    = Directory.GetFiles(UtilityHelper.ConvertToObsPath(configPath), "*.asset", SearchOption.TopDirectoryOnly);
            foreach (var item in configs)
            {
                string path   = UtilityHelper.ConverToRelativePath(item.Replace("\\", "/"));
                var    config = AssetDatabase.LoadAssetAtPath <SO_UIViewConfig>(path);
                //对config进行一次纠正,常驻内存的界面,必须是唯一的
                if (config.cacheScheme == UIViewCacheScheme.Cache)
                {
                    config.unique = true;
                }
                uiViewConfig.Add(config.viewName, config);
            }
#endif
            Debug.Log("View config inited.");
        }