12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { _decorator, Component, Node, LabelComponent } from 'cc';
- import { NoticeManager } from '../../../engines/notices/NoticeManager';
- import StringUtils from '../../../engines/utils/StringUtils';
- import { PlatformManager } from '../../../Platform/PlatformManager';
- import { branchIdType } from '../../../Platform/WeChat/branchIdType';
- import { WeChatPlatform } from '../../../Platform/WeChat/WeChatPlatform';
- import { GameModel } from '../../models/GameModel';
- const { ccclass, property } = _decorator;
- @ccclass('ExchangeItemRenderScript')
- export class ExchangeItemRenderScript extends Component {
- @property({
- type: LabelComponent
- })
- timeLabel: LabelComponent = null;
- @property({
- type: LabelComponent
- })
- timeLabel1: LabelComponent = null;
- @property({
- type: LabelComponent
- })
- goldLabel: LabelComponent = null;
- @property({
- type: LabelComponent
- })
- diamondLabel: LabelComponent = null;
- private data: any;
- private gold:number;
- UpdateItemRender(data: any): void {
- this.data = data;
- let time: number = data.time / 60 / 60;
- this.gold=GameModel.single.fullEarnings * data.time;
- this.timeLabel.string = time + "小时枪械收益";
- this.timeLabel1.string = "立即获得" + time + "小时枪械收益!";
- this.goldLabel.string = StringUtils.numberUtilsEn(this.gold);
- this.diamondLabel.string = StringUtils.numberUtilsEn(data.useDiamond, 0);
- }
- /**
- * 购买
- */
- BuyButtonClickHandler(): void {
- if (GameModel.single.diamond < this.data.useDiamond) {
- NoticeManager.ShowPrompt("钻石不足!");
- } else {
- GameModel.single.diamond -= this.data.useDiamond;
- GameModel.single.gold+=this.gold;
- let weChat = PlatformManager.impl as WeChatPlatform;
- if (weChat instanceof WeChatPlatform) {
- weChat.branchAnalytics(branchIdType.GoldExchange, String(this.data.useDiamond))
- }
- }
- }
- start() {
- // Your initialization goes here.
- }
- // update (deltaTime: number) {
- // // Your update function goes here.
- // }
- }
|