| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import { _decorator, Component, Node, Label, tween, v3, find, EventHandler } from 'cc';
- import { OpenWindow } from '../core/ui/window/OpenWindow';
- import { Window } from '../core/ui/window/Window';
- import { WindowManager } from '../core/ui/window/WindowManager';
- import { WindowOpenMode } from '../core/ui/window/WindowOpenMode';
- import { g } from '../Data/g';
- import { UIEffect } from '../Main/UIEffect';
- const { ccclass, property } = _decorator;
- @ccclass('GetDiamond')
- export class GetDiamond extends Component {
- @property({ tooltip: "旋转光效节点", type: Node })
- public turnLightBox: Node;
- @property({ tooltip: "贡献icon", type: Node })
- public diamondIcon: Node;
- @property({ tooltip: "贡献值txt", type: Node })
- public diamondTxt: Node;
- @property({ tooltip: "领取按钮", type: Node }) private getBtn: Node;
- @property({ tooltip: "更多领取按钮", type: Node }) private getMoreBtn: Node;
- public newWindowType: number = -1;//新窗口类型
- public newWindowData: any;//新窗口参数
- public addDiamond: number = 0;//新获得神石数值
- public closeBackFun: EventHandler;
- start() {
- g.gameData.isPlayAddDiamondAnim = true;
- }
- /**
- * @zn 初始化界面信息
- * @param data 0:神石值,1:所需打开新窗口类型(-1:无新窗口打开,0:金币窗口,1:合成红包奖励),2:新窗口参数(无新窗口不用填写),3:窗口关闭回调(无回调可不填)
- */
- public setData(data: any[]) {
- this.diamondTxt.getComponent(Label).string = "神石:" + data[0];
- this.addDiamond = data[0];
- this.newWindowType = data[1];//红包类型
- this.newWindowData = this.newWindowType == 0 ? data[2] : null;
- if (data[3]) {
- this.closeBackFun = data[3];
- }
- if (this.newWindowType == 1) {
- this.getBtn.active = false;
- } else {
- this.getMoreBtn.active = false;
- }
- }
- /**
- * 领取神石
- */
- public async getDiamond() {
- //通知货币变化 货币飞行动画
- let times = this.addDiamond > 10 ? 10 : this.addDiamond;
- let _window = await WindowManager.open("Prefabs/Windows/货币飞行控制器", WindowOpenMode.NotCloseAndAdd);
- switch (this.newWindowType) {
- case 0://打开金币领取窗口
- await this.getComponent(OpenWindow).open(this.newWindowData);
- g.gameData.isPlayMoneyAnim = true;
- break;
- case 1://打开金币领取窗口
- this.getComponent(Window).close();
- WindowManager.open('Prefabs/Each/EachWindow', WindowOpenMode.NotCloseAndAdd);
- break;
- default://直接关闭窗口
- this.getComponent(Window).close();
- break;
- }
- _window.getComponent(UIEffect).changeDiamond(this.addDiamond, times);
- _window.getComponent(UIEffect).showEffect(0, times);
- this.closeBackFun && this.closeBackFun.emit([]);
- }
- }
|