| 123456789101112131415161718192021222324252627282930313233343536 |
- import { _decorator, Component, Node } from 'cc';
- import { BuffData } from '../battle/BuffData';
- import { DataSystem } from '../core/data/DataSystem';
- import { BuffItem } from './BuffItem';
- const { ccclass, property } = _decorator;
- @ccclass('UserBuffList')
- export class UserBuffList extends Component {
- @property({ type: Node, tooltip: "内容节点" }) contentNode: Node;
- @property({ tooltip: "宝箱红包", type: [BuffItem] }) buffList: BuffItem[] = [];
- start() {
- this.setView();
- }
- update() {
- DataSystem.watch(BuffData, 'curBuffs') && this.setView();
- DataSystem.watch(BuffData, 'canUseCombination') && this.setView();
- }
- private async setView() {
- let buffData = DataSystem.getData(BuffData);
- let index = 0;
- if (buffData.canUseCombination) {
- this.buffList[0].setData(110004, true);
- index = 1;
- }
- for (let i = 0; i < buffData.curBuffs.length; i++) {
- if (index < this.buffList.length) {
- this.buffList[index++].setData(buffData.curBuffs[i]);
- }
- }
- for (let i = index; i < this.buffList.length; i++) {
- this.buffList[i].node.active = false;
- }
- }
- }
|