MainData.ts 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. curServer: IServer
  64. serverList: IServer[]
  65. init() {
  66. this.maxRoleLv = RoleQualityConfig[this.maxRoleQuality].maxLv
  67. this.maxCardLv = RoleQualityConfig[this.maxCardQuality].maxLv
  68. //在线奖励一到六档
  69. let rewardList = [
  70. DIS_ID.onlineIdx1,
  71. DIS_ID.onlineIdx2,
  72. DIS_ID.onlineIdx3,
  73. DIS_ID.onlineIdx4,
  74. DIS_ID.onlineIdx5,
  75. DIS_ID.onlineIdx6,
  76. ]
  77. }
  78. reset() {
  79. this.modRedMap.clear()
  80. this.emailRed = false
  81. this.curServer = null
  82. this.serverList = []
  83. }
  84. }