mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交升级
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
9
JisolGameCocos/assets/script/ui/Consts/Pet/info.meta
Normal file
9
JisolGameCocos/assets/script/ui/Consts/Pet/info.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "c1b92428-4724-4f3e-b2c6-416af802434c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "f423768a-7790-4a2f-b005-a40110aba905",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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:"升级成功!"})
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user