123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- /**
- * 代码描述
- */
- import { Audio } from "../../common/src/Audio";
- import { GameDataCenter } from "../../common/src/GameDataCenter";
- import { UIManager } from "../../common/src/UIManager";
- import { Utils } from "../../common/src/Utils";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export class TipPanel extends cc.Component {
- @property({ type: cc.Node, tooltip: '面板1' })
- panel1: cc.Node = null;
- @property({ type: cc.Node, tooltip: '面板2' })
- panel2: cc.Node = null;
- private insufficient: boolean = true;
- onEnable() {
- this.panel1.getChildByName('closeButton').on('click', this.onClose, this);
- this.panel1.getChildByName('ice').getChildByName('button').on('click', this.onClose, this);
- this.panel1.getChildByName('insufficient').getChildByName('button').on('click', this.onGet, this);
- this.panel2.getChildByName('closeButton').on('click', this.onClose, this);
- this.panel2.getChildByName('button').on('click', this.onDoubleGet, this);
- //type: 0.没有泡泡,1.泡泡不多了,2.冰球提示,3.炸弹使用提示
- switch (GameDataCenter.tipType) {
- case 0:
- this.panel1.active = true;
- let node = this.panel1.getChildByName('insufficient');
- node.active = true;
- node.getChildByName('label').getComponent(cc.Label).string = '泡泡用完了';
- node.getChildByName('buduile').active = false;
- node.getChildByName('yongwanle').active = true;
- node.getChildByName('tip').getComponent(cc.Label).string = '获得10个泡泡+激光炮';
- let item = node.getChildByName('picture').getChildByName('item');
- item.getChildByName('add').active = true;
- item.getChildByName('bubble').active = true;
- this.insufficient = false;
- Utils.btnTween(this.panel1.getChildByName('insufficient').getChildByName('button'));
- break;
- case 1:
- this.panel1.active = true;
- this.panel1.getChildByName('insufficient').active = true;
- Utils.btnTween(this.panel1.getChildByName('insufficient').getChildByName('button'));
- break;
- case 2:
- this.panel1.active = true;
- this.panel1.getChildByName('ice').active = true;
- if (GameDataCenter.gameLevel == 31) {
- this.panel1.getChildByName('ice').getChildByName('ice').active = true;
- }
- if (GameDataCenter.gameLevel == 11) {
- this.panel1.getChildByName('ice').getChildByName('shitou').active = true;
- }
- if (GameDataCenter.gameLevel == 12) {
- this.panel1.getChildByName('ice').getChildByName('caihong').active = true;
- }
- break;
- case 3:
- this.panel2.active = true;
- this.panel2.getChildByName('tips').active = true;
- Utils.btnTween(this.panel2.getChildByName('button'));
- cc.tween(this.panel2.getChildByName('bg'))
- .by(0.05, { angle: 1 })
- .repeatForever()
- .start();
- break;
- case 4:
- this.panel2.active = true;
- this.panel2.getChildByName('online').active = true;
- this.panel2.getChildByName('button').children[0].getChildByName('label').getComponent(cc.Label).string = '领取';
- Utils.btnTween(this.panel2.getChildByName('button'));
- cc.tween(this.panel2.getChildByName('bg'))
- .by(0.05, { angle: 1 })
- .repeatForever()
- .start();
- }
- Utils.openPanel(this.node.getChildByName('panel'));
- }
- /**关闭 */
- private onClose(): void {
- Audio.playSoundByPath('tip:res/snd/click');
- if (GameDataCenter.tipType == 0) {
- UIManager.open('fail:FailPanel');
- }
- if (GameDataCenter.tipType == 1) {
- cc.systemEvent.emit('showTenButton', true);
- }
- this.node.destroy();
- }
- /**领取 */
- private onGet(): void {
- Audio.playSoundByPath('tip:res/snd/click');
- this.get();
- }
- private get(): void {
- cc.systemEvent.emit('updateBubble', 10);
- if (!this.insufficient) {
- cc.systemEvent.emit('updateUI', 'special2', 1);
- }
- UIManager.close('tip:TipPanel', true);
- }
- /**双倍领取 */
- private onDoubleGet(): void {
- Audio.playSoundByPath('tip:res/snd/click');
- this.doubleGet();
- }
- /**双倍领取 */
- private doubleGet(): void {
- if (GameDataCenter.tipType == 3) {
- cc.systemEvent.emit('updateUI', 'special1', 2);
- }
- else if (GameDataCenter.tipType == 4) {
- GameDataCenter.rewarded = [`${Math.floor(Math.random() * 4)}:1`, '4:80'];
- UIManager.open('rewarded:RewardedPanel');
- cc.systemEvent.emit('startTimer');
- }
- UIManager.close('tip:TipPanel', true);
- }
- }
|