You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

98 lines
3.7 KiB

import { _decorator, Component, instantiate, Label, Node } from 'cc';
import { RewardData } from './UIsign7Day';
import { ItemData } from '../../game/ConfigProjectData';
import { ItemGrid } from '../../com/ItemGrid';
const { ccclass, property } = _decorator;
@ccclass('SingItem')
export class SingItem extends Component {
bg: Node = null;
bg1: Node = null;
rewardList: Node = null;
dayDesc: Label = null;
lightdown: Node = null;
lightUp: Node = null;
gou: Node = null;
protected onLoad(): void {
this.bg = this.node.getChildByName("bg");
this.bg1 = this.node.getChildByName("bg1");
this.rewardList = this.node.getChildByName("rewardList");
this.dayDesc = this.node.getChildByName("dayDesc").getComponent(Label);
this.lightdown = this.node.getChildByName("lightdown");
this.lightUp = this.node.getChildByName("lightUp");
this.gou = this.node.getChildByName("gou");
}
setData(rewardArray: RewardData[], index: number, curSign: number, curSignStatus: number) {
this._rewardArray = rewardArray;
this._index = index;
this._curSign = curSign;
this._curSignStatus = curSignStatus;
this._items = [];
for (let i = 0; i < this._rewardArray.length; i++) {
let item = this._rewardArray[i];
if (item.type == 1) {
let itemConf = gg.data.table.getItemData(item.prop_id);
if (!itemConf) {
console.error('[SingItem] item config missing', item.prop_id);
continue;
}
if (itemConf.type == 5) {
// 皮肤奖励已移除,按原 prop_id 展示
}
this._items.push(new ItemData(itemConf.id, item.num, itemConf));
} else {
let conf = gg.data.project.getWeaponData(item.prop_id);
if (!conf) {
console.error('[SingItem] weapon config missing', item.prop_id);
continue;
}
const scrapId = gg.data.project.getWeaponScrapId(conf.id);
if (!scrapId) {
console.error('[SingItem] weapon scrapId missing', item.prop_id);
continue;
}
let itemConf = gg.data.table.getItemData(scrapId);
if (!itemConf) {
console.error('[SingItem] scrap item missing', scrapId, 'weapon', item.prop_id);
continue;
}
this._items.push(new ItemData(scrapId, item.num, itemConf));
}
}
this.updateUI();
}
private _rewardArray: RewardData[] = [];
private _index: number = 0;
private _curSign: number = 0;
private _curSignStatus: number = 0;
private _items: ItemData[] = [];
updateUI() {
this.dayDesc.string = gg.lang.get('第{1}天', [this._index + 1])//`第${i + 1}天`;
this.gou.active = this._index < this._curSign || (this._index == this._curSign && this._curSignStatus >= 1);
this.lightdown.children[0].active = this._index <= this._curSign;
this.bg1.active = this._index == this._curSign && this._curSignStatus == 0;
this.rewardList.children.map(x => x.active = false);
for (let i = 0; i < this._items.length; i++) {
let item = this._items[i];
let n: Node = null;
if (i < this.rewardList.children.length) {
n = this.rewardList.children[i];
} else {
n = instantiate(this.rewardList.children[0]);
this.rewardList.addChild(n);
}
n.active = true;
n.getComponent(ItemGrid).setData(item);
}
}
}