| 12345678910111213141516171819202122232425262728293031323334353637 |
- 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 = '<outline color=#000000 width=1>' + StringUtils.getRichText(configData[id].des1) + '</outline>';
- this.iconSprite.spriteFrame = await this.getComponent(ResourceLoader).load<SpriteFrame>('image/skillIcons/skill04/spriteFrame', SpriteFrame);
- this.node.active = true;
- } else if (configData[id].icon) {
- this.desRichText.string = '<outline color=#000000 width=1>' + StringUtils.getRichText(configData[id].des) + '</outline>';
- this.iconSprite.spriteFrame = await this.getComponent(ResourceLoader).load<SpriteFrame>('image/skillIcons/' + configData[id].icon + '/spriteFrame', SpriteFrame);
- this.node.active = true;
- }
- this.nameLabel.string = configData[id].name || '';
- }
- }
|