123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- /** @format */
- import {BaseUI} from './BaseUI'
- import {Data, Mgr} from '../GameControl'
- import {ccUtils} from '../utils/ccUtils'
- import {list, node, observer} from '../mobx/observer'
- import {GAME_WIN_TYPE, Language, LOCAL, MONSTER_TYPE} from '../enums/Enum'
- import List from '../uiutils/List'
- import {IRoleConfig, RoleConfig} from '../config/RoleConfig'
- import GameUI, {RoundOutType} from '../zuma/FightCore'
- import {CardSkillConfig} from '../config/CardSkillConfig'
- import {IMonsterConfig, MonsterConfig} from '../config/MonsterConfig'
- import {BT} from '../behaviorTree/BehaviorTree'
- import {IStageConfig, StageConfig} from '../config/StageConfig'
- import {IStageInfoConfig, StageInfoConfig} from '../config/StageInfoConfig'
- import {EliteInfoConfig} from '../config/EliteInfoConfig'
- import {EliteStageConfig} from '../config/EliteStageConfig'
- const {ccclass, property} = cc._decorator
- @ccclass
- @observer
- export class GameDevUI extends BaseUI {
- @list('chooseNode/scrollView')
- private chooseList: List
- @node('chooseNode')
- private chooseViewNode: cc.Node
- private allRoleIDs: string[]
- private allCardIDs: string[]
- private isChooseCard: boolean = false
- private gameUI: GameUI
- private curLang: Language
- onShow(args, fromUI: number) {
- this.curLang = Mgr.i18n.getLanguage()
- Mgr.i18n.setLanguage(Language.zh)
- this.gameUI = args
- this.allRoleIDs = Object.keys(RoleConfig).sort((a, b) => parseInt(a) - parseInt(b))
- this.allCardIDs = Object.keys(CardSkillConfig).sort((a, b) => parseInt(a) - parseInt(b))
- //白绿蓝紫橙
- let testID = [1, 4, 7, 11]
- this.allRoleIDs = this.allRoleIDs.filter(value => testID.includes(+value % 100))
- //加上有技能的怪物
- let monsterIDs = Object.keys(MonsterConfig).filter(value => MonsterConfig[value].skills[0] > 0)
- this.allRoleIDs = this.allRoleIDs.concat(monsterIDs)
- cc.debug.setDisplayStats(false)
- this.initItem(true)
- this.initItem(false)
- //检查关卡配置
- this.checkStageConfig(Object.values(StageInfoConfig), StageConfig, '普通')
- this.checkStageConfig(Object.values(EliteInfoConfig), EliteStageConfig, '精英')
- }
- onDisable(): any {
- Mgr.i18n.setLanguage(this.curLang)
- Mgr.event.removeAll(this)
- }
- update(dt: number) {
- if (this.gameUI) {
- let {roleNum, enemyNum, castCost} = this.gameUI.getGameInfo()
- ccUtils.setLabel(roleNum.toString(), this.node, 'roleNum')
- ccUtils.setLabel(enemyNum.toString(), this.node, 'enemyNum')
- ccUtils.setLabel(castCost.toString(), this.node, 'costNum')
- }
- }
- initItem(isChooseCard: boolean) {
- this.isChooseCard = isChooseCard
- let arr = Mgr.storage.getObject(isChooseCard ? LOCAL.chooseMultCard : LOCAL.chooseMultRole, [])
- if (arr) {
- this.chooseList.setMultSelected(arr, null)
- this.onChooseSureClick()
- }
- }
- initChooseRole(node, itemIndex) {
- let curAllIDs = this.isChooseCard ? this.allCardIDs : this.allRoleIDs
- let curCfg = this.isChooseCard
- ? CardSkillConfig[curAllIDs[itemIndex]]
- : this.getRoleCfgByID(+curAllIDs[itemIndex])
- if (curCfg) ccUtils.setLabel(Mgr.i18n.getLabel(curCfg.name) + curCfg.quality + '阶', node, 'lb')
- }
- getRoleCfgByID(ID: number): IRoleConfig {
- let cfg = RoleConfig[ID]
- if (!cfg) cfg = (MonsterConfig[ID] as unknown) as IRoleConfig
- return cfg
- }
- checkStageConfig(stageInfos, stageConfig, stageName: string) {
- let errStage = []
- let errRoleStage = []
- for (let i = 0; i < stageInfos.length; i++) {
- let roleNum = 0
- let stageInfo = stageInfos[i]
- let allRoles = []
- for (let j = 1; j < 100; j++) {
- let stageCfg = stageConfig[stageInfo.ID * 100 + j]
- if (stageCfg) {
- if (stageCfg.summonType == RoundOutType.time || stageCfg.summonType == RoundOutType.dieOut) {
- roleNum += stageCfg.roles[0].length
- } else if (stageCfg.summonType == RoundOutType.average) {
- roleNum += stageCfg.rolesTime.flat().reduce((acc, val) => acc + val, 0)
- }
- let checkLength = (array1, array2) => {
- let isSame = array1.flat().length == array2.flat().length
- if (!isSame)
- console.log(
- '配置长度不一致:',
- stageInfo.ID * 100 + j,
- 'roles长度:',
- stageCfg.roles.flat().length,
- 'rolesPos长度',
- stageCfg.rolesPos.flat().length,
- 'rolesTime长度',
- stageCfg.rolesTime.flat().length,
- )
- return isSame
- }
- //检测配置长度是否一致
- checkLength(stageCfg.roles, stageCfg.rolesPos)
- checkLength(stageCfg.rolesPos, stageCfg.rolesTime)
- allRoles.push(...stageCfg.roles.flat())
- } else {
- if (stageInfo.parameter > 0 && roleNum != stageInfo.parameter) {
- errStage.push(`${stageName}关卡${stageInfo.ID}`)
- }
- break
- }
- }
- //检测类型是杀敌数量的时候,不能有召唤类型的怪物
- if (stageInfo.type == GAME_WIN_TYPE.killNum) {
- let summonArr = allRoles.filter(v => MonsterConfig[v].type == MONSTER_TYPE.baby)
- if (summonArr.length > 0) {
- errRoleStage.push(`${stageName}关卡${stageInfo.ID}:有召唤类型怪物ID:${summonArr}`)
- }
- } else if (stageInfo.type == GAME_WIN_TYPE.boss) {
- //检测boss类型,有且只能有一个boss
- let boosArr = allRoles.filter(v => MonsterConfig[v].type == MONSTER_TYPE.boss)
- if (boosArr.length != 1) {
- errRoleStage.push(`${stageName}关卡${stageInfo.ID}boos数量不等于1:boosID:${boosArr}`)
- }
- }
- }
- if (errStage.length > 0) {
- console.log('关卡配置错误,配置怪物数量不等于通过条件:', errStage.join(','))
- Mgr.ui.tip('关卡配置错误,配置怪物数量不等于通过条件:' + errStage.join(','))
- }
- if (errRoleStage.length > 0) {
- console.log('关卡配置错误,配置的怪物类型错误:', errRoleStage.join(','))
- Mgr.ui.tip('关卡配置错误,配置的怪物类型错误:' + errRoleStage.join(','))
- }
- }
- //网络事件=======================================
- //触发事件=======================================
- // 点击事件=======================================
- onClickCreateRoleEntity(e) {
- if (e.target['cfgID']) this.gameUI.createDevEntity(parseInt(e.target['cfgID']))
- }
- onClickCreateEnemyRoleEntity(e) {
- if (e.target['cfgID']) this.gameUI.createDevEntity(parseInt(e.target['cfgID']), true)
- }
- onClickCreateSkillCardEntity(e) {
- if (e.target['cfgID']) this.gameUI.showSkillPop(Mgr.global.buildICard({id: e.target['cfgID'], lv: 1, sid: ''}))
- }
- onClickDebug() {
- cc.debug.setDisplayStats(!cc.debug.isDisplayStats())
- }
- onClickShowLayout() {
- let layouts = cc.find('layouts', this.node)
- layouts.active = !layouts.active
- }
- onStageChange(editBox: cc.EditBox) {
- this.gameUI.changeStageChange(parseInt(editBox.string))
- }
- onRoleLogChange(editBox: cc.EditBox) {
- BT.debugEntity = parseInt(editBox.string)
- }
- onGameSpeedChange(editBox: cc.EditBox) {
- Data.game.gameSpeed = parseInt(editBox.string)
- }
- onChooseSureOpenClick(e, detail) {
- this.isChooseCard = detail != undefined
- this.chooseViewNode.active = true
- let curAllIDs = this.isChooseCard ? this.allCardIDs : this.allRoleIDs
- this.chooseList.numItems = curAllIDs.length
- this.scheduleOnce(() => {
- let arr = Mgr.storage.getObject(this.isChooseCard ? LOCAL.chooseMultCard : LOCAL.chooseMultRole)
- this.chooseList.setMultSelected(arr, null)
- })
- }
- onChooseSureClick() {
- this.chooseViewNode.active = false
- let multArr = this.chooseList.getMultSelected()
- multArr.sort((a, b) => a - b)
- let key = !this.isChooseCard ? 'layout' : 'layout_card'
- let curAllIDs = this.isChooseCard ? this.allCardIDs : this.allRoleIDs
- for (let i = multArr.length - 1; i >= 0; i--) {
- if (multArr[i] >= curAllIDs.length) {
- multArr.splice(i, 1)
- }
- }
- let nodes = ccUtils.instantChildren(cc.find(`layouts/${key}/btn`, this.node), multArr.length)
- let nodeEs
- if (!this.isChooseCard) {
- nodeEs = ccUtils.instantChildren(cc.find(`layouts/${key}E/btn`, this.node), multArr.length)
- }
- for (let i = 0; i < multArr.length; i++) {
- nodes[i]['cfgID'] = curAllIDs[multArr[i]]
- let cfg = this.isChooseCard ? CardSkillConfig[nodes[i]['cfgID']] : this.getRoleCfgByID(+nodes[i]['cfgID'])
- let name = Mgr.i18n.getLabel(cfg.name)
- ccUtils.setLabel(name + cfg.quality + '阶', nodes[i], 'Label')
- if (nodeEs) {
- nodeEs[i]['cfgID'] = curAllIDs[multArr[i]]
- ccUtils.setLabel(name + cfg.quality + '阶', nodeEs[i], 'Label')
- }
- }
- Mgr.storage.set(this.isChooseCard ? LOCAL.chooseMultCard : LOCAL.chooseMultRole, multArr)
- }
- }
|