提交拖拽阵法

This commit is contained in:
PC-20230316NUNE\Administrator
2023-11-16 19:10:19 +08:00
parent 1683ec01a0
commit c4437fef5e
24 changed files with 509 additions and 96 deletions

View File

@@ -3,7 +3,6 @@ import JNLayerBase from '../../../../extensions/ngame/assets/ngame/ui/base/JNLay
import { Prefab } from 'cc';
import PlayerPetData from '../../data/PlayerPetData';
import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView';
import { PetIconItem } from '../Consts/Pet/PetIconItem';
import { NodeEventType } from 'cc';
import { sp } from 'cc';
import { app } from '../../App';
@@ -11,6 +10,7 @@ import { PlayerPetOV } from '../../consts/API';
import { UIPetAnim } from '../../consts/GData';
import { GUI } from '../UIConfig';
import PlayerTacticalData from '../../data/PlayerTacticalData';
import { IntoBattlePetIcon } from './IntoBattlePetIcon';
const { ccclass, property } = _decorator;
//上阵页面
@@ -55,35 +55,49 @@ export class IntoBattleView extends JNLayerBase {
this.pets = PlayerPetData.getIns().getData();
this.views.refreshData(this.pets);
//设置不可选中
this.views.getItems<IntoBattlePetIcon>().forEach(item => {
if(PlayerTacticalData.getIns().getTacticalInfo().indexOf(item.data.petId) != -1)
item.isNoSelect = true; //如果在阵法里则不可选中
})
//向子节点添加点击事件
this.views.addItemEvent(NodeEventType.TOUCH_START,this.onClickItem.bind(this));
this.onUpdateSelect();
}
//刷新选中
onUpdateSelect(){
//默认都不选中
this.views.getItems<PetIconItem>().forEach(item => {
this.views.getItems<IntoBattlePetIcon>().forEach(item => {
item.isSelect = false;
item.onUpdateSelect();
})
//设置选中
if(this.index != -1){
let current = this.views.getItems<PetIconItem>()[this.index]
let current = this.views.getItems<IntoBattlePetIcon>()[this.index]
current.isSelect = true;
current.onUpdateSelect();
}
//显示选中宠物
this.spine.skeletonData = app.battleRes.roleSpine[this.pets[this.index].petTbId];
this.spine.setAnimation(0,UIPetAnim.std,true);
//显示选中宠物
this.spine.skeletonData = app.battleRes.roleSpine[this.pets[this.index].petTbId];
this.spine.setAnimation(0,UIPetAnim.std,true);
}
}
//点击Item
onClickItem(index:number){
//判断是否不可选中
if(this.views.getItems<IntoBattlePetIcon>()[index].isNoSelect) {
app.layer.Open(GUI.Tips,{text:"当前宠物已上阵"})
return;
}
//设置当前选中
this.index = index;
@@ -101,7 +115,7 @@ export class IntoBattleView extends JNLayerBase {
}
//修改上阵信息
await PlayerTacticalData.getIns().UpdateIndexTactical(this.index,this.pets[this.index].petId);
await PlayerTacticalData.getIns().UpdateIndexTactical(this.tIndex,this.pets[this.index].petId);
//上阵完 关闭页面
app.layer.CloseNode(this.node);