mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交捕捉
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNScrollViewItem from '../../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollViewItem';
|
||||
import { GOnHookPet } from '../../../../../extensions/ngame/assets/ngame/message/proto';
|
||||
import { PetIcon } from '../../Consts/Pet/PetIcon';
|
||||
import { PetIconSelect } from '../../Consts/Pet/PetIconSelect';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('MainSreepsIcon')
|
||||
export class MainSreepsIcon extends JNScrollViewItem<GOnHookPet> {
|
||||
|
||||
@property(PetIconSelect)
|
||||
icon:PetIconSelect;
|
||||
|
||||
start(){
|
||||
this.icon.setIcon(this.data.petTbId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "590f92c6-d3f3-4143-9de4-e47a1257257a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNScrollView from '../../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView';
|
||||
import { app } from '../../../App';
|
||||
import GOnHookManager, { GOnHookManagerEvent } from '../../../manager/battle/mode/GOnHookManager';
|
||||
import { GOnHookPet } from '../../../../../extensions/ngame/assets/ngame/message/proto';
|
||||
import { MainSreepsIcon } from './MainSreepsIcon';
|
||||
import { NodeEventType } from 'cc';
|
||||
import { GUI } from '../../UIConfig';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('MainSreepsList')
|
||||
export class MainSreepsList extends Component {
|
||||
|
||||
//野怪列表
|
||||
@property(JNScrollView)
|
||||
views:JNScrollView;
|
||||
|
||||
//默认选择
|
||||
index:number = 0;
|
||||
|
||||
onLoad(){
|
||||
|
||||
//监听 野怪死亡
|
||||
app.event.on(GOnHookManagerEvent.ADD_KILL_SREEP,this.onAddSreep,this);
|
||||
//监听 野怪删除
|
||||
app.event.on(GOnHookManagerEvent.DEL_KILL_SREEP,this.onDelSreep,this);
|
||||
|
||||
//添加子节点事件
|
||||
this.views.addItemEvent(NodeEventType.TOUCH_END,this.onClickItem.bind(this));
|
||||
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
|
||||
//取消监听
|
||||
app.event.off(GOnHookManagerEvent.ADD_KILL_SREEP,this.onAddSreep,this);
|
||||
app.event.on(GOnHookManagerEvent.DEL_KILL_SREEP,this.onDelSreep,this);
|
||||
}
|
||||
|
||||
|
||||
//添加野怪
|
||||
onAddSreep(sreep:GOnHookPet){
|
||||
this.views.addData(sreep);
|
||||
}
|
||||
|
||||
//删除野怪
|
||||
onDelSreep(sreep:GOnHookPet){
|
||||
this.views.delData(sreep);
|
||||
}
|
||||
|
||||
//刷新
|
||||
onUpdateView(){
|
||||
|
||||
let items = this.views.getItems<MainSreepsIcon>();
|
||||
|
||||
if(items.length <= 0) return;
|
||||
|
||||
//取消选中
|
||||
items.forEach(item => item.icon.isSelect = false)
|
||||
|
||||
//选中index
|
||||
if(items[this.index]) items[this.index].icon.isSelect = true;
|
||||
|
||||
}
|
||||
|
||||
//点击子节点
|
||||
onClickItem(index:number){
|
||||
|
||||
this.index = index;
|
||||
this.onUpdateView();
|
||||
|
||||
}
|
||||
|
||||
//捕捉野怪
|
||||
async onClickCatch(){
|
||||
|
||||
//获取选中的野怪
|
||||
let item = this.views.getItems<MainSreepsIcon>()[this.index];
|
||||
|
||||
if(!item){
|
||||
app.layer.Open(GUI.Tips,{text:"请选择需要捕捉的宠物"});
|
||||
return;
|
||||
}
|
||||
|
||||
if(await GOnHookManager.getIns().onCatchCreeps(item.data))
|
||||
app.layer.Open(GUI.Tips,{text:"捕捉成功!"});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "fe2ad307-ecc6-45e4-a5e0-4782b0bf0257",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user