StudioDataManager.cs 3.1 KB

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