| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- import { RewardState, RewardType } from "../../data/GameData";
- import { CSignType } from "../../data/module/SignData";
- const { ccclass, property } = cc._decorator;
- /**
- * 签到icon组件
- * @author 薛鸿潇
- * - 红包icon:用红包样式
- * - 现金、金猪现金:用提现样式
- */
- @ccclass
- export default class SignIconItem extends cc.Component {
- @property({ displayName: '提现样式', type: cc.Node })
- private node_cash: cc.Node = null!;
- @property({ displayName: '红包样式', type: cc.Node })
- private node_redbag: cc.Node = null!;
- @property({ displayName: '现金提示', type: cc.Node })
- private node_money: cc.Node = null!;
- @property({ displayName: '天数', type: cc.Label })
- private lbl_day: 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,
- videoNum: 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.rewardType == RewardType.rmb || this.icon_data.rewardType == RewardType.pigRmb) {
- this.node_cash.active = true;
- this.node_redbag.active = false;
- this.lbl_day.node.getComponent(cc.LabelOutline).color = cc.color(DayOutLineColor.cash);
- } else {
- this.node_cash.active = false;
- this.node_redbag.active = true;
- 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;
- this.node_money.active = false;
- } 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,
- }
|