public static PlayerResourceData InitData() { PlayerResourceData data = new PlayerResourceData(); var config = Config.ConfigData.PlayerConfig.gamePrepareConfig; if (config == null) { DebugPlus.LogError("GamePrepareConfig null! PlayerResourceData InitFail!"); return(null); } data.AddCurrencyMax(ModifierDetailRootType_Simple.OriginConfig, config.OriginalCurrencyMax); data.AddResearchMax(ModifierDetailRootType_Simple.OriginConfig, config.OriginalResearchMax); data.AddEnergyMax(ModifierDetailRootType_Simple.OriginConfig, config.OriginalEnergyMax); data.AddRoCoreMax(ModifierDetailRootType_Simple.OriginConfig, config.OriginalRoCoreMax); data.AddAIRobot_Maintenance_Max(ModifierDetailRootType_Simple.OriginConfig, config.OriginalAIRobot_Maintenance_Max); data.AddAIRobot_Builder_Max(ModifierDetailRootType_Simple.OriginConfig, config.OriginalAIRobot_Builder_Max); data.AddAIRobot_Operator_Max(ModifierDetailRootType_Simple.OriginConfig, config.OriginalAIRobot_Operator_Max); var prepareData = DataManager.Instance.gamePrepareData; data.AddCurrency(prepareData.GamePrepare_Currency); data.AddRoCore(prepareData.GamePrepare_RoCore); data.AddResearch(config.OriginalResearch); data.AddEnergy(config.OriginalEnergy); ///Init AIInfo data.AIRobotInfo.Add(ShipAIRobotType.Maintenance, prepareData.GamePrepare_AI_Maintenance); data.AIRobotInfo.Add(ShipAIRobotType.Builder, prepareData.GamePrepare_AI_Builder); data.AIRobotInfo.Add(ShipAIRobotType.Operator, prepareData.GamePrepare_AI_Operator); return(data); }
public static CampInfo InitInfo(int campID) { CampInfo info = new CampInfo(); var _meta = CampModule.GetCampDataByKey(campID); if (_meta != null) { info.CampID = _meta.CampID; info.campName = MultiLanguage.Instance.GetTextValue(_meta.CampName); info.campDesc = MultiLanguage.Instance.GetTextValue(_meta.CampDesc); info.campIconPath = _meta.CampIcon; info.campBGSmallPath = _meta.CampBGSmall; info.hardLevel = _meta.HardLevel; info.defualtHardLevelValue = _meta.DefaultHardLevel; info.creedInfo = CampCreedInfo.InitInfo(_meta.CreedID); info.attributeInfo = CampModule.GetCampAttribueInfoList(_meta.CampID); ///Init DefaultLeader info.campLeaderList = CampModule.GetCampDefaultLeaderList(_meta.CampID); return(info); } DebugPlus.LogError("[CampInfo] : Init Fail! campID=" + campID); return(null); }
/// <summary> /// 不需要实例化的资源的卸载,根据对象 /// </summary> /// <param name="obj"></param> /// <param name="destoryObj"></param> /// <returns></returns> public bool ReleaseResource(Object obj, bool destoryObj = false) { if (obj == null) { return(false); } ResouceItem item = null; foreach (ResouceItem res in AssetDic.Values) { if (res.m_Guid == obj.GetInstanceID()) { item = res; } } if (item == null) { DebugPlus.LogError("AssetDic里不存在改资源:" + obj.name + " 可能释放了多次"); return(false); } item.RefCount--; DestoryResouceItme(item, destoryObj); return(true); }
public static List <LeaderSkillInfo> GetLeaderSkillInfoDefault(int leaderID) { List <LeaderSkillInfo> result = new List <LeaderSkillInfo>(); var meta = GetLeaderPresetDataByKey(leaderID); if (meta != null) { var list = Utility.TryParseStringList(meta.LeaderSkillIDList, ','); for (int i = 0; i < list.Count; i++) { var skill = Utility.TryParseIntList(list[i], ':'); if (skill.Count != 2) { DebugPlus.LogError("LeaderSkill FormateError! leaderID=" + leaderID); continue; } int skillID = skill[0]; if (GetLeaderSkillDataByKey(skillID) != null) { LeaderSkillInfo info = LeaderSkillInfo.InitSkillInfo(skillID, skill[1]); result.Add(info); } } } return(result); }
public void AddMainShipShieldModifier(AssemblePartInfo partInfo, MainShipShieldInfo shieldInfo, ModifierBase modifierBase) { if (modifierBase == null) { DebugPlus.LogError("Modifier Base Data is null"); return; } if (modifierBase.ParseTargetType(modifierBase.Target) != ModifierTarget.MainShipShield) { DebugPlus.LogError("ModifierTargetError Name=" + modifierBase.ModifierName); return; } ModifierData data = null; switch (modifierBase.ParseModifierShieldType(modifierBase.effectType)) { case ModifierMainShip_Shield.Shield_open_init: if (!IsAddMainShipShieldModifier(shieldInfo, modifierBase)) { data = ModifierData.Create(modifierBase, delegate { shieldInfo.AddShieldOpenInit_Assemble(partInfo.modifierRootType, partInfo.UID, partInfo.partID, (int)modifierBase.Value); }); } break; } if (data != null) { ///ADD modifier shieldInfo.shipShieldModifier.OnAddModifier(data); } }
/// <summary> /// 获取部件可装配类型 /// </summary> /// <param name="partID"></param> /// <returns></returns> public static List <AssembleEquipTarget> GetAssemblePartEquipType(int partID) { List <AssembleEquipTarget> result = new List <AssembleEquipTarget>(); var partMeta = GetAssemblePartDataByKey(partID); if (partMeta != null) { var list = Utility.TryParseStringList(partMeta.AssembleType, ','); for (int i = 0; i < list.Count; i++) { if (GetAssembleMainTypeData(list[i]) != null) { AssembleEquipTarget target = AssembleEquipTarget.None; Enum.TryParse <AssembleEquipTarget>(list[i], out target); if (target == AssembleEquipTarget.None) { DebugPlus.LogError("GetAssemblePartEquipType Error! type=" + list[i]); } else { result.Add(target); } } } if (list.Count > Config.GlobalConfigData.AssemblePart_Target_MaxNum) { DebugPlus.LogError("AssemblePartTarget can not largerThan " + Config.GlobalConfigData.AssemblePart_Target_MaxNum + " Current partID is " + partID); } } return(result); }
/// <summary> /// 获取阵营初始领袖 /// </summary> /// <param name="campID"></param> /// <returns></returns> public static List <LeaderInfo> GetCampDefaultLeaderList(int campID) { List <LeaderInfo> result = new List <LeaderInfo>(); var campData = GetCampDataByKey(campID); if (campData != null) { var leaderIDList = Utility.TryParseIntList(campData.LeaderPresetList, ','); if (leaderIDList.Count == 0 || leaderIDList.Count > Config.GlobalConfigData.GamePrepare_Crew_Leader_Max) { DebugPlus.LogError("[CampData] : DefaultCrewLeader Member Error! campID = " + campID); return(result); } for (int i = 0; i < leaderIDList.Count; i++) { LeaderInfo info = LeaderInfo.CreateLeaderInfo_Preset(leaderIDList[i]); if (info != null) { info.forceSelcet = true; result.Add(info); } } } return(result); }
/// <summary> /// 根据路径的crc加载中间类ResoucItem /// </summary> /// <param name="crc"></param> /// <returns></returns> public ResouceItem LoadResouceAssetBundle(uint crc) { ResouceItem item = null; if (!m_ResouceItemDic.TryGetValue(crc, out item) || item == null) { DebugPlus.LogError(string.Format("LoadResourceAssetBundle error: can not find crc {0} in AssetBundleConfig", crc.ToString())); return(item); } if (item.m_AssetBundle != null) { return(item); } item.m_AssetBundle = LoadAssetBundle(item.m_ABName); if (item.m_DependAssetBundle != null) { for (int i = 0; i < item.m_DependAssetBundle.Count; i++) { LoadAssetBundle(item.m_DependAssetBundle[i]); } } return(item); }
public LanguageConfig LoadLanguageConfig() { string configPath = ""; if (ResourceManager.m_LoadFormAssetBundle) { configPath = LanguagePath_Bundle + "/LanguageConfig.json"; } else { configPath = LanguagePath + "/LanguageConfig.json"; } if (File.Exists(configPath)) { StreamReader sr = new StreamReader(configPath); string jsonStr = sr.ReadToEnd(); sr.Close(); config = JsonMapper.ToObject <LanguageConfig>(jsonStr); return(config); } else { DebugPlus.LogError("LanguageConfig Read Fail,Path=" + configPath); } return(null); }
/// <summary> /// 加载单个assetbundle根据名字 /// </summary> /// <param name="name"></param> /// <returns></returns> private AssetBundle LoadAssetBundle(string name) { AssetBundleItem item = null; uint crc = CRC32.GetCrc32(name); if (!m_AssetBundleItemDic.TryGetValue(crc, out item)) { AssetBundle assetBundle = null; string fullPath = Application.streamingAssetsPath + "/" + name; assetBundle = AssetBundle.LoadFromFile(fullPath); if (assetBundle == null) { DebugPlus.LogError(" Load AssetBundle Error:" + fullPath); } item = m_AssetBundleItemPool.Spawn(true); item.assetBundle = assetBundle; item.RefCount++; m_AssetBundleItemDic.Add(crc, item); } else { item.RefCount++; } return(item.assetBundle); }
public static LeaderPortraitInfo Generate_PresetInfo(int bgID, int clothID, int earID, int hairID, int eyesID, int faceID, int mouthID, int noseID) { LeaderPortraitInfo info = new LeaderPortraitInfo(); var config = Config.ConfigData.LeaderPortraitConfig; info.portrait_bg = config.portrait_bg.Find(x => x.configID == bgID); info.portrait_cloth = config.portrait_cloth.Find(x => x.configID == clothID); info.portrait_ear = config.portrait_Ear.Find(x => x.configID == earID); info.portrait_hair = config.portrait_hair.Find(x => x.configID == hairID); info.portrait_eyes = config.portrait_eyes.Find(x => x.configID == eyesID); info.portrait_face = config.portrait_face.Find(x => x.configID == faceID); info.portrait_mouth = config.portrait_Mouth.Find(x => x.configID == mouthID); info.portrait_nose = config.portrait_Nose.Find(x => x.configID == noseID); if (info.portrait_bg == null || info.portrait_cloth == null || info.portrait_ear == null || info.portrait_eyes == null || info.portrait_face == null || info.portrait_hair == null || info.portrait_mouth == null || info.portrait_nose == null) { DebugPlus.LogError("[Generate_PresetInfo] : Error!"); return(null); } return(info); }
public static LeaderInfo CreateLeaderInfo_Preset(int leaderID) { LeaderInfo info = new LeaderInfo(); var meta = LeaderModule.GetLeaderPresetDataByKey(leaderID); if (meta == null) { DebugPlus.LogError("CreateLeaderInfo_Preset Fail! leaderID=" + leaderID); return(null); } info.leaderID = meta.LeaderID; info.leaderName = MultiLanguage.Instance.GetTextValue(meta.LeaderName); info.leaderDesc = MultiLanguage.Instance.GetTextValue(meta.LeaderDesc); info.currentAge = meta.Age; info.Gender = (byte)meta.Gender; info.speciesInfo = LeaderSpeciesInfo.InitSpeciesInfo(meta.SpeciesID); info.creedInfo = LeaderCreedInfo.InitCreedInfo(meta.CreedID); info.skillInfoList = LeaderModule.GetLeaderSkillInfoDefault(leaderID); info.attributeInfoList = LeaderModule.GetLeaderAttributePreset(leaderID); info.birthlandInfo = LeaderBirthlandInfo.InitBirthlandInfo(meta.BirthlandID); info.storyInfoList = LeaderModule.GetLeaderPresetStory(leaderID); info.portraitInfo = LeaderPortraitInfo.Generate_PresetInfo(meta.Portrait_BG, meta.Portrait_Cloth, meta.Portrait_Ear, meta.Portrait_Hair, meta.Portrait_Eyes, meta.Portrait_Face, meta.Portrait_Mouth, meta.Portrait_Nose); return(info); }
public static PlayerAssemblePartData LoadSaveData(AssemblePartGeneralSaveData saveData) { PlayerAssemblePartData data = new PlayerAssemblePartData(); if (saveData == null) { DebugPlus.LogError("[AssemblePartGeneralSaveData] saveData is null"); return(null); } //Load Design for (int i = 0; i < saveData.currentSaveDesignPart.Count; i++) { AssemblePartInfo info = new AssemblePartInfo(); info.LoadSaveData(saveData.currentSaveDesignPart[i]); data.AddAssemblePartDesign(info); } //Load Storage for (int i = 0; i < saveData.currentSaveStoragePart.Count; i++) { AssemblePartInfo info = new AssemblePartInfo(); info.LoadSaveData(saveData.currentSaveStoragePart[i]); data.AddAssemblePartStorage(info); } //Load Equiped for (int i = 0; i < saveData.currentSaveEquipedPart.Count; i++) { AssemblePartInfo info = new AssemblePartInfo(); info.LoadSaveData(saveData.currentSaveEquipedPart[i]); data.AddAssemblePartStorage(info); } return(data); }
/// <summary> /// 缓存加载的资源 /// </summary> /// <param name="path"></param> /// <param name="item"></param> /// <param name="crc"></param> /// <param name="obj"></param> /// <param name="addrefcount"></param> void CacheResource(string path, ref ResouceItem item, uint crc, Object obj, int addrefcount = 1) { //缓存太多,清除最早没有使用的资源 WashOut(); if (item == null) { DebugPlus.LogError("ResouceItem is null, path: " + path); } if (obj == null) { DebugPlus.LogError("ResouceLoad Fail : " + path); } item.m_Obj = obj; item.m_Guid = obj.GetInstanceID(); item.m_LastUseTime = Time.realtimeSinceStartup; item.RefCount += addrefcount; ResouceItem oldItme = null; if (AssetDic.TryGetValue(item.m_Crc, out oldItme)) { AssetDic[item.m_Crc] = item; } else { AssetDic.Add(item.m_Crc, item); } }
public MultiLanguage() { LoadLanguageConfig(); if (string.IsNullOrEmpty(GetCurLanguageFilePath(CurrentLanguage))) { return; } string filePath = ""; if (ResourceManager.m_LoadFormAssetBundle) { filePath = LanguagePath_Bundle + "/" + GetCurLanguageFilePath(CurrentLanguage) + "/"; } else { filePath = LanguagePath + "/" + GetCurLanguageFilePath(CurrentLanguage) + "/"; } for (int i = 0; i < config.txtFile.Count; i++) { string languageDataPath = filePath + config.txtFile[i] + ".txt"; if (File.Exists(languageDataPath)) { StreamReader sr = new StreamReader(languageDataPath); string txt = sr.ReadToEnd(); sr.Close(); if (string.IsNullOrEmpty(txt)) { continue; } string[] lines = txt.Replace("\r\n", "\r").Split('\r'); foreach (var line in lines) { if (string.IsNullOrEmpty(line)) { continue; } string[] value = Regex.Split(line, "==", RegexOptions.IgnoreCase); if (TextData.ContainsKey(value[0])) { Debug.LogError("FindSame TextID TextID=" + line + " txt=" + languageDataPath); continue; } else if (value.Length != 2) { Debug.LogError("Text Format Error string=" + line + " txt=" + languageDataPath); continue; } var replaceStr = value[1].Replace("\\n", "\n"); TextData.Add(value[0], replaceStr); } } else { DebugPlus.LogError("TextData Read Fail, path=" + languageDataPath); } } }
public void AddAssemblePartDesign(AssemblePartInfo info) { ushort guid = getPartUnUsedInstanceID(); info.UID = guid; _assemblePartDesignDataDic.Add(guid, info); DebugPlus.LogObject <AssemblePartInfo>(info); }
public static void DoCanvasFade(this CanvasGroup group, float targetAlpha, float time) { if (group == null) { DebugPlus.LogError("CanvasGroup is Null!"); return; } group.DOFade(targetAlpha, time); }
IEnumerator LoadingSceneAsync(string sceneName) { LoadSceneStartCallBack?.Invoke(); ClearCache(); UIManager.Instance.ResetWinDic(); UIManager.Instance.ResetWinList(); AlreadyLoadScene = false; /// LoadScene AsyncOperation unLoadScene = SceneManager.LoadSceneAsync(UIPath.ScenePath.Scene_Loading, LoadSceneMode.Single); while (unLoadScene != null && !unLoadScene.isDone) { yield return(new WaitForEndOfFrame()); } LoadingProgress = 0; int targetProgress = 0; AsyncOperation asyncScene = SceneManager.LoadSceneAsync(sceneName); if (asyncScene == null) { DebugPlus.LogError("Loading Scene Empty Name=" + sceneName); yield return(new WaitForEndOfFrame()); } if (!asyncScene.isDone) { asyncScene.allowSceneActivation = false; while (asyncScene.progress < 0.9f) { targetProgress = (int)asyncScene.progress * 100; yield return(new WaitForEndOfFrame()); ///Smooth while (LoadingProgress < targetProgress) { ++LoadingProgress; yield return(new WaitForEndOfFrame()); } } CurrentSceneName = sceneName; SetSceneSetting(sceneName); targetProgress = 100; while (LoadingProgress < targetProgress - 2) { ++LoadingProgress; yield return(new WaitForEndOfFrame()); } LoadingProgress = 100; asyncScene.allowSceneActivation = true; AlreadyLoadScene = true; LoadSceneOverCallBack?.Invoke(); } }
public static Transform FindTransfrom(this Transform transfrom, string name) { var trans = transfrom.Find(name); if (trans == null) { DebugPlus.LogError("Find Transfrom is null ! name= " + name); } return(trans); }
/// <summary> /// Get MainShip Shield Level Data /// </summary> /// <param name="levelID"></param> /// <returns></returns> public static Config.MainShipShieldLevelMap GetMainShipShieldLevelData(int levelID) { var config = Config.ConfigData.MainShipConfigData.basePropertyConfig.shieldLevelMap; if (config == null) { DebugPlus.LogError("[MainShipShieldLevelMap] : config is null ! "); } return(config.Find(x => x.Level == levelID)); }
public static Config.MainShipShieldLayerMap GetMainShipShieldLayerData(int layerIndex) { var config = Config.ConfigData.MainShipConfigData.basePropertyConfig.shieldLayerMap; if (config == null) { DebugPlus.LogError("[MainShipShieldLayerMap] : config is null !"); } return(config.Find(x => x.layerIndex == layerIndex)); }
public static ModifierDetailRootType_Mix FetchBlockModifierRootType(FunctionBlockType type) { ModifierDetailRootType_Mix result = ModifierDetailRootType_Mix.None; if (!Enum.TryParse <ModifierDetailRootType_Mix>(type.ToString(), out result)) { DebugPlus.LogError("[ModifierDetailRootType_Block] fetchType Error! type= " + type); } return(result); }
public ModifierBase GetModifierBase(string name) { var modifier = generalModifier.ModifierBase.Find(x => x.ModifierName == name); if (modifier == null) { DebugPlus.LogError("Can not Find Modifier,Name=" + name); } return(modifier); }
public CampInfo GetCampInfoData(int campID) { CampInfo result = null; result = campPrepareInfoList.Find(x => x.CampID == campID); if (result == null) { DebugPlus.LogError("GetCampData Info Null! campID=" + campID); } return(result); }
public string GetTextValue(string key) { var result = string.Empty; TextData.TryGetValue(key, out result); if (string.IsNullOrEmpty(result)) { DebugPlus.LogError("Text not Found! ID=" + key); } return(result); }
public static LeaderSpeciesData GetLeaderSpeciesDataByKey(int speciesID) { LeaderSpeciesData data = null; leaderSpeciesDataDic.TryGetValue(speciesID, out data); if (data == null) { DebugPlus.LogError("Get LeaderSpeciesData Error! speciesID=" + speciesID); } return(data); }
public static LeaderPresetData GetLeaderPresetDataByKey(int leaderID) { LeaderPresetData data = null; leaderPresetDataDic.TryGetValue(leaderID, out data); if (data == null) { DebugPlus.LogError("Get LeaderPresetData Error! leaderID=" + leaderID); } return(data); }
public static LeaderCreedData GetLeaderCreedDataByKey(int creedID) { LeaderCreedData data = null; leaderCreedDataDic.TryGetValue(creedID, out data); if (data == null) { DebugPlus.LogError("Get LeaderCreedData Error! CreedID=" + creedID); } return(data); }
public static LeaderAttributeData GetLeaderAttributeDataByKey(int attributeID) { LeaderAttributeData data = null; leaderAttributeDataDic.TryGetValue(attributeID, out data); if (data == null) { DebugPlus.LogError("Get LeaderAttributeData Error! attributeID=" + attributeID); } return(data); }
public static LeaderBirthlandData GetLeaderBirthlandDataByKey(int landID) { LeaderBirthlandData data = null; leaderBirthlandDataDic.TryGetValue(landID, out data); if (data == null) { DebugPlus.LogError("Get LeaderBirthlandData Error! landID=" + landID); } return(data); }