import { formatGoodsNum } from '@scripts/utils/Helper'; import { _decorator, Component, Label, Node } from 'cc'; const { ccclass, property } = _decorator; @ccclass('GoodsValue') export class GoodsValue extends Component { @property(Node) flagNode: Node; @property(Node) valueNode: Node; @property(Node) bonusNode: Node; @property(Label) lblBonus: Label; @property(Label) lblPercent: Label; @property(Label) lblValue: Label; initValue(value: number, bonus: number, percent: number, isSc = false) { this.node.active = value > 0; if (this.flagNode) this.flagNode.active = isSc; const total = value + bonus; this.lblValue.string = formatGoodsNum(total); this.lblBonus.string = `+${bonus}`; this.lblPercent.string = `+${percent}%`; const hasBonus = bonus > 0; this.bonusNode.active = hasBonus; this.valueNode.y = hasBonus ? 11.5 : 0; } }