| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- 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, valueStr: string, bonus: number, percent: number, isSc = false) {
- this.node.active = value > 0;
- if (this.flagNode) this.flagNode.active = isSc;
- this.lblValue.string = valueStr;
- this.lblBonus.string = `+${bonus}`;
- this.lblPercent.string = `+${percent}%`;
- const hasBonus = bonus > 0;
- this.bonusNode.active = hasBonus;
- this.valueNode.y = hasBonus ? 11.5 : 0;
- }
- }
|