StudioDataManager.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 int TYPE_SELECT_INDEX = 0;//界面类型0无属性选择,1有属性选择
  11. public int PROPERTY_SELECT_INDEX = 0;//属性类型
  12. public void Clear()
  13. {
  14. _StudioInfoById.Clear();
  15. }
  16. public void RspStudioInfos(StudioData studioData)
  17. {
  18. if (!_StudioInfoById.ContainsKey(studioData.ChapterId))
  19. {
  20. _StudioInfoById.Add(studioData.ChapterId, studioData);
  21. }
  22. _StudioInfoById[studioData.ChapterId] = studioData;
  23. }
  24. public void RspBuyStudioPlayTimes(int chapterId, int buyTimes, int totalPlayTimes)
  25. {
  26. _StudioInfoById[chapterId].BuyTimes = buyTimes;
  27. _StudioInfoById[chapterId].TotalPlayTimes = totalPlayTimes;
  28. }
  29. public void NoticeStudioPlayTimes(M2C_NoticeStudioPlayTimes message)
  30. {
  31. _StudioInfoById[message.ChapterId].PlayTimes = message.PlayTimes;
  32. }
  33. public StudioData GetStudioDataById(int id)
  34. {
  35. if (_StudioInfoById.ContainsKey(id))
  36. {
  37. return _StudioInfoById[id];
  38. }
  39. else
  40. {
  41. StudioData studioData = new StudioData() { ChapterId = id, BuyTimes = 0, PlayTimes = 0, TotalPlayTimes = StudioCfgArray.Instance.GetCfg(id).num };
  42. RspStudioInfos(studioData);
  43. return studioData;
  44. }
  45. }
  46. public void IsCanFight(StoryLevelCfg[] storyLevelCfgs, StoryLevelCfg storyLevelCfg, out bool canFight, out string content)
  47. {
  48. bool isPass = InstanceZonesDataManager.CheckLevelPass(storyLevelCfg.needStoryLevelId);
  49. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv;
  50. bool isLastPast = true;
  51. int index = Array.IndexOf(storyLevelCfgs, storyLevelCfg);
  52. if (index > 0)
  53. {
  54. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[index - 1].needStoryLevelId);
  55. }
  56. content = "";
  57. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.order);
  58. if (!isLastPast) content = "需通关前置关卡";
  59. StoryLevelCfg needStoryLevelCfg = StoryLevelCfgArray.Instance.GetCfg(storyLevelCfg.needStoryLevelId);
  60. if (!isPass) content = string.Format("完成主线{0}-{1}解锁", needStoryLevelCfg.chapterId, needStoryLevelCfg.order);
  61. canFight = isPass && isRoleLv && isLastPast;
  62. }
  63. }
  64. }