| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476 | 
							- using System.Collections;
 
- using System.Collections.Generic;
 
- using System;
 
- using UnityEngine;
 
- using ET;
 
- namespace GFGGame
 
- {
 
-     public class StoryDataManager
 
-     {
 
-         public static string priorId = "prior";//首次登录前置剧情id
 
-         public static int currentChapter = 0;
 
-         public static int currentLevel = 0;
 
-         public static string currentLevelID;
 
-         public static int currentScoreType;
 
-         public static int currentCardId = 0;
 
-         public static bool usedRecommend;
 
-         public static int _passChapter = 0;
 
-         public static int _passLevel = 0;
 
-         private static int _passChapterJY = 10000;
 
-         private static int _passLevelJY = 0;
 
-         private static int _recommendCount = 0;
 
-         public static int recommendDay = -1;
 
-         public static int recommendCount
 
-         {
 
-             get
 
-             {
 
-                 return _recommendCount;
 
-             }
 
-         }
 
-         private static Dictionary<string, int> _highestScoreDic = new Dictionary<string, int>();
 
-         private static Dictionary<int, int> _chapterStarCountDic = new Dictionary<int, int>();
 
-         private static Dictionary<int, Dictionary<int, int>> _chapterBonusDic = new Dictionary<int, Dictionary<int, int>>();
 
-         public static void InitServerData(RoleInfo roleInfo)
 
-         {
 
-             usedRecommend = false;
 
-             _recommendCount = roleInfo.recommendCount;
 
-             recommendDay = roleInfo.recommendDay;
 
-         }
 
-         public static void InitScoreList(List<StoryScore> list)
 
-         {
 
-             _highestScoreDic.Clear();
 
-             if (list != null)
 
-             {
 
-                 foreach (StoryScore value in list)
 
-                 {
 
-                     _highestScoreDic[value.lvlId] = value.score;
 
-                 }
 
-             }
 
-         }
 
-         public static void InitStarList(List<StoryStar> list)
 
-         {
 
-             _chapterStarCountDic.Clear();
 
-             _chapterBonusDic.Clear();
 
-             if (list != null)
 
-             {
 
-                 foreach (StoryStar value in list)
 
-                 {
 
-                     int chapterID = value.chapterId;
 
-                     _chapterStarCountDic[chapterID] = value.star;
 
-                     if (value.boxStatus != null && value.boxStatus.Length > 0)
 
-                     {
 
-                         Dictionary<int, int> statusDic = null;
 
-                         if (_chapterBonusDic.ContainsKey(chapterID))
 
-                         {
 
-                             statusDic = _chapterBonusDic[chapterID];
 
-                         }
 
-                         else
 
-                         {
 
-                             statusDic = new Dictionary<int, int>();
 
-                             _chapterBonusDic.Add(chapterID, statusDic);
 
-                         }
 
-                         string[] statusStrs = value.boxStatus.Split(';');
 
-                         for (int i = 0; i < statusStrs.Length; i++)
 
-                         {
 
-                             string statusStr = statusStrs[i];
 
-                             int status = int.Parse(statusStr);
 
-                             statusDic[i] = status;
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         public static void ResetDailyData()
 
-         {
 
-             _recommendCount = GameConst.MAX_COUNT_RECOMMEND;
 
-             int day = ServerDataManager.CurrentDay;
 
-             recommendDay = day;
 
-             GameProxy.ReqUpdateRecommendCount(_recommendCount);
 
-         }
 
-         public static void SetPassData(int chapter, int chapterLvl)
 
-         {
 
-             if (StoryUtil.CheckChapterIsHard(chapter))
 
-             {
 
-                 //_passChapterJY = chapter;
 
-                 //_passLevelJY = chapterLvl;
 
-             }
 
-             else
 
-             {
 
-                 //_passChapter = chapter;
 
-                 //_passLevel = chapterLvl;
 
-             }
 
-         }
 
-         public static int GetChapterBonusStatus(int chapterID, int index)
 
-         {
 
-             if (_chapterBonusDic.ContainsKey(chapterID))
 
-             {
 
-                 Dictionary<int, int> statusDic = _chapterBonusDic[chapterID];
 
-                 if (statusDic != null)
 
-                 {
 
-                     if (statusDic.ContainsKey(index))
 
-                     {
 
-                         return statusDic[index];
 
-                     }
 
-                 }
 
-             }
 
-             return ConstBonusStatus.CAN_NOT_GET;
 
-         }
 
-         public static List<ItemData> GetChapterBonus(int chapterID, int index)
 
-         {
 
-             List<ItemData> bonusList = StoryBonusDataCache.GetChapterBonusList(chapterID, index);
 
-             foreach (ItemData itemData in bonusList)
 
-             {
 
-                 ItemDataManager.Add(itemData.id, itemData.num);
 
-             }
 
-             Dictionary<int, int> statusDic = null;
 
-             if (_chapterBonusDic.ContainsKey(chapterID))
 
-             {
 
-                 statusDic = _chapterBonusDic[chapterID];
 
-             }
 
-             else
 
-             {
 
-                 statusDic = new Dictionary<int, int>();
 
-                 _chapterBonusDic.Add(chapterID, statusDic);
 
-                 statusDic[0] = ConstBonusStatus.CAN_NOT_GET;
 
-                 statusDic[1] = ConstBonusStatus.CAN_NOT_GET;
 
-                 statusDic[2] = ConstBonusStatus.CAN_NOT_GET;
 
-             }
 
-             statusDic[index] = ConstBonusStatus.GOT;
 
-             string boxStatus = GetBoxStatus(currentChapter);
 
-             int starCountChapter = GetChapterStarCount(currentChapter);
 
-             GameProxy.ReqUpdateStoryStar(currentChapter, starCountChapter, boxStatus);
 
-             return bonusList;
 
-         }
 
-         public static void UpdateChapterBonusStatus(int chapterID, int starCount)
 
-         {
 
-             StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterID);
 
-             if (starCount >= storyChapterCfg.bonusStar1)
 
-             {
 
-                 Dictionary<int, int> statusDic = null;
 
-                 if (_chapterBonusDic.ContainsKey(chapterID))
 
-                 {
 
-                     statusDic = _chapterBonusDic[chapterID];
 
-                 }
 
-                 else
 
-                 {
 
-                     statusDic = new Dictionary<int, int>();
 
-                     _chapterBonusDic.Add(chapterID, statusDic);
 
-                     statusDic[0] = ConstBonusStatus.CAN_NOT_GET;
 
-                     statusDic[1] = ConstBonusStatus.CAN_NOT_GET;
 
-                     statusDic[2] = ConstBonusStatus.CAN_NOT_GET;
 
-                 }
 
-                 if (statusDic[0] == ConstBonusStatus.CAN_NOT_GET)
 
-                 {
 
-                     statusDic[0] = ConstBonusStatus.CAN_GET;
 
-                 }
 
-                 if (starCount >= storyChapterCfg.bonusStar2 && statusDic[1] == ConstBonusStatus.CAN_NOT_GET)
 
-                 {
 
-                     statusDic[1] = ConstBonusStatus.CAN_GET;
 
-                 }
 
-                 if (starCount >= storyChapterCfg.bonusStar3 && statusDic[2] == ConstBonusStatus.CAN_NOT_GET)
 
-                 {
 
-                     statusDic[2] = ConstBonusStatus.CAN_GET;
 
-                 }
 
-             }
 
-         }
 
-         public static bool CheckOpenMainUI()
 
-         {
 
-             return CheckLevelPass(1, 4) && GuideDataManager.GetGuideCountCopy(ConstGuideId.SINGLE_FIGHT) > 0;
 
-         }
 
-         //检查指定章节对应的普通章节是否通关
 
-         public static bool CheckNormalChapterPass(int chapterId)
 
-         {
 
-             int normalChapterId = StoryUtil.GetNormalChapterId(chapterId);
 
-             return normalChapterId <= GameGlobal.myNumericComponent.GetAsInt(NumericType.Chapter);
 
-         }
 
-         public static bool CheckChapterUnlock(int chapterId)
 
-         {
 
-             StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterId);
 
-             if (GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) < chapterCfg.lvl)
 
-             {
 
-                 return false;
 
-             }
 
-             if (StoryUtil.CheckChapterIsHard(chapterId))
 
-             {
 
-                 //对应普通剧情的章需要开启
 
-                 if (!CheckNormalChapterPass(chapterId))
 
-                 {
 
-                     return false;
 
-                 }
 
-                 //前一精英章需要通关
 
-                 if (chapterId - 1 > GameGlobal.myNumericComponent.GetAsInt(NumericType.ChapterJY))
 
-                 {
 
-                     return false;
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (chapterId - 1 > GameGlobal.myNumericComponent.GetAsInt(NumericType.Chapter))
 
-                 {
 
-                     return false;
 
-                 }
 
-             }
 
-             return true;
 
-         }
 
-         public static bool CheckLevelPass(int chapterId, int level)
 
-         {
 
-             int passChapter = GetPassChapter(chapterId);
 
-             int passLevel = GetPassLevel(chapterId);
 
-             if (chapterId <= passChapter)
 
-             {
 
-                 return true;
 
-             }
 
-             if (chapterId == passChapter + 1 && level <= passLevel)
 
-             {
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         public static bool CheckLevelUnlock(int chapterId, int level)
 
-         {
 
-             int passChapter = GetPassChapter(chapterId);
 
-             int passLevel = GetPassLevel(chapterId);
 
-             if (chapterId <= passChapter)
 
-             {
 
-                 return true;
 
-             }
 
-             if (chapterId == passChapter + 1 && level <= passLevel + 1)
 
-             {
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         public static bool CheckCurrentLevelPass()
 
-         {
 
-             return CheckLevelPass(currentChapter, currentLevel);
 
-         }
 
-         public static int GetScoreHighest(string levelID)
 
-         {
 
-             if (_highestScoreDic.ContainsKey(levelID))
 
-             {
 
-                 return _highestScoreDic[levelID];
 
-             }
 
-             return 0;
 
-         }
 
-         public static void GetStoryId(string levelIdStr, out int chapterIdP, out int levelIdP)
 
-         {
 
-             string[] ids = levelIdStr.Split('_');
 
-             chapterIdP = int.Parse(ids[0]);
 
-             levelIdP = int.Parse(ids[1]);
 
-         }
 
-         public static int GetResultStarCount(int score)
 
-         {
 
-             if (!EquipDataCache.cacher.CheckEquipedFightNeeded())
 
-             {
 
-                 return 0;
 
-             }
 
-             return GetStarCount(currentLevelID, score);
 
-         }
 
-         public static int GetStarCountHistory(string levelID, int score)
 
-         {
 
-             int chapterIdT = 0;
 
-             int levelIdT = 0;
 
-             GetStoryId(levelID, out chapterIdT, out levelIdT);
 
-             if (!CheckLevelPass(chapterIdT, levelIdT))
 
-             {
 
-                 return 0;
 
-             }
 
-             return GetStarCount(levelID, score);
 
-         }
 
-         public static int GetStarCount(string levelID, int score)
 
-         {
 
-             StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelID);
 
-             StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
 
-             int starCount = 0;
 
-             if (score > fightCfg.score1)
 
-             {
 
-                 if (score > fightCfg.score3)
 
-                 {
 
-                     starCount = 3;
 
-                 }
 
-                 else if (score > fightCfg.score2)
 
-                 {
 
-                     starCount = 2;
 
-                 }
 
-                 else
 
-                 {
 
-                     starCount = 1;
 
-                 }
 
-             }
 
-             return starCount;
 
-         }
 
-         public static bool CheckCurrentScoreEnough(int score)
 
-         {
 
-             StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(currentLevelID);
 
-             StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
 
-             return (score > fightCfg.score1);
 
-         }
 
-         public static void SetScore(int score, int starCount)
 
-         {
 
-             int scoreHighest = 0;
 
-             if (_highestScoreDic.ContainsKey(currentLevelID))
 
-             {
 
-                 scoreHighest = _highestScoreDic[currentLevelID];
 
-             }
 
-             if (score > scoreHighest)
 
-             {
 
-                 _highestScoreDic[currentLevelID] = score;
 
-                 GameProxy.ReqUpdateStoryScore(currentLevelID, score);
 
-                 int starCountSaved = GetStarCountHistory(currentLevelID, scoreHighest);
 
-                 int starCountChapter = 0;
 
-                 if (_chapterStarCountDic.ContainsKey(currentChapter))
 
-                 {
 
-                     starCountChapter = _chapterStarCountDic[currentChapter];
 
-                 }
 
-                 if (starCount > starCountSaved)
 
-                 {
 
-                     starCountChapter = starCountChapter + starCount - starCountSaved;
 
-                     _chapterStarCountDic[currentChapter] = starCountChapter;
 
-                     UpdateChapterBonusStatus(currentChapter, starCountChapter);
 
-                     string boxStatus = GetBoxStatus(currentChapter);
 
-                     GameProxy.ReqUpdateStoryStar(currentChapter, starCountChapter, boxStatus);
 
-                 }
 
-             }
 
-         }
 
-         public static int GetPassChapter(int fromChapter)
 
-         {
 
-             if (StoryUtil.CheckChapterIsHard(fromChapter))
 
-             {
 
-                 return GameGlobal.myNumericComponent.GetAsInt(NumericType.ChapterJY);
 
-             }
 
-             return GameGlobal.myNumericComponent.GetAsInt(NumericType.Chapter);
 
-         }
 
-         public static int GetPassLevel(int fromChapter)
 
-         {
 
-             if (StoryUtil.CheckChapterIsHard(fromChapter))
 
-             {
 
-                 return GameGlobal.myNumericComponent.GetAsInt(NumericType.ChapterLvlJY);
 
-             }
 
-             return GameGlobal.myNumericComponent.GetAsInt(NumericType.ChapterLvl);
 
-         }
 
-         public static List<ItemData> PassCurrentLevel(out bool fistPassLastLvl, out bool curLvfirstPass)
 
-         {
 
-             fistPassLastLvl = false;
 
-             curLvfirstPass = false;
 
-             List<ItemData> currentBonusList = new List<ItemData>();
 
-             if (!CheckCurrentLevelPass())
 
-             {
 
-                 curLvfirstPass = true;
 
-                 int tempPassLevel = currentLevel;
 
-                 int tempPassChapter = GetPassChapter(currentChapter);
 
-                 int nextLevel = currentLevel + 1;
 
-                 string nextLevelID = currentChapter + "_" + nextLevel;
 
-                 StoryLevelCfg nextLevelCfg = StoryLevelCfgArray.Instance.GetCfg(nextLevelID);
 
-                 if (nextLevelCfg == null)
 
-                 {
 
-                     tempPassChapter = currentChapter;
 
-                     tempPassLevel = 0;
 
-                     fistPassLastLvl = true;
 
-                 }
 
-                 SetPassData(tempPassChapter, tempPassLevel);
 
-                 // FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(_passChapter + 1, _passLevel);//首次通过要检查是否有功能开启
 
-                 //GameProxy.ReqUpdateStoryProgress(_passChapter, _passLevel, _passChapterJY, _passLevelJY);
 
-                 currentBonusList = StoryBonusDataCache.GetBonusList(currentLevelID, true, true);
 
-             }
 
-             else
 
-             {
 
-                 currentBonusList = StoryBonusDataCache.GetBonusList(currentLevelID, false, true);
 
-             }
 
-             StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(StoryDataManager.currentLevelID);
 
-             //消耗体力
 
-             if (currentBonusList != null && currentBonusList.Count > 0)
 
-             {
 
-                 if (GameGlobal.myNumericComponent.GetAsInt(NumericType.Power) >= levelCfg.power)
 
-                 {
 
-                     RoleDataManager.power -= levelCfg.power;
 
-                 }
 
-                 else
 
-                 {
 
-                     RoleDataManager.power = 0;
 
-                 }
 
-             }
 
-             //消耗推荐次数
 
-             if (usedRecommend)
 
-             {
 
-                 usedRecommend = false;
 
-                 _recommendCount--;
 
-                 GameProxy.ReqUpdateRecommendCount(_recommendCount);
 
-             }
 
-             //经验奖励
 
-             if (levelCfg.fightID != null && levelCfg.fightID.Length > 0)
 
-             {
 
-                 StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
 
-                 RoleDataManager.exp += fightCfg.exp;
 
-             }
 
-             foreach (ItemData itemData in currentBonusList)
 
-             {
 
-                 ItemDataManager.Add(itemData.id, itemData.num);
 
-             }
 
-             return currentBonusList;
 
-         }
 
-         public static int GetChapterStarCount(int chapterID)
 
-         {
 
-             if (_chapterStarCountDic.ContainsKey(chapterID))
 
-             {
 
-                 return _chapterStarCountDic[chapterID];
 
-             }
 
-             return 0;
 
-         }
 
-         public static int GetCanFightTime(string levelID)
 
-         {
 
-             StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelID);
 
-             int time = (int)Math.Floor((float)GameGlobal.myNumericComponent.GetAsInt(NumericType.Power) / levelCfg.power);
 
-             return time;
 
-         }
 
-         private static string GetBoxStatus(int chapterId)
 
-         {
 
-             string boxStatus = "0;0;0";
 
-             if (_chapterBonusDic.ContainsKey(chapterId))
 
-             {
 
-                 boxStatus = "{0};{1};{2}";
 
-                 Dictionary<int, int> tempDic = _chapterBonusDic[chapterId];
 
-                 int value0 = GetChapterBonusStatus(chapterId, 0);
 
-                 int value1 = GetChapterBonusStatus(chapterId, 1);
 
-                 int value2 = GetChapterBonusStatus(chapterId, 2);
 
-                 boxStatus = string.Format(boxStatus, value0, value1, value2);
 
-             }
 
-             return boxStatus;
 
-         }
 
-     }
 
- }
 
 
  |