import { _decorator, Component, Node, Sprite, Label, RichText, SpriteFrame } from 'cc';
import { DataSystem } from '../core/data/DataSystem';
import { ResourceLoader } from '../core/resourceManager/ResourceLoader';
import { StringUtils } from '../core/utils/StringUtils';
import { ConfigData } from '../data/ConfigData';
import { Config } from '../launch/Config';
const { ccclass, property, requireComponent } = _decorator;
@ccclass('BuffItem')
@requireComponent(ResourceLoader)
export class BuffItem extends Component {
@property({ type: Node, tooltip: "技能背景" }) skillNode: Node;
@property({ type: Node, tooltip: "buff背景" }) buffNode: Node;
@property({ type: Sprite, tooltip: "icon图标" }) iconSprite: Sprite;
@property({ type: Label, tooltip: "icon图标" }) nameLabel: Label;
@property({ type: RichText, tooltip: "描述" }) desRichText: RichText;
start() {
}
public async setData(id: number, isSkill: boolean = false) {
this.skillNode.active = isSkill;
this.buffNode.active = !isSkill;
let configData = isSkill ? DataSystem.getData(ConfigData).get('skill') : DataSystem.getData(ConfigData).get('buff');
if (isSkill) {
this.desRichText.string = '' + StringUtils.getRichText(configData[id].des1) + '';
this.iconSprite.spriteFrame = await this.getComponent(ResourceLoader).load('image/skillIcons/skill04/spriteFrame', SpriteFrame);
this.node.active = true;
} else if (configData[id].icon) {
this.desRichText.string = '' + StringUtils.getRichText(configData[id].des) + '';
this.iconSprite.spriteFrame = await this.getComponent(ResourceLoader).load('image/skillIcons/' + configData[id].icon + '/spriteFrame', SpriteFrame);
this.node.active = true;
}
this.nameLabel.string = configData[id].name || '';
}
}