StudioDataManager.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using GFGGame;
  5. namespace GFGGame
  6. {
  7. public class StudioDataManager : SingletonBase<StudioDataManager>
  8. {
  9. private Dictionary<int, StudioData> _StudioInfoById = new Dictionary<int, StudioData>();
  10. public void Clear()
  11. {
  12. _StudioInfoById.Clear();
  13. }
  14. public void RspStudioInfos(StudioData studioData)
  15. {
  16. if (!_StudioInfoById.ContainsKey(studioData.ChapterId))
  17. {
  18. _StudioInfoById.Add(studioData.ChapterId, studioData);
  19. }
  20. _StudioInfoById[studioData.ChapterId] = studioData;
  21. }
  22. public void RspBuyStudioPlayTimes(int chapterId, int buyTimes, int totalPlayTimes)
  23. {
  24. _StudioInfoById[chapterId].BuyTimes = buyTimes;
  25. _StudioInfoById[chapterId].TotalPlayTimes = totalPlayTimes;
  26. }
  27. public void NoticeStudioPlayTimes(M2C_NoticeStudioPlayTimes message)
  28. {
  29. _StudioInfoById[message.ChapterId].PlayTimes = message.PlayTimes;
  30. }
  31. public StudioData GetStudioDataById(int id)
  32. {
  33. if (_StudioInfoById.ContainsKey(id))
  34. {
  35. return _StudioInfoById[id];
  36. }
  37. else
  38. {
  39. StudioData studioData = new StudioData() { ChapterId = id, BuyTimes = 0, PlayTimes = 0, TotalPlayTimes = StudioCfgArray.Instance.GetCfg(id).num };
  40. RspStudioInfos(studioData);
  41. return studioData;
  42. }
  43. }
  44. public void IsCanFight(StoryLevelCfg[] storyLevelCfgs, StoryLevelCfg storyLevelCfg, out bool canFight, out string content)
  45. {
  46. bool isPass = InstanceZonesDataManager.CheckLevelPass(storyLevelCfg.needStoryLevelId);
  47. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv;
  48. bool isLastPast = true;
  49. int index = Array.IndexOf(storyLevelCfgs, storyLevelCfg);
  50. if (index > 0)
  51. {
  52. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[index - 1].needStoryLevelId);
  53. }
  54. content = "";
  55. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.order);
  56. if (!isLastPast) content = "需通关前置关卡";
  57. if (!isPass) content = string.Format("完成主线{0}-{1}解锁", storyLevelCfg.chapterId, storyLevelCfg.order);
  58. canFight = isPass && isRoleLv && isLastPast;
  59. }
  60. }
  61. }