提交升级

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2023-11-28 02:13:05 +08:00
parent 62959f80e4
commit 07db3912cc
46 changed files with 2482 additions and 961 deletions

View File

@@ -71,7 +71,7 @@ export interface PlayerPetOV{
petId:number, //宠物唯一Id
petPlayerId:number; //宠物的玩家Id
petTbId:number; //宠物配置表Id
petGrade:number; //宠物等级
petLevel:number; //宠物等级
petStar:number; //宠物星级
petStarExp:number; //宠物星级经验
}
@@ -102,7 +102,9 @@ export const API = {
/********** 宠物接口 ******************/
GetPlayerPets: async () => RData(await app.api.get(`/game/pet/list`),false) as PlayerPetOV[], //获取玩家全部宠物
//petId 需合成的Id pets 被合成的Id列表
PetUpStar: async (petId:number,pets:number[]) => RData(await app.api.post(`/game/pet/up/star`,{petId,pets}),true) as PlayerPetOV, //提升宠物星
PetUpStar: async (petId:number,pets:number[]) => RData(await app.api.post(`/game/pet/up/star`,{petId,pets}),true) as PlayerPetOV, //提升宠物星
//petId 升级的宠物Id
PetUpLevel: async (petId:number) => RData(await app.api.post(`/game/pet/up/level/${petId}`),true) as PlayerPetOV, //升级宠物
/********** 阵法接口 ******************/
GetPlayerTactical: async () => RData(await app.api.get(`/game/tactical/get`),false) as PlayerTacticalOV, //获取玩家阵法

View File

@@ -75,7 +75,7 @@ export default class PlayerPetData extends BaseData{
if(pet){
//更新数据
Object.assign(pet,resource);
app.event.emit(PlayerPetEvent.UPDATE_INFO)
app.event.emit(PlayerPetEvent.UPDATE_INFO,pet)
}else{
operation = ResourceUpdateType.ADD;
this.onUpdateOV(operation,resource);

View File

@@ -3,6 +3,9 @@ import { _decorator, Component, Node } from 'cc';
import { app } from '../../../App';
import { UIPetAnim } from '../../../consts/GData';
import { v3 } from 'cc';
import { PlayerPetOV } from '../../../consts/API';
import { Label } from 'cc';
import { PlayerPetEvent } from '../../../data/PlayerPetData';
const { ccclass, property } = _decorator;
@ccclass('PetIcon')
@@ -11,13 +14,54 @@ export class PetIcon extends Component {
@property(sp.Skeleton)
spine:sp.Skeleton;
//设置icon
setIcon(petTbId:number){
@property(Node)
starNode:Node; //星星
this.spine.skeletonData = app.battleRes.roleSpine[petTbId];
info:PlayerPetOV;
onLoad(){
this.reset();
//监听
app.event.on(PlayerPetEvent.UPDATE_INFO,this.onUpdateInfo,this)
}
protected onDestroy(): void {
app.event.off(PlayerPetEvent.UPDATE_INFO,this.onUpdateInfo,this)
}
//初始化
reset(){
this.starNode.active = false;
}
//信息更新
onUpdateInfo(info:PlayerPetOV){
if(this.info && info.petId == this.info.petId){
this.onUpdateView(); //刷新页面
}
}
//刷新页面
onUpdateView(){
this.spine.skeletonData = app.battleRes.roleSpine[this.info.petTbId];
this.spine.setAnimation(0,UIPetAnim.std,true);
if(this.info.petStar){
this.starNode.active = true;
this.starNode.getComponentInChildren(Label).string = `${this.info.petStar}`;
}
}
//设置icon
set(info:PlayerPetOV){
this.reset();
this.info = info;
this.onUpdateView();
}
}

View File

@@ -1,5 +1,6 @@
import { _decorator, Component, Node } from 'cc';
import { PetIcon } from './PetIcon';
import { PlayerPetOV } from '../../../consts/API';
const { ccclass, property } = _decorator;
@ccclass('PetIconSelect')
@@ -43,10 +44,10 @@ export class PetIconSelect extends Component {
}
//设置icon
setIcon(petTbId:number){
//设置
set(info:PlayerPetOV){
this.petIcon.setIcon(petTbId);
this.petIcon.set(info);
}

View File

@@ -11,7 +11,7 @@ export class PetIconSelectScroll extends JNScrollViewItem<PlayerPetOV> {
select:PetIconSelect;
protected start(): void {
this.select.setIcon(this.data.petTbId);
this.select.set(this.data);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "c1b92428-4724-4f3e-b2c6-416af802434c",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,78 @@
import { sp } from 'cc';
import { _decorator, Component, Node } from 'cc';
import { PlayerPetOV } from '../../../../consts/API';
import { app } from '../../../../App';
import { UIPetAnim } from '../../../../consts/GData';
import { Label } from 'cc';
import { PlayerPetEvent } from '../../../../data/PlayerPetData';
const { ccclass, property } = _decorator;
@ccclass('PetPreviewWindow')
export class PetPreviewWindow extends Component {
@property(Node)
starNode:Node; //星星节点
@property(Label)
levelLabel:Label; //等级
@property(sp.Skeleton)
spine:sp.Skeleton; //宠物Spine
info:PlayerPetOV;
onLoad(){
this.onUpdateInit();
//监听
app.event.on(PlayerPetEvent.UPDATE_INFO,this.onUpdateInfo,this)
}
protected onDestroy(): void {
app.event.off(PlayerPetEvent.UPDATE_INFO,this.onUpdateInfo,this)
}
//初始化
onUpdateInit(){
//隐藏
this.starNode.active = false;
this.levelLabel.node.active = false;
}
//刷新信息
onUpdateInfo(info:PlayerPetOV){
if(this.info && info.petId == this.info.petId){
this.onUpdateView(); //刷新页面
}
}
//刷新页面
onUpdateView(){
this.onUpdateInit();
//显示宠物
this.spine.skeletonData = app.battleRes.roleSpine[this.info.petTbId];
this.spine.setAnimation(0,UIPetAnim.std,true);
//等级
this.levelLabel.node.active = true;
this.levelLabel.string = `Lv ${this.info.petLevel}`;
//如果有星则显示星
if(this.info.petStar){
this.starNode.active = true;
this.starNode.getComponentInChildren(Label).string = `${this.info.petStar}`;
}
}
//绑定显示的宠物
bind(info:PlayerPetOV){
this.info = info;
this.onUpdateView();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f423768a-7790-4a2f-b005-a40110aba905",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -12,7 +12,14 @@ export class MainSreepsIcon extends JNScrollViewItem<GOnHookPet> {
icon:PetIconSelect;
start(){
this.icon.setIcon(this.data.petTbId);
this.icon.set({
petTbId: this.data.petTbId,
petId: 0,
petPlayerId: 0,
petLevel: 0,
petStar: 0,
petStarExp: 0
});
}
}

View File

@@ -6,11 +6,12 @@ import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/compone
import { NodeEventType } from 'cc';
import { sp } from 'cc';
import { app } from '../../App';
import { PlayerPetOV } from '../../consts/API';
import { API, PlayerPetOV } from '../../consts/API';
import { UIPetAnim } from '../../consts/GData';
import { GUI } from '../UIConfig';
import PlayerTacticalData from '../../data/PlayerTacticalData';
import { PetIconSelectScroll } from '../Consts/Pet/PetIconSelectScroll';
import { PetPreviewWindow } from '../Consts/Pet/info/PetPreviewWindow';
const { ccclass, property } = _decorator;
//上阵页面
@@ -21,8 +22,8 @@ export class IntoBattleView extends JNLayerBase {
@property(JNScrollView)
views:JNScrollView; //宠物列表
@property(sp.Skeleton)
spine:sp.Skeleton; //当前选中的宠物
@property(PetPreviewWindow)
petPreview:PetPreviewWindow; //宠物显示窗口
//宠物数据
pets:PlayerPetOV[] = [];
@@ -79,8 +80,7 @@ export class IntoBattleView extends JNLayerBase {
current.select.isSelect = true;
//显示选中宠物
this.spine.skeletonData = app.battleRes.roleSpine[this.pets[this.index].petTbId];
this.spine.setAnimation(0,UIPetAnim.std,true);
this.petPreview.bind(this.pets[this.index]);
}
}
@@ -126,6 +126,17 @@ export class IntoBattleView extends JNLayerBase {
}
//点击升级
async onClickUpLevel(){
if(this.index < 0){
app.layer.Open(GUI.Tips,{text:"请选择宠物."})
return;
}
if(await API.PetUpLevel(this.pets[this.index].petId))
app.layer.Open(GUI.Tips,{text:"升级成功!"})
}
}