import { RewardState, RewardType } from "../../data/GameData"; import { CSignType } from "../../data/module/SignData"; const { ccclass, property } = cc._decorator; /** * 签到icon组件 * @author 薛鸿潇 * - 红包icon:用红包样式 * - 现金、金猪现金:用提现样式 */ @ccclass export default class SignIconBigItem extends cc.Component { @property({ displayName: '天数', type: cc.Label }) private lbl_day: cc.Label = null; @property({ displayName: '金额', type: cc.Label }) private lbl_money: cc.Label = null; @property({ displayName: '蒙版', type: cc.Node }) private node_mask: cc.Node = null; @property({ displayName: '勾', type: cc.Node }) private node_gou: cc.Node = null; /** 数据 */ private icon_data: CSignType = { id: 0, rewardType: 0, rewardNum: 0, loginDay: 0, showType: 0 } /** * 初始化数据 */ public async setItemData(icon_data) { await this.initIcon(icon_data); } /** * 初始化icon * @param icon_data 数据 */ private initIcon(icon_data) { this.icon_data = icon_data; if (!this.icon_data) { this.node.active = false; return } this.lbl_day.string = '第' + this.icon_data.id + '天'; if (this.icon_data.showType == 2) { this.lbl_day.node.getComponent(cc.LabelOutline).color = cc.color(DayOutLineColor.cash); this.lbl_money.string = (this.icon_data.rewardNum * 0.0001) + '元'; } else { this.lbl_day.node.getComponent(cc.LabelOutline).color = cc.color(DayOutLineColor.red_bag); } // 状态样式 let state = gData.sign.getStateByDay(this.icon_data.id); if (state == RewardState.none) { this.node_mask.active = true; this.node_gou.active = true; } else if (state == RewardState.unlock) { this.node_mask.active = false; this.node_gou.active = false; } else if (state == RewardState.lock) { this.node_mask.active = false; this.node_gou.active = false; } } } /** 天数描边 */ enum DayOutLineColor { /** 红包 */ red_bag = '#EB3A0E' as any, /** 提现 */ cash = '#2AB718' as any, }