GameData.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /** @format */
  2. import {Data} from '../GameControl'
  3. import {ccUtils} from '../utils/ccUtils'
  4. import {GAME_TYPE} from '../enums/Enum'
  5. import {SysFrameAni} from '../ECS/systems/SysFrameAni'
  6. import {observable} from 'mobx'
  7. import {SysEnter} from '../ECS/systems/SysEnter'
  8. import {IRelicattributeConfig} from '../config/RelicattributeConfig'
  9. import {IRunecardConfig} from '../config/RunecardConfig'
  10. import {idNum} from '../proto/typedef'
  11. import Asset = cc.Asset
  12. /** @format */
  13. export class GameData {
  14. groupList: string[] = [
  15. 'default',
  16. 'friend',
  17. 'enemy',
  18. 'friendBullet',
  19. 'enemyBullet',
  20. 'friendHurtSkill',
  21. 'friendGainSkill',
  22. 'enemyHurtSkill',
  23. 'enemyGainSkill',
  24. 'friendHurtSkillMonitor',
  25. 'friendGainSkillMonitor',
  26. 'enemyHurtSkillMonitor',
  27. 'enemyGainSkillMonitor',
  28. 'friendMeleeMonitor',
  29. 'enemyMeleeMonitor',
  30. 'friendMeleeXMonitor',
  31. 'enemyMeleeXMonitor',
  32. 'friendAttackMonitor',
  33. 'enemyAttackMonitor',
  34. 'skillArea',
  35. ]
  36. gFriend: number = this.groupList.indexOf('friend')
  37. gEnemy: number = this.groupList.indexOf('enemy')
  38. gFriendBullet: number = this.groupList.indexOf('friendBullet')
  39. gEnemyBullet: number = this.groupList.indexOf('enemyBullet')
  40. gFriendHurtSkill: number = this.groupList.indexOf('friendHurtSkill')
  41. gFriendGainSkill: number = this.groupList.indexOf('friendGainSkill')
  42. gEnemyHurtSkill: number = this.groupList.indexOf('enemyHurtSkill')
  43. gEnemyGainSkill: number = this.groupList.indexOf('enemyGainSkill')
  44. gFriendHurtSkillMonitor: number = this.groupList.indexOf('friendHurtSkillMonitor')
  45. gFriendGainSkillMonitor: number = this.groupList.indexOf('friendGainSkillMonitor')
  46. gEnemyHurtSkillMonitor: number = this.groupList.indexOf('enemyHurtSkillMonitor')
  47. gEnemyGainSkillMonitor: number = this.groupList.indexOf('enemyGainSkillMonitor')
  48. gFriendMeleeMonitor: number = this.groupList.indexOf('friendMeleeMonitor')
  49. gEnemyMeleeMonitor: number = this.groupList.indexOf('enemyMeleeMonitor')
  50. gFriendMeleeXMonitor: number = this.groupList.indexOf('friendMeleeXMonitor')
  51. gEnemyMeleeXMonitor: number = this.groupList.indexOf('enemyMeleeXMonitor')
  52. gFriendAttackMonitor: number = this.groupList.indexOf('friendAttackMonitor')
  53. gEnemyAttackMonitor: number = this.groupList.indexOf('enemyAttackMonitor')
  54. gSkillArea: number = this.groupList.indexOf('skillArea')
  55. collisionMatrix: boolean[][] = new Array(this.groupList.length)
  56. .fill([])
  57. .map(() => new Array(this.groupList.length).fill(false))
  58. gameBundle: cc.AssetManager.Bundle
  59. gameAssetMap: Map<string, cc.Asset> = new Map()
  60. //近战探测范围
  61. meleeRange: number = 130
  62. //万分比
  63. rateNum: number = 10000
  64. //配置表CD最大值
  65. cdMax: number = 9999
  66. //防御常数
  67. defenseConst: number = 325
  68. //环境伤害倍率
  69. curHurtRate: number = 0
  70. //光环cd
  71. holoCD: number = 0.1
  72. //光环buff持续时间 (光环cd小于光环持续时间)
  73. holoDuration: number = 0.15
  74. attackLeftRadiusPoints: cc.Vec2[] = []
  75. attackRightRadiusPoints: cc.Vec2[] = []
  76. //角色出生范围
  77. fightSizeMaxY: number = 250
  78. fightSizeMinY: number = -310
  79. fightSizeMaxX: number = 350
  80. fightSizeMinX: number = -350
  81. //子弹,触摸等范围
  82. fightAreaMaxY: number = 350
  83. fightAreaMinY: number = -410
  84. fightAreaMaxX: number = 350
  85. fightAreaMinX: number = -350
  86. meleeMonitorRangeX: number = 200
  87. meleeMonitorRangeY: number = 1000
  88. meleeYMonitorRangeX: number = 3000
  89. meleeYMonitorRangeY: number = 300
  90. //关卡ID
  91. stageID: number = 1
  92. //关卡波数ID
  93. stageRound: number
  94. //关卡试玩次数
  95. trailTimes: number
  96. //开启试玩
  97. trailOpen: boolean
  98. //关卡试玩ID
  99. trailID: number
  100. gameType: GAME_TYPE = GAME_TYPE.none
  101. spineTimeRate: number = 1
  102. spineScale: number = 0.22
  103. maxAttackSpeed: number = 50000
  104. minAttackSpeed: number = 5000
  105. maxAttackRange: number = 1000
  106. relicAttrCfg: IRelicattributeConfig[] = []
  107. relicEntryArr: number[] = []
  108. dropOut: idNum[]
  109. @observable
  110. gameSpeed: number = 1
  111. speedUpTime: number = 0
  112. friendNum: number = 3
  113. init() {
  114. let colliderPairs = [
  115. [this.gFriend, this.gEnemyAttackMonitor],
  116. [this.gFriend, this.gEnemyBullet],
  117. [this.gFriend, this.gFriendGainSkill],
  118. [this.gFriend, this.gEnemyHurtSkill],
  119. [this.gFriend, this.gFriendGainSkillMonitor],
  120. [this.gFriend, this.gEnemyHurtSkillMonitor],
  121. [this.gFriend, this.gSkillArea],
  122. [this.gEnemy, this.gFriendAttackMonitor],
  123. [this.gEnemy, this.gFriendBullet],
  124. [this.gEnemy, this.gEnemyGainSkill],
  125. [this.gEnemy, this.gFriendHurtSkill],
  126. [this.gEnemy, this.gEnemyGainSkillMonitor],
  127. [this.gEnemy, this.gFriendHurtSkillMonitor],
  128. [this.gEnemy, this.gSkillArea],
  129. [this.gFriendMeleeMonitor, this.gEnemyMeleeMonitor],
  130. [this.gFriendMeleeXMonitor, this.gEnemyMeleeXMonitor],
  131. ,
  132. ]
  133. for (let i = 0; i < this.groupList.length; i++) {
  134. for (let j = 0; j < this.groupList.length; j++) {
  135. this.collisionMatrix[i][j] = colliderPairs.some(arr => {
  136. return [JSON.stringify([i, j]), JSON.stringify([j, i])].includes(JSON.stringify(arr))
  137. })
  138. }
  139. }
  140. //n必须为偶数,单边扇形有n+1个点
  141. this.attackLeftRadiusPoints = ccUtils.generateAttackPoints(Data.game.meleeRange, 10, true, 1)
  142. this.attackRightRadiusPoints = ccUtils.generateAttackPoints(Data.game.meleeRange, 10, false, 1)
  143. //console.log(Data.game.attackLeftRadiusPoints, Data.game.attackRightRadiusPoints)
  144. }
  145. reset() {
  146. Data.game.gameSpeed = 1
  147. }
  148. maskBitByGroupIndex(groupIndex: number) {
  149. let maskBits = 0
  150. let bits = this.collisionMatrix[groupIndex]
  151. for (let i = 0; i < bits.length; i++) {
  152. if (!bits[i]) continue
  153. maskBits |= 1 << i
  154. }
  155. //console.log(this.groupList[groupIndex], '----->', groupIndex, '----mask---------->', maskBits)
  156. return maskBits
  157. }
  158. }