import { _decorator, Component, Node, Label, Sprite, SpriteFrame, find } from 'cc'; import { ADHelper } from '../../ADHelper'; import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils'; import { Utils } from '../../core/utils/Utils'; import { g } from '../../Data/g'; import { NoviceWindow } from '../Novice/NoviceWindow'; import { UIEffect } from '../UIEffect'; import { GetType } from './GetType'; const { ccclass, property } = _decorator; @ccclass('GetWindow') export class GetWindow extends Component { @property({ type: Label, tooltip: "数量文本" }) countLabel: Label; @property({ type: Sprite, tooltip: "icon图标" }) icon: Sprite; private imageMap = [ { big: "Images/Turntable/red/spriteFrame", small: "Images/Turntable/red_small/spriteFrame" }, { big: "Images/Turntable/diamond/spriteFrame", small: "Images/Turntable/diamond_small/spriteFrame" }, { big: "Images/Turntable/star/spriteFrame", small: "Images/Turntable/star_small/spriteFrame" } ] private data: { count: number, type: GetType, needBezierEffect: boolean, particCount: number }[] = []; private effectNode: Node; start() { if (!NoviceWindow.isNovicing) { this.getComponent(ADHelper).show(); } } public async onParams(data: { count: number, type: GetType, needBezierEffect: boolean, particCount: number }[] = [{ count: 1500, type: GetType.RedBag, needBezierEffect: true, particCount: 11 }], effectNode?: Node) { this.countLabel.string = "x" + data[0].count; this.data = data.concat(); this.effectNode = effectNode; this.icon.spriteFrame = await ResourcesUtils.load(this.imageMap[this.data[0].type].big, SpriteFrame, this.node); } onDestroy() { for (let i = 0; i < this.data.length; i++) { if (this.data[i].needBezierEffect) { find("Canvas/UI").getComponent(UIEffect).showBezierRedBagEffect(this.data[i].type, this.effectNode, this.data[i].particCount); } switch (this.data[i].type) { case GetType.RedBag: g.userData.bonus += this.data[i].count; break; case GetType.Diamond: g.userData.diamond += this.data[i].count; break; case GetType.exp: g.userData.lv += this.data[i].count; break; } } } }