squidGame/tgx-games-client/assets/module_arean/ui_hero_details/HeroScrollCell.ts

73 lines
2.3 KiB
TypeScript

/************************************************************************************
* FileName : HeroScrollCell.ts
* Description : 英雄界面底部列表单元
* Version : v1.0.0
* CreateTime : 2024-10-24 17:04:57
* Author :
* Copyright (c) since 2024
* ==============================================================
* Method Description:
*
* ==============================================================
************************************************************************************/
import {_decorator, Button, Component, 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('HeroScrollCell')
export class HeroScrollCell extends Component {
// 英雄icon
@property(Node)
heroIcon : Node = null;
// 遮罩
@property(Node)
mask : Node = null;
// 品质
@property(Node)
quality : Node = null;
// 选中框
@property(Node)
choose : Node = null;
private _fun : Function = null;
private _data : ISkinCfg = null;
public get data() : ISkinCfg { return this._data; }
public setData(data : ISkinCfg,isHave : boolean,fun : Function) : void {
this._data = data;
this._fun = fun;
this._initIcon();
this._initQuality();
this.updateChooseActive(data.isDefault === 1);
this.updateMaskActive(!isHave);
}
private _initIcon() : void {
let sp: SpriteFrame = resLoader.getSpriteFrame(`res/Image/SkinIcon/skinIcon_${this._data.id}`, ModuleDef.Arean);
if (sp) this.heroIcon.getComponent(Sprite).spriteFrame = sp;
}
private _initQuality() : void {
let sp: SpriteFrame = resLoader.getSpriteFrame(`res/Image/Quality/quality_${this._data.quality}`, ModuleDef.Arean);
if (sp) this.quality.getComponent(Sprite).spriteFrame = sp;
}
public updateChooseActive(flag : boolean) : void{
this.choose.active = flag;
}
public updateMaskActive(flag : boolean) : void{
this.mask.active = flag;
}
public clickHero() : void{
this._fun && this._fun(this._data.id);
this.updateChooseActive(true)
}
}