Пример #1
0
        /// <summary>
        /// 获取存档数量
        /// </summary>
        /// <returns></returns>
        int GetGameDataIndex(string groupName)
        {
            string SaveFilePath = Application.persistentDataPath + "/SaveData/Sav_" + groupName;

            if (Directory.Exists(SaveFilePath))
            {
                DirectoryInfo info  = new DirectoryInfo(SaveFilePath);
                var           files = info.GetFiles();
                return(files.Length / 2);
            }
            else
            {
                DebugPlus.Log("Save GroupFile not Exist! path=" + SaveFilePath);
            }
            return(0);
        }
Пример #2
0
        int GetGameDataGroupIndex()
        {
            string saveFilePath = Application.persistentDataPath + "/SaveData";

            if (Directory.Exists(saveFilePath))
            {
                DirectoryInfo info = new DirectoryInfo(saveFilePath);
                var           file = info.GetDirectories();
                return(file.Length);
            }
            else
            {
                DebugPlus.Log("Save File not Exist! path=" + saveFilePath);
            }
            return(1);
        }
Пример #3
0
        /// <summary>
        /// 获取存档
        /// </summary>
        /// <param name="saveID"></param>
        /// <returns></returns>
        private GameSaveData GetSaveDataBySaveID(string groupName, int groupID, int saveIndex)
        {
            GameSaveDataItem data = GetSaveNavigatorData(groupID, saveIndex);

            if (data == null)
            {
                DebugPlus.LogError("Save Not Exists! SaveID=  " + data.saveName + "_" + data.Index);
                return(null);
            }
            else
            {
                string SaveFilePath = Application.persistentDataPath + "/SaveData/Sav_" + groupName;
                if (Directory.Exists(SaveFilePath))
                {
                    DirectoryInfo dirs  = new DirectoryInfo(SaveFilePath);
                    var           files = dirs.GetFiles();
                    DebugPlus.Log("Save num=" + files.Length / 2);

                    for (int i = 0; i < files.Length; i++)
                    {
                        if (files[i].Name == groupName + "_" + saveIndex + ".sav")
                        {
                            try
                            {
                                var savePath = files[i].FullName;
                                var saveData = LoadSave(savePath);
                                if (saveData != null)
                                {
                                    return(saveData);
                                }
                            }
                            catch (Exception e)
                            {
                                Debug.LogError(e);
                                return(null);
                            }
                        }
                    }
                }
            }
            return(null);
        }
Пример #4
0
        public static LeaderSkillInfo InitSkillInfo(int skillID, int defaultLevel)
        {
            LeaderSkillInfo info = new LeaderSkillInfo();
            var             meta = LeaderModule.GetLeaderSkillDataByKey(skillID);

            if (meta == null)
            {
                DebugPlus.LogError("Init LeaderSkill Info Error! skillID=" + skillID);
                return(null);
            }
            info.skillID       = meta.SkillID;
            info.skillName     = MultiLanguage.Instance.GetTextValue(meta.SkillName);
            info.skillDesc     = MultiLanguage.Instance.GetTextValue(meta.SkillDesc);
            info.skillIconPath = meta.SkillIcon;
            info.currentLevel  = defaultLevel;
            info.maxLevel      = meta.MaxLevel;

            if (info.currentLevel > meta.MaxLevel)
            {
                DebugPlus.Log("LeaderSkill Info SkillLevelDefault larger than MaxLevel, skillID=" + skillID);
                info.currentLevel = meta.MaxLevel;
            }
            return(info);
        }
Пример #5
0
        public List <GameSaveDataItem> RefreshCurrentSaveDataList()
        {
            AllSaveDataList.Clear();
            string SaveFilePath = Application.persistentDataPath + "/SaveData";

            if (Directory.Exists(SaveFilePath))
            {
                DirectoryInfo dirs  = new DirectoryInfo(SaveFilePath);
                var           saves = dirs.GetFiles("*.nav", SearchOption.AllDirectories);

                DebugPlus.Log("[GameSaveData] : Save File Length=" + saves.Length);

                for (int i = 0; i < saves.Length; i++)
                {
                    try
                    {
                        var savePath = saves[i].FullName;
                        var data     = LoadSaveNavigator(savePath);
                        if (data != null)
                        {
                            AllSaveDataList.Add(data);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                        continue;
                    }
                }
            }
            else
            {
                Debug.Log("Save Path not Exits!  Path=" + SaveFilePath);
            }
            return(AllSaveDataList);
        }
Пример #6
0
 protected void GetPrepare_Research_Coefficient_Default()
 {
     DebugPlus.Log("[Research_Coefficient] : Config not Find! Use Default Value");
     GamePrepare_EnemyHardLevel = (float)Config.ConfigData.PlayerConfig.gamePrepareConfig.GamePrepareConfig_Research_Coefficient_Default;
 }
Пример #7
0
        /// <summary>
        /// 回收资源
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="maxCacheCount"></param>
        /// <param name="destoryCache"></param>
        /// <param name="recycleParent"></param>
        public void ReleaseObject(GameObject obj, int maxCacheCount = -1, bool destoryCache = false, bool recycleParent = true)
        {
            if (obj == null)
            {
                return;
            }

            ResouceObj resObj = null;
            int        tempID = obj.GetInstanceID();

            if (!m_ResouceObjDic.TryGetValue(tempID, out resObj))
            {
                DebugPlus.Log(obj.name + "对象不是ObjectManager创建的!");
                return;
            }

            if (resObj == null)
            {
                DebugPlus.LogError("缓存的ResouceObj为空!");
                return;
            }

            if (resObj.m_Already)
            {
                DebugPlus.LogError("该对象已经放回对象池了,检测自己是否情况引用!");
                return;
            }

#if UNITY_EDITOR
            obj.name += "(Recycle)";
#endif

            List <ResouceObj> st = null;
            if (maxCacheCount == 0)
            {
                m_ResouceObjDic.Remove(tempID);
                ResourceManager.Instance.ReleaseResource(resObj, destoryCache);
                resObj.Reset();
                m_ResourceObjClassPool.Recycle(resObj);
            }
            else//回收到对象池
            {
                if (!m_ObjectPoolDic.TryGetValue(resObj.m_Crc, out st) || st == null)
                {
                    st = new List <ResouceObj>();
                    m_ObjectPoolDic.Add(resObj.m_Crc, st);
                }

                if (resObj.m_CloneObj)
                {
                    if (recycleParent)
                    {
                        resObj.m_CloneObj.transform.SetParent(RecyclePoolTrs, false);
                    }
                    else
                    {
                        resObj.m_CloneObj.SetActive(false);
                    }
                }

                if (maxCacheCount < 0 || st.Count < maxCacheCount)
                {
                    st.Add(resObj);
                    resObj.m_Already = true;
                    //ResourceManager做一个引用计数
                    ResourceManager.Instance.DecreaseResoucerRef(resObj);
                }
                else
                {
                    m_ResouceObjDic.Remove(tempID);
                    ResourceManager.Instance.ReleaseResource(resObj, destoryCache);
                    resObj.Reset();
                    m_ResourceObjClassPool.Recycle(resObj);
                }
            }
        }
Пример #8
0
 protected void GetPrepare_EnermyHardLevel_Default()
 {
     DebugPlus.Log("[EnermyHardLevel] : Config not Find! Use Default Value");
     GamePrepare_EnemyHardLevel = (float)Config.ConfigData.PlayerConfig.gamePrepareConfig.GamePrepareConfig_EnemyHardLevel_Default;
 }
Пример #9
0
 protected void GetPrepare_RoCore_Default()
 {
     DebugPlus.Log("[GamePrepare_RoCore] : Config not Find! Use Default Value");
     GamePrepare_RoCore = Config.ConfigData.PlayerConfig.gamePrepareConfig.GamePrepareConfig_RoCore_Default;
 }
Пример #10
0
 protected void GetPrepare_ResourceRichness_Default()
 {
     DebugPlus.Log("[GamePrepare_ResourceRichness] : Config not Find! Use Default Value");
     GamePrepare_Currency = Config.ConfigData.PlayerConfig.gamePrepareConfig.GamePrepareConfig_Resource_Richness_Default;
 }
Пример #11
0
 protected void GetGamePrepare_AI_Operator_Default()
 {
     DebugPlus.Log("[GamePrepare_AI_Operator] : Config not Find! Use Default Value");
     GamePrepare_AI_Builder = Config.ConfigData.PlayerConfig.gamePrepareConfig.GamePrepareConfig_AI_Operator_Default;
 }
Пример #12
0
 protected void GetPrepare_AI_Maintenance_Default()
 {
     DebugPlus.Log("[GamePrepare_AI_Maintenance] : Config not Find! Use Default Value");
     GamePrepare_AI_Maintenance = Config.ConfigData.PlayerConfig.gamePrepareConfig.GamePrepareConfig_AI_Operator_Default;
 }