mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
@@ -4,23 +4,18 @@ import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/compone
|
||||
import PlayerPetData, { PlayerPetEvent } from '../../data/PlayerPetData';
|
||||
import { API, PlayerPetOV } from '../../consts/API';
|
||||
import { PetOV, PlayerPetOVSelect } from '../VO/PetOV';
|
||||
import { PetIconSelectScroll } from '../Consts/Pet/PetIconSelectScroll';
|
||||
import { NodeEventType } from 'cc';
|
||||
import { Label } from 'cc';
|
||||
import { app, TD } from '../../App';
|
||||
import { GUI } from '../UIConfig';
|
||||
import { ProgressBar } from 'cc';
|
||||
import JProgressBar from '../../../../extensions/ngame/assets/ngame/util/components/Progress/JProgressBar';
|
||||
import { Toggle } from 'cc';
|
||||
import GOnHookManager from '../../manager/battle/mode/GOnHookManager';
|
||||
import { Slider } from 'cc';
|
||||
import ResourceData, { ResourceType } from '../../data/ResourceData';
|
||||
import { GUI } from '../UIConfig';
|
||||
import { PetPreviewWindow } from '../Consts/Pet/info/PetPreviewWindow';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('PetUpStarView')
|
||||
export class PetUpStarView extends JNLayerBase {
|
||||
|
||||
@property(JNScrollView)
|
||||
views:JNScrollView; //宠物列表
|
||||
|
||||
@property(Label)
|
||||
petNameLabel:Label; //宠物名称
|
||||
@property(Label)
|
||||
@@ -32,8 +27,27 @@ export class PetUpStarView extends JNLayerBase {
|
||||
@property(JProgressBar)
|
||||
viewPetExpProgress:JProgressBar; //预览宠物经验条
|
||||
|
||||
@property(Toggle)
|
||||
isEngulfToggle:Toggle; //是否主动吞噬 0 星 宠物
|
||||
@property(PetPreviewWindow)
|
||||
petPreview:PetPreviewWindow; //宠物显示窗口
|
||||
|
||||
@property(Slider)
|
||||
slider:Slider; //滑块
|
||||
|
||||
@property(Label)
|
||||
qsLabel:Label; //魂数量
|
||||
|
||||
//消耗数量
|
||||
_consume:number = 0;
|
||||
get consume(){
|
||||
return Math.min(ResourceData.getIns().getValue(ResourceType.Q1S),this._consume);
|
||||
}
|
||||
set consume(value:number){
|
||||
let max = ResourceData.getIns().getValue(ResourceType.Q1S);
|
||||
this._consume = value;
|
||||
//修正
|
||||
this.slider.progress = this.consume / max;
|
||||
this.qsLabel.string = `${ResourceData.getIns().getValue(ResourceType.Q1S) - this.consume}`
|
||||
}
|
||||
|
||||
data:PlayerPetOV;
|
||||
|
||||
@@ -45,39 +59,20 @@ export class PetUpStarView extends JNLayerBase {
|
||||
|
||||
//监听
|
||||
app.event.on(PlayerPetEvent.UPDATE_INFO,this.onUpdateInfo,this); //刷新宠物信息
|
||||
app.event.on(PlayerPetEvent.UPDATE_MINUS,this.onPetMinus,this); //减少宠物
|
||||
|
||||
}
|
||||
|
||||
onJNClose(): void {
|
||||
//取消监听
|
||||
app.event.off(PlayerPetEvent.UPDATE_INFO,this.onUpdateInfo,this); //刷新宠物信息
|
||||
app.event.off(PlayerPetEvent.UPDATE_MINUS,this.onPetMinus,this); //减少宠物
|
||||
}
|
||||
|
||||
|
||||
//刷新页面
|
||||
onUpdateView(){
|
||||
|
||||
//显示选中宠物
|
||||
this.petPreview.bind(this.data);
|
||||
this.onUpdateInfo();
|
||||
|
||||
//当前需要升星的宠物并且未上阵 并且排除自己
|
||||
let pets = PetOV.PlayerPetOVSelects(
|
||||
PlayerPetData.getIns().getPetIdData(
|
||||
this.data.petTbId, //同一种宠物
|
||||
PlayerPetData.getIns().getNoTacticalData() //非上阵宠物
|
||||
).filter(pet => pet.petId != this.data.petId) //排除自己
|
||||
);
|
||||
this.views.refreshData(pets);
|
||||
|
||||
//向子节点添加点击事件
|
||||
this.views.addItemEvent(NodeEventType.TOUCH_START,this.onClickItem.bind(this));
|
||||
|
||||
this.onUpdateSelect();
|
||||
|
||||
//更新吞噬
|
||||
this.isEngulfToggle.isChecked = GOnHookManager.getIns().onHookEngulfPets.indexOf(this.data) >= 0;
|
||||
|
||||
}
|
||||
|
||||
//刷新信息
|
||||
@@ -91,37 +86,15 @@ export class PetUpStarView extends JNLayerBase {
|
||||
this.petStarExp.string = `升级进度: ${upStarExp} / ${this.data.petStarExp}`;
|
||||
this.petExpProgress.value = this.data.petStar + (this.data.petStarExp / upStarExp);
|
||||
|
||||
}
|
||||
|
||||
//减少宠物
|
||||
onPetMinus(pet:PlayerPetOV){
|
||||
this.views.getItems<PetIconSelectScroll>().forEach(item => {
|
||||
if(item.data.petId == pet.petId)
|
||||
this.views.delData(item.data);
|
||||
});
|
||||
}
|
||||
|
||||
//刷新选择
|
||||
onUpdateSelect(){
|
||||
|
||||
//刷新
|
||||
this.views.getItems<PetIconSelectScroll>().forEach((item) => {
|
||||
let data = item.data as PlayerPetOVSelect;
|
||||
item.select.isSelect = data.isSelect;
|
||||
})
|
||||
|
||||
this.onUpdatePreview();
|
||||
this.qsLabel.string = `${ResourceData.getIns().getValue(ResourceType.Q1S) - this.consume}`
|
||||
|
||||
}
|
||||
|
||||
//更新预览进度条
|
||||
onUpdatePreview(){
|
||||
|
||||
//选择得到的经验
|
||||
let exp = this.views.getItems<PetIconSelectScroll>().filter(item => item.select.isSelect).length;
|
||||
|
||||
let upStarExp;
|
||||
let petStarExp = this.data.petStarExp + exp;
|
||||
let petStarExp = this.data.petStarExp + this.consume;
|
||||
let petStar = this.data.petStar;
|
||||
|
||||
while(petStarExp >= (upStarExp = TD.TbGRoleUpStar.get(petStar + 1).merge)){
|
||||
@@ -133,50 +106,41 @@ export class PetUpStarView extends JNLayerBase {
|
||||
this.petStarExp.string = `升级进度: ${upStarExp} / ${petStarExp}`;
|
||||
//预览进度
|
||||
this.viewPetExpProgress.value = petStar + (petStarExp / upStarExp);
|
||||
this.qsLabel.string = `${ResourceData.getIns().getValue(ResourceType.Q1S) - this.consume}`
|
||||
|
||||
}
|
||||
|
||||
//滑动滑块
|
||||
onSliderMove(slider: Slider){
|
||||
|
||||
let max = ResourceData.getIns().getValue(ResourceType.Q1S);
|
||||
if(!max){
|
||||
this.consume = 0;
|
||||
return;
|
||||
}
|
||||
this.consume = Math.ceil(max * slider.progress);
|
||||
|
||||
this.onUpdatePreview();
|
||||
|
||||
}
|
||||
|
||||
//选择全部
|
||||
onClickAll(){
|
||||
let pets = this.views.getData<PlayerPetOVSelect>();
|
||||
//如果全部选择则全部取消
|
||||
if(pets.filter(pet => pet.isSelect).length == pets.length){
|
||||
pets.forEach(pet => pet.isSelect = false);
|
||||
}else{
|
||||
pets.forEach(pet => pet.isSelect = true);
|
||||
}
|
||||
this.onUpdateSelect();
|
||||
}
|
||||
|
||||
//点击Item
|
||||
onClickItem(index:number){
|
||||
let pets = this.views.getData<PlayerPetOVSelect>();
|
||||
pets[index].isSelect = !pets[index].isSelect;
|
||||
this.onUpdateSelect();
|
||||
}
|
||||
|
||||
//点击合成
|
||||
async onClickUp(){
|
||||
|
||||
//获取被合成的Id
|
||||
let pets = this.views.getData<PlayerPetOVSelect>().filter(pet => pet.isSelect).map(pet => pet.petId);
|
||||
|
||||
if(pets.length <= 0){
|
||||
app.layer.Open(GUI.Tips,{text:"请选择需要被合成的宠物"});
|
||||
if(!this.consume){
|
||||
app.layer.Open(GUI.Tips,{text:"拖拽进行升星吧~"})
|
||||
return;
|
||||
}
|
||||
|
||||
await API.PetUpStar(this.data.petId,pets);
|
||||
await API.PetUpStar(this.data.petId,this.consume);
|
||||
this.consume = 0;
|
||||
|
||||
}
|
||||
|
||||
//点击吞噬选择
|
||||
onClickEngulfToggle(){
|
||||
GOnHookManager.getIns().onHookEngulfPets.splice(GOnHookManager.getIns().onHookEngulfPets.indexOf(this.data),1);
|
||||
if(this.isEngulfToggle.isChecked){
|
||||
GOnHookManager.getIns().onHookEngulfPets.push(this.data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -193,17 +193,6 @@ export class IntoBattleView extends JNLayerBase {
|
||||
|
||||
}
|
||||
|
||||
//点击升级
|
||||
async onClickUpLevel(){
|
||||
if(this.index < 0){
|
||||
app.layer.Open(GUI.Tips,{text:"请选择宠物."})
|
||||
return;
|
||||
}
|
||||
await API.PetUpLevel(this.pets[this.index].petId)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user