Beispiel #1
0
        /// <summary>
        /// 获取特效颜色
        /// 英雄属性类型+自定义
        /// </summary>
        /// <returns></returns>
        public static string GetEffColor(int index)
        {
            if (index >= EffColorStr.Length)
            {
                CLog.Error("特效背景颜色越界");
                return("ffffff");
            }

            return(EffColorStr[index]);
        }
Beispiel #2
0
        public static RectTransform MyRectTransform(this GameObject obj)
        {
            RectTransform rect = obj.GetComponent <RectTransform>();

            if (rect == null)
            {
                CLog.Error($"对象[{obj.name}]的RectTransform组件未找到");
            }
            return(rect);
        }
Beispiel #3
0
        /// <summary>
        /// 获取引用对象(在UIOutlet中定义的)
        /// </summary>
        public GameObject Get(string name)
        {
            GameObject obj;

            if (!objectList.TryGetValue(name, out obj))
            {
                CLog.Error($"未找到GameObject对象,请在UIOutlet中设置:{name}");
            }
            return(obj);
        }
Beispiel #4
0
        /// <summary>
        /// 读取配置表
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        private async CTask readConfig <T>(Dictionary <object, T> source) where T : BaseConfig, new()
        {
            loadCount += 1;
            string fileName = typeof(T).Name;

            UnityEngine.Object configObj = await CSF.Mgr.Assetbundle.LoadAsset <UnityEngine.Object>(configAssetbundle, fileName);

            if (configObj != null)
            {
                string strconfig = configObj.ToString();
                if (IsCSV)
                {
                    using (StringReader sr = new StringReader(strconfig))
                    {
                        string line;
                        while ((line = sr.ReadLine()) != null)
                        {
                            T config = CSF.ConfigUtils.ToObject <T>(line.Split(splitFieldChar));
                            if (source.ContainsKey(config.UniqueID))
                            {
                                CLog.Error($"表[{fileName}]中有相同键({config.UniqueID})");
                            }
                            else
                            {
                                source.Add(config.UniqueID, config);
                            }
                        }
                    }
                }
                else
                {
                    List <T> list = JsonMapper.ToObject <List <T> >(strconfig);
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (source.ContainsKey(list[i].UniqueID))
                        {
                            CLog.Error($"表[{fileName}]中有相同键({list[i].UniqueID})");
                        }
                        else
                        {
                            source.Add(list[i].UniqueID, list[i]);
                        }
                    }
                }
            }
            else
            {
                CLog.Error($"配置文件不存在{fileName}");
            }
            loadedCount += 1;
        }
        private async CTask readFBMaplPosSetting()
        {
            UnityEngine.Object configObj = await CSF.Mgr.Assetbundle.LoadAsset <UnityEngine.Object>("Data/FBMaplPosSetting.txt", "FBMaplPosSetting");

            if (configObj != null)
            {
                string strconfig = configObj.ToString();
                dicFBMaplPosSetting = JsonMapper.ToObject <List <FBMaplPosSetting> >(strconfig);
            }
            else
            {
                CLog.Error($"配置文件不存在FBMaplPosSetting");
            }
        }
Beispiel #6
0
        /// <summary>
        /// 获取控件对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="path">路径</param>
        /// <param name="parent">父对象</param>
        /// <returns></returns>
        public T GetComponen <T>(string path, Transform parent = null) where T : Component
        {
            if (parent == null)
            {
                parent = transform;
            }
            Transform tran = parent.Find(path);

            if (tran == null)
            {
                string str = $"父对象[{parent.name}],子路径[{path}]下未找到[{typeof(T).Name}]类型的对象";
                CLog.Error(str);
                return(null);
            }
            return(parent.Find(path).GetComponent <T>());
        }
        private async CTask readHeroModelSetting()
        {
            UnityEngine.Object configObj = await CSF.Mgr.Assetbundle.LoadAsset <UnityEngine.Object>("Data/HeroModelSetting.txt", "HeroModelSetting");

            if (configObj != null)
            {
                string strconfig             = configObj.ToString();
                List <HeroModelSetting> list = JsonMapper.ToObject <List <HeroModelSetting> >(strconfig);
                for (int i = 0; i < list.Count; i++)
                {
                    dicHeroModelSetting.Add(list[i].Model, list[i]);
                }
            }
            else
            {
                CLog.Error($"配置文件不存在HeroModelSetting");
            }
        }
Beispiel #8
0
        public static string GetColorByAttr(int index, bool light)
        {
            if (light)
            {
                if (index >= AttrColorStrLight.Length)
                {
                    CLog.Error("高亮颜色越界");
                    return("ffffff");
                }

                return(AttrColorStrLight[index]);
            }

            if (index >= AttrColorStrDark.Length)
            {
                CLog.Error("暗沉颜色越界");
                return("ffffff");
            }

            return(AttrColorStrDark[index]);
        }
Beispiel #9
0
        /// <summary>
        /// 读取竖表
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        private async CTask <T> readConfigV <T>() where T : BaseConfig, new()
        {
            string fileName = typeof(T).Name;

            UnityEngine.Object configObj = await CSF.Mgr.Assetbundle.LoadAsset <UnityEngine.Object>(configAssetbundle, fileName);

            if (configObj != null)
            {
                string strconfig = configObj.ToString();
                if (IsCSV)
                {
                    using (StringReader sr = new StringReader(strconfig))
                    {
                        string line;
                        while ((line = sr.ReadLine()) != null)
                        {
                            T config = CSF.ConfigUtils.ToObject <T>(line.Split(splitFieldChar));
                            return(config);
                        }
                    }
                }
                else
                {
                    List <T> list = JsonMapper.ToObject <List <T> >(strconfig);
                    if (list.Count > 0)
                    {
                        return(list[0]);
                    }
                }
            }
            else
            {
                CLog.Error($"配置文件不存在{fileName}");
            }
            return(default(T));
        }