StudioDataManager.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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, StoryLevelCfg storyLevelCfg, out bool canFight, out string content)
  48. {
  49. bool isPass = InstanceZonesDataManager.CheckLevelPass(storyLevelCfg.needStoryLevelId);
  50. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv;
  51. bool isLastPast = true;
  52. int index = Array.IndexOf(storyLevelCfgs, storyLevelCfg);
  53. if (index > 0)
  54. {
  55. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[index - 1].needStoryLevelId);
  56. }
  57. content = "";
  58. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.order);
  59. if (!isLastPast) content = "需通关前置关卡";
  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. }