69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
/************************************************************************************
|
|
|
|
* FileName : SkinItem.ts
|
|
* Description :
|
|
* Version : v1.0.0
|
|
* CreateTime : 2024-10-22 09:55:13
|
|
* Author :
|
|
* Copyright (c) since 2024
|
|
* ==============================================================
|
|
* Method Description:
|
|
*
|
|
* ==============================================================
|
|
************************************************************************************/
|
|
import {_decorator, Component, Label, Node, Sprite, SpriteFrame} from 'cc';
|
|
import {resLoader} from "db://assets/core_tgx/base/utils/ResLoader";
|
|
import {ModuleDef} from "db://assets/scripts/ModuleDef";
|
|
import { ISkinCfg } from '../../module_basic/shared/configs/interface/ISkinCfg';
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('SkinItem')
|
|
export class SkinItem extends Component {
|
|
@property(Node)
|
|
skinIcon: Node = null;
|
|
@property(Node)
|
|
qualityIcon: Node = null;
|
|
@property(Label)
|
|
skinName1: Label = null;
|
|
@property(Label)
|
|
skinName2: Label = null;
|
|
|
|
// 皮肤唯一标识
|
|
private _skinId : number = null;
|
|
private _fun : Function = null;
|
|
private _skinData : ISkinCfg = null;
|
|
public get skinData() : ISkinCfg{
|
|
return this._skinData;
|
|
}
|
|
|
|
public initData(data: ISkinCfg,callBack : Function) : void{
|
|
this._skinId = data.id;
|
|
this._skinData = data;
|
|
this._fun = callBack;
|
|
this._initIcon(data.id);
|
|
this._initQuality(data.quality);
|
|
this._initName(data.name,data.name);
|
|
}
|
|
|
|
private _initIcon(res : number) : void{
|
|
let sp : SpriteFrame = resLoader.getSpriteFrame(`res/Image/SkinIcon/skinIcon_${res}`,ModuleDef.Arean);
|
|
if(sp) this.skinIcon.getComponent(Sprite).spriteFrame = sp;
|
|
}
|
|
|
|
|
|
private _initQuality(quality : number) : void{
|
|
let sp : SpriteFrame = resLoader.getSpriteFrame(`res/Image/Quality/quality_${quality}`,ModuleDef.Arean);
|
|
if(sp) this.qualityIcon.getComponent(Sprite).spriteFrame = sp;
|
|
}
|
|
|
|
private _initName(name1 : string,name2 : string) : void {
|
|
this.skinName1.string = name1;
|
|
// let heroData = CommonFun.getInstance().checkSkinBelongToHero(this.skinData);
|
|
// this.skinName2.string = heroData ? heroData.name : "";
|
|
}
|
|
|
|
public clickSkin() : void{
|
|
this._fun && this._fun(this._skinId);
|
|
}
|
|
} |