12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- /** @format */
- import {BaseUI} from './BaseUI'
- import {ccUtils} from '../utils/ccUtils'
- import {observer} from '../mobx/observer'
- import {GUIDE_TYPE, LANGUAGE_TYPE} from '../enums/Enum'
- import {IUserGuide} from '../interface/UIInterface'
- import {Data, Mgr} from '../GameControl'
- import {IMonsterManualConfig, MonsterManualConfig} from '../config/MonsterManualConfig'
- const {ccclass, property} = cc._decorator
- @ccclass
- @observer
- export class UserGuideUI extends BaseUI {
- callback: Function
- curPage: number = 1
- allPageNum: number = 2
- onShow(args: IUserGuide, fromUI: number) {
- let key = GUIDE_TYPE[args.guideType]
- ccUtils.setLabel(
- args.guideType == GUIDE_TYPE.monster ? LANGUAGE_TYPE.specialEnemy : LANGUAGE_TYPE.explain,
- this.node,
- 'title/label',
- )
- this.callback = args.callback
- cc.find('all', this.node).children.forEach(value => {
- value.active = value.name == key
- if (value.active) {
- this.allPageNum = value.children.length
- if (args.guideType == GUIDE_TYPE.monster) {
- let cfg: IMonsterManualConfig = Object.values(MonsterManualConfig).find(
- v => v.trigger == Data.game.stageID,
- )
- if (cfg) {
- Mgr.global.initRoleSpineByName(cfg.resources, value, 'spine')
- ccUtils.setLabel(cfg.monster, value, 'name')
- ccUtils.setLabel(cfg.skill, value, 'des')
- let attrs = ccUtils.instantChildren(cc.find('attrs/attr', value), cfg.features.length)
- for (let i = 0; i < attrs.length; i++) {
- let attr = attrs[i]
- let feature = cfg.features[i]
- ccUtils.setLabel(feature, attr)
- }
- }
- }
- }
- })
- this.curPage = 1
- }
- onHide(): any {
- this.callback && this.callback()
- return super.onHide()
- }
- //UI或者其他函数=======================================
- switchPage(node: cc.Node) {
- node.parent.children.forEach(value => (value.active = value.name == `page${this.curPage}`))
- }
- //网络事件=======================================
- //触发事件=======================================
- // 点击事件=======================================
- onNextClick(e) {
- this.curPage += 1
- if (this.curPage > this.allPageNum) this.curPage = 1
- this.switchPage(e.target.parent)
- }
- onPreClick(e) {
- this.curPage -= 1
- if (this.curPage < 1) this.curPage = 1
- this.switchPage(e.target.parent)
- }
- }
|