mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交地图选择
This commit is contained in:
@@ -18,6 +18,12 @@ export class MapSelectShowItem extends JNScrollViewItem<TB.TbGOnHookMaps> {
|
||||
@property({type:Label,displayName:"地图介绍"})
|
||||
mapText:Label;
|
||||
|
||||
@property({type:Node,displayName:"选中图片"})
|
||||
selectNode:Node;
|
||||
|
||||
//是否选择
|
||||
isSelect:boolean = false;
|
||||
|
||||
onInit(data: TB.TbGOnHookMaps): void {
|
||||
|
||||
this.onUpdateView();
|
||||
@@ -29,10 +35,13 @@ export class MapSelectShowItem extends JNScrollViewItem<TB.TbGOnHookMaps> {
|
||||
|
||||
this.mapName.string = this.data.name;
|
||||
this.mapText.string = this.data.introduce;
|
||||
this.selectNode.active = !!this.isSelect;
|
||||
|
||||
//加载预览图
|
||||
TbResource.loadSpriteFrame(this.data.mapImage,this.mapImage,this);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,7 +1,12 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNLayerBase from '../../../../extensions/ngame/assets/ngame/ui/base/JNLayerBase';
|
||||
import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView';
|
||||
import { TD } from '../../App';
|
||||
import { app, TD } from '../../App';
|
||||
import GOnHookData from '../../data/GOnHookData';
|
||||
import { TbGOnHookMaps } from '../../../resources/config/data/schema';
|
||||
import { MapSelectShowItem } from './MapSelectShowItem';
|
||||
import { NodeEventType } from 'cc';
|
||||
import GOnHookManager from '../../manager/battle/mode/GOnHookManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('MapSelectView')
|
||||
@@ -11,13 +16,53 @@ export class MapSelectView extends JNLayerBase {
|
||||
@property(JNScrollView)
|
||||
views:JNScrollView;
|
||||
|
||||
//当前地图下标
|
||||
index:number = -1;
|
||||
|
||||
onJNLoad(data?: any): void {
|
||||
super.onJNLoad(data);
|
||||
|
||||
TD.TbGOnHookMaps.getDataList().forEach((item,index) => {
|
||||
if(GOnHookData.getIns().info.onHookMap == item.id){
|
||||
this.index = index;
|
||||
}
|
||||
})
|
||||
|
||||
this.views.refreshData(TD.TbGOnHookMaps.getDataList())
|
||||
|
||||
let items = this.views.getItems<MapSelectShowItem>();
|
||||
|
||||
//向子节点添加点击事件
|
||||
this.views.addItemEvent(NodeEventType.TOUCH_START,this.onClickItem.bind(this));
|
||||
|
||||
items[this.index].isSelect = true;
|
||||
items[this.index].onUpdateView();
|
||||
|
||||
}
|
||||
|
||||
//点击地图
|
||||
onClickItem(index:number){
|
||||
let items = this.views.getItems<MapSelectShowItem>();
|
||||
|
||||
items.forEach(item => {
|
||||
item.isSelect = false;
|
||||
})
|
||||
this.index = index;
|
||||
items[this.index].isSelect = true;
|
||||
this.views.getItems<MapSelectShowItem>().forEach(item => item.onUpdateView())
|
||||
|
||||
}
|
||||
|
||||
//点击确认
|
||||
async onClickConfirm(){
|
||||
|
||||
await GOnHookManager.getIns().setMap(this.views.getItems<MapSelectShowItem>()[this.index].data.id);
|
||||
|
||||
//关闭页面
|
||||
app.layer.CloseNode(this.node);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user