/** * 代码描述 */ import { Audio } from "../../common/src/Audio"; import { GameDataCenter } from "../../common/src/GameDataCenter"; import { Utils } from "../../common/src/Utils"; const { ccclass, property } = cc._decorator; @ccclass export class AttendancePanel extends cc.Component { @property({ type: cc.Node, tooltip: '面板' }) panel: cc.Node = null; private day: number = 0; private ui: string[] = ['special1', 'coin', 'special4', 'special3', 'coin', 'special2', 'coin']; private num: number[] = [1, 100, 1, 1, 300, 1]; onEnable() { this.panel.getChildByName('closeButton').on('click', this.onClose, this); this.panel.getChildByName('button').getChildByName('doubleGet').on('click', this.onDoubleGet, this); this.panel.getChildByName('button').getChildByName('get').on('click', this.onGet, this); this.day = (GameDataCenter.signIn) % 7; Utils.openPanel(this.node.getChildByName('panel')); Utils.btnTween(this.panel.getChildByName('button').getChildByName('doubleGet')) let node = this.panel.getChildByName('days'); if (this.day == 7) { for (let i = 0; i < this.day; i++) { node.children[i].getChildByName('mask').active = false; } } else { for (let i = 0; i < this.day; i++) { node.children[i].getChildByName('mask').active = true; } } let today = node.children[this.day]; Utils.btnTween(today); today.getComponent(cc.Sprite).enabled = false; today.getChildByName('bottom').getComponent(cc.Sprite).enabled = false; today.getChildByName('bottom').getChildByName('label').color = cc.color('#FFFFFF' as any); today.getChildByName('bottom').getChildByName('label').x -= 20; today.getChildByName('bottom').getChildByName('videoIcon').active = true; today.getChildByName('di').active = true; today.on('click', this.onDoubleGet, this); } /**关闭 */ private onClose(): void { Audio.playSoundByPath('attendance:res/snd/click'); this.node.destroy(); } /**领取 */ private onGet(): void { Audio.playSoundByPath('attendance:res/snd/click'); GameDataCenter.isSignIn = true; GameDataCenter.signIn++; if (this.day == 6) { for (let i = 1; i <= 4; i++) { cc.systemEvent.emit('updateUI', `special${i}`, 2); } } else { cc.systemEvent.emit('updateUI', this.ui[this.day], this.num[this.day]); } this.node.destroy(); } /**双倍领取 */ private onDoubleGet(): void { Audio.playSoundByPath('attendance:res/snd/click'); GameDataCenter.isSignIn = true; GameDataCenter.signIn++; if (this.day == 6) { for (let i = 1; i <= 4; i++) { cc.systemEvent.emit('updateUI', `special${i}`, 4); } } else { cc.systemEvent.emit('updateUI', this.ui[this.day], this.num[this.day] * 2); } this.node.destroy(); } }