/** @format */ import {Data} from '../GameControl' import {ccUtils} from '../utils/ccUtils' import {GAME_TYPE} from '../enums/Enum' import {SysFrameAni} from '../ECS/systems/SysFrameAni' import {observable} from 'mobx' import {SysEnter} from '../ECS/systems/SysEnter' import {IRelicattributeConfig} from '../config/RelicattributeConfig' import {IRunecardConfig} from '../config/RunecardConfig' import {idNum} from '../proto/typedef' import Asset = cc.Asset /** @format */ export class GameData { groupList: string[] = [ 'default', 'friend', 'enemy', 'friendBullet', 'enemyBullet', 'friendHurtSkill', 'friendGainSkill', 'enemyHurtSkill', 'enemyGainSkill', 'friendHurtSkillMonitor', 'friendGainSkillMonitor', 'enemyHurtSkillMonitor', 'enemyGainSkillMonitor', 'friendMeleeMonitor', 'enemyMeleeMonitor', 'friendMeleeXMonitor', 'enemyMeleeXMonitor', 'friendAttackMonitor', 'enemyAttackMonitor', 'skillArea', ] gFriend: number = this.groupList.indexOf('friend') gEnemy: number = this.groupList.indexOf('enemy') gFriendBullet: number = this.groupList.indexOf('friendBullet') gEnemyBullet: number = this.groupList.indexOf('enemyBullet') gFriendHurtSkill: number = this.groupList.indexOf('friendHurtSkill') gFriendGainSkill: number = this.groupList.indexOf('friendGainSkill') gEnemyHurtSkill: number = this.groupList.indexOf('enemyHurtSkill') gEnemyGainSkill: number = this.groupList.indexOf('enemyGainSkill') gFriendHurtSkillMonitor: number = this.groupList.indexOf('friendHurtSkillMonitor') gFriendGainSkillMonitor: number = this.groupList.indexOf('friendGainSkillMonitor') gEnemyHurtSkillMonitor: number = this.groupList.indexOf('enemyHurtSkillMonitor') gEnemyGainSkillMonitor: number = this.groupList.indexOf('enemyGainSkillMonitor') gFriendMeleeMonitor: number = this.groupList.indexOf('friendMeleeMonitor') gEnemyMeleeMonitor: number = this.groupList.indexOf('enemyMeleeMonitor') gFriendMeleeXMonitor: number = this.groupList.indexOf('friendMeleeXMonitor') gEnemyMeleeXMonitor: number = this.groupList.indexOf('enemyMeleeXMonitor') gFriendAttackMonitor: number = this.groupList.indexOf('friendAttackMonitor') gEnemyAttackMonitor: number = this.groupList.indexOf('enemyAttackMonitor') gSkillArea: number = this.groupList.indexOf('skillArea') collisionMatrix: boolean[][] = new Array(this.groupList.length) .fill([]) .map(() => new Array(this.groupList.length).fill(false)) gameBundle: cc.AssetManager.Bundle gameAssetMap: Map = new Map() //近战探测范围 meleeRange: number = 130 //万分比 rateNum: number = 10000 //配置表CD最大值 cdMax: number = 9999 //防御常数 defenseConst: number = 325 //环境伤害倍率 curHurtRate: number = 0 //光环cd holoCD: number = 0.1 //光环buff持续时间 (光环cd小于光环持续时间) holoDuration: number = 0.15 attackLeftRadiusPoints: cc.Vec2[] = [] attackRightRadiusPoints: cc.Vec2[] = [] //角色出生范围 fightSizeMaxY: number = 250 fightSizeMinY: number = -310 fightSizeMaxX: number = 350 fightSizeMinX: number = -350 //子弹,触摸等范围 fightAreaMaxY: number = 350 fightAreaMinY: number = -410 fightAreaMaxX: number = 350 fightAreaMinX: number = -350 meleeMonitorRangeX: number = 200 meleeMonitorRangeY: number = 1000 meleeYMonitorRangeX: number = 3000 meleeYMonitorRangeY: number = 300 //关卡ID stageID: number = 1 //关卡波数ID stageRound: number //关卡试玩次数 trailTimes: number //开启试玩 trailOpen: boolean //关卡试玩ID trailID: number gameType: GAME_TYPE = GAME_TYPE.none spineTimeRate: number = 1 spineScale: number = 0.22 maxAttackSpeed: number = 50000 minAttackSpeed: number = 5000 maxAttackRange: number = 1000 relicAttrCfg: IRelicattributeConfig[] = [] relicEntryArr: number[] = [] dropOut: idNum[] @observable gameSpeed: number = 1 speedUpTime: number = 0 friendNum: number = 3 init() { let colliderPairs = [ [this.gFriend, this.gEnemyAttackMonitor], [this.gFriend, this.gEnemyBullet], [this.gFriend, this.gFriendGainSkill], [this.gFriend, this.gEnemyHurtSkill], [this.gFriend, this.gFriendGainSkillMonitor], [this.gFriend, this.gEnemyHurtSkillMonitor], [this.gFriend, this.gSkillArea], [this.gEnemy, this.gFriendAttackMonitor], [this.gEnemy, this.gFriendBullet], [this.gEnemy, this.gEnemyGainSkill], [this.gEnemy, this.gFriendHurtSkill], [this.gEnemy, this.gEnemyGainSkillMonitor], [this.gEnemy, this.gFriendHurtSkillMonitor], [this.gEnemy, this.gSkillArea], [this.gFriendMeleeMonitor, this.gEnemyMeleeMonitor], [this.gFriendMeleeXMonitor, this.gEnemyMeleeXMonitor], , ] for (let i = 0; i < this.groupList.length; i++) { for (let j = 0; j < this.groupList.length; j++) { this.collisionMatrix[i][j] = colliderPairs.some(arr => { return [JSON.stringify([i, j]), JSON.stringify([j, i])].includes(JSON.stringify(arr)) }) } } //n必须为偶数,单边扇形有n+1个点 this.attackLeftRadiusPoints = ccUtils.generateAttackPoints(Data.game.meleeRange, 10, true, 1) this.attackRightRadiusPoints = ccUtils.generateAttackPoints(Data.game.meleeRange, 10, false, 1) //console.log(Data.game.attackLeftRadiusPoints, Data.game.attackRightRadiusPoints) } reset() { Data.game.gameSpeed = 1 } maskBitByGroupIndex(groupIndex: number) { let maskBits = 0 let bits = this.collisionMatrix[groupIndex] for (let i = 0; i < bits.length; i++) { if (!bits[i]) continue maskBits |= 1 << i } //console.log(this.groupList[groupIndex], '----->', groupIndex, '----mask---------->', maskBits) return maskBits } }