import { _decorator, Component, Node, Sprite, Label, SpriteFrame, find } from 'cc'; import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils'; import { BitmapFont } from '../../core/ui/BitmapFont'; import { g } from '../../Data/g'; import { platform } from '../../Data/platform'; import { UIEffect } from '../UIEffect'; const { ccclass, property } = _decorator; @ccclass('PlantRewardWindow') export class PlantRewardWindow extends Component { @property({ type: Sprite, tooltip: "奖励图标" }) rewardIcon: Sprite; @property({ type: BitmapFont, tooltip: "奖励数量文本" }) rewardLabel: BitmapFont; private type = 0; private count = 0; public async onParams(data: any) { this.count = data.value; switch (data.reward_type) { case "bonus": this.type = 0; // g.userData.bonus += data.value; this.rewardIcon.spriteFrame = await ResourcesUtils.load("Images/Turntable/red/spriteFrame", SpriteFrame, this.node); break; case "diamond": this.type = 1; // g.userData.diamond += data.value; this.rewardIcon.spriteFrame = await ResourcesUtils.load("Images/Turntable/diamond/spriteFrame", SpriteFrame, this.node); break; } this.rewardLabel.string = "x" + data.value; } onDestroy() { switch (this.type) { case 0: platform.reportThinking("envelope_increase", JSON.stringify({ previous_number: g.userData.bonus, increase_number: this.count, current_number: g.userData.bonus + this.count, reasons: "PlantReward" })); g.userData.bonus += this.count; break; case 1: platform.reportThinking("diamond_increase", JSON.stringify({ previous_number: g.userData.diamond, increase_number: this.count, current_number: g.userData.diamond + this.count, reasons: "PlantReward" })); g.userData.diamond += this.count; break; } find("Canvas/UI").getComponent(UIEffect).showBezierRedBagEffect(this.type, null, 1); } }