MainData.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /** @format */
  2. import {observable, computed, action} from 'mobx'
  3. import {activityTimeInfo, building, idNum, popGiftInfo} from '../proto/typedef'
  4. import {Data, Mgr} from '../GameControl'
  5. import {DataConfig} from '../config/DataConfig'
  6. import {RoleLevelConfig} from '../config/RoleLevelConfig'
  7. import {RoleQualityConfig} from '../config/RoleQualityConfig'
  8. import {IBaseAttr, IServer, ITimeGift} from '../interface/GlobalInterface'
  9. import {CHANNEL, DIS_ID, LOGIN_TYPE, MOD} from '../enums/Enum'
  10. import {IOnlineRewardData, IRewardNty} from '../interface/UIInterface'
  11. import {onlineAwardNty, rechargeResult, relicDataNty} from '../proto/game'
  12. export class MainData {
  13. @observable
  14. webSocketCon: boolean = false
  15. texBundle: cc.AssetManager.Bundle
  16. //服务器道具更新消息缓存
  17. rewardNtyMap: Map<string, IRewardNty> = new Map()
  18. globalTime: number = 0
  19. secondTime: number = 0
  20. @observable
  21. minutesTime: number = 0
  22. @observable
  23. //服务器时间 单位:秒
  24. serverTime: number = 0
  25. //登录时间
  26. loginTime: number = 0
  27. buildData: building[]
  28. roleSpineMap: Map<string, sp.SkeletonData> = new Map()
  29. itemsPrefabMap: Map<string, cc.Prefab> = new Map()
  30. itemsPoolMap: Map<string, cc.NodePool> = new Map()
  31. maxRoleQuality: number = DataConfig[DIS_ID.heroQuality].data1
  32. maxCardQuality: number = DataConfig[DIS_ID.heroQuality].data2
  33. maxEquipQuality: number = DataConfig[DIS_ID.heroQuality].data3
  34. maxRoleLv: number = 0
  35. maxCardLv: number = 0
  36. maxEquipLv: number = 0
  37. //一个角色最多携带的装备数量
  38. equipMaxNum: number = 6
  39. //天赋加成是基础值
  40. talentAdd: IBaseAttr[]
  41. safeTop: number = 0
  42. timeGifts: ITimeGift[] = []
  43. //遗迹加成是比例值
  44. relicAdd: IBaseAttr[]
  45. relicData: relicDataNty
  46. activityList: Map<number, activityTimeInfo> = new Map() //活动列表
  47. modPopMap: Map<number, boolean> = new Map()
  48. //模块红点数据
  49. modRedMap: Map<number, boolean> = new Map()
  50. @observable
  51. emailRed: boolean = false
  52. loginType: LOGIN_TYPE
  53. //战斗后返回
  54. exitGame: boolean = false
  55. 战斗后返回升级
  56. exitGameLv: boolean = false
  57. localVersion: string = ''
  58. //是否是第二天登录
  59. isSecondDay: boolean = false
  60. appType: string = ''
  61. payData: rechargeResult[] = []
  62. channel: CHANNEL
  63. onlineRewards: onlineAwardNty //在线奖励数据
  64. onlineGetRewards: IOnlineRewardData[] = [] //在线奖励领取阶段--阶段时间数组
  65. curServer: IServer
  66. serverList: IServer[]
  67. init() {
  68. this.maxRoleLv = RoleQualityConfig[this.maxRoleQuality].maxLv
  69. this.maxCardLv = RoleQualityConfig[this.maxCardQuality].maxLv
  70. //在线奖励一到六档
  71. let rewardList = [
  72. DIS_ID.onlineIdx1,
  73. DIS_ID.onlineIdx2,
  74. DIS_ID.onlineIdx3,
  75. DIS_ID.onlineIdx4,
  76. DIS_ID.onlineIdx5,
  77. DIS_ID.onlineIdx6,
  78. ]
  79. Data.main.onlineGetRewards = []
  80. for (let i = 0; i < rewardList.length; i++) {
  81. let item = DataConfig[rewardList[i]]
  82. Data.main.onlineGetRewards.push({
  83. idx: rewardList[i],
  84. time: item.data1,
  85. data: {id: item.data2, num: item.data3},
  86. })
  87. }
  88. }
  89. reset() {
  90. this.modRedMap.clear()
  91. this.emailRed = false
  92. this.curServer = null
  93. this.serverList = []
  94. }
  95. }