Esempio n. 1
0
        private static void ExportMechaComponentQualityConfig(DataFormat dataFormat)
        {
            string folder = MechaComponentQualityConfigFolder_Build;

            if (Directory.Exists(folder))
            {
                Directory.Delete(folder, true);
            }
            Directory.CreateDirectory(folder);

            DirectoryInfo di = new DirectoryInfo(Application.dataPath + DesignRoot + MechaComponentQualityConfigFolder_Relative);

            foreach (FileInfo fi in di.GetFiles("*.asset"))
            {
                string relativePath = CommonUtils.ConvertAbsolutePathToProjectPath(fi.FullName);
                Object configObj    = AssetDatabase.LoadAssetAtPath <Object>(relativePath);
                MechaComponentQualityConfigSSO configSSO = (MechaComponentQualityConfigSSO)configObj;
                MechaComponentQualityConfig    config    = configSSO.MechaComponentQualityConfig;
                if (string.IsNullOrEmpty(configSSO.MechaComponentQualityConfig.MechaComponentQualityConfigName))
                {
                    Debug.LogError("机甲组件品质配置未绑定机甲组件Prefab,无法序列化");
                }
                else
                {
                    string path  = folder + configSSO.name + ".config";
                    byte[] bytes = SerializationUtility.SerializeValue(config, dataFormat);
                    File.WriteAllBytes(path, bytes);
                }
            }
        }
Esempio n. 2
0
        private static void LoadMechaComponentQualityConfig(DataFormat dataFormat)
        {
            MechaComponentQualityConfigDict.Clear();

            DirectoryInfo di = new DirectoryInfo(MechaComponentQualityConfigFolder_Build);

            if (di.Exists)
            {
                foreach (FileInfo fi in di.GetFiles("*.config", SearchOption.AllDirectories))
                {
                    byte[] bytes = File.ReadAllBytes(fi.FullName);
                    MechaComponentQualityConfig config = SerializationUtility.DeserializeValue <MechaComponentQualityConfig>(bytes, dataFormat);
                    if (MechaComponentQualityConfigDict.ContainsKey(config.MechaComponentQualityConfigName))
                    {
                        Debug.LogError($"机甲组件品质配置重名:{config.MechaComponentQualityConfigName}");
                    }
                    else
                    {
                        MechaComponentQualityConfigDict.Add(config.MechaComponentQualityConfigName, config);
                    }
                }
            }
            else
            {
                Debug.LogError("机甲组件品质配置表不存在");
            }
        }
        public MechaComponentInfo(MechaComponentConfig mechaComponentConfig, Quality quality, string alias = "")
        {
            GUID = GetGUID();
            MechaComponentConfig = mechaComponentConfig;
            Quality      = quality;
            Alias        = alias;
            AbilityGroup = ConfigManager.Instance.GetAbilityGroup(MechaComponentConfig.AbilityGroupConfigKey);
            MechaComponentQualityConfig = ConfigManager.Instance.GetMechaComponentQualityConfig(MechaComponentConfig.MechaComponentQualityConfigKey);

            CurrentQualityUpgradeData = MechaComponentQualityConfig.GetQualityUpgradeData(quality);
            if (CurrentQualityUpgradeData == null)
            {
                Debug.LogError($"未配置品质为{quality}的{MechaComponentType}");
            }
            else
            {
                CurrentPowerUpgradeData = CurrentQualityUpgradeData.GetPowerUpgradeData(0);
            }

            M_TotalLife = CurrentQualityUpgradeData.Life;
            M_LeftLife  = CurrentQualityUpgradeData.Life;
            if (ConfigManager.MechaComponentOriginalOccupiedGridInfoDict.TryGetValue(mechaComponentConfig.MechaComponentKey, out MechaComponentOriginalOccupiedGridInfo info))
            {
                MechaComponentOriginalOccupiedGridInfo = info.Clone();
            }
        }
 public bool ValidateQuality(Quality quality)
 {
     if (MechaComponentPrefab)
     {
         MechaComponentConfig        mcc = ConfigManager.Instance.GetMechaComponentConfig(MechaComponentPrefab.name);
         MechaComponentQualityConfig qc  = ConfigManager.Instance.GetMechaComponentQualityConfig(mcc.MechaComponentQualityConfigKey);
         if (qc.GetQualityUpgradeData(quality) != null)
         {
             qualityMessage = "";
             return(true);
         }
         else
         {
             qualityMessage = $"{MechaComponentPrefab.name}组件未配置{quality}品质";
             return(false);
         }
     }
     else
     {
         qualityMessage = "机甲组件为空,请先设置机甲组件";
         return(false);
     }
 }