1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import { _decorator, Component, Node, Event } from "cc";
- import BaseUI from "../../scripts/base/BaseUI";
- import { GameDetailLayer } from "../layer/GameDetailLayer";
- import { Tips } from "../../scripts/mgr/Tips";
- import { GameInfo } from "../../scripts/api/UserM";
- import Utils from "../../scripts/utils/Utils";
- import AB from "../../scripts/base/AB";
- import { Sprite } from "cc";
- import ConfigM from "../../scripts/api/ConfigM";
- import { DebugM } from "../../scripts/mgr/DebugM";
- const { ccclass, property } = _decorator;
- @ccclass("PlayGameItem")
- export class PlayGameItem extends BaseUI {
- protected onLoad(): void {
- super.onLoad();
- }
- private data: GameInfo;
- init(item: GameInfo) {
- this.data = item;
- let c = ConfigM.ins.getGame(item.gameId);
- this.setText("lbl_name", c.gameName);
- console.log("item.remainPog", item.remainPog);
- if (item.seasonPog > 0) {
- this.setText(
- "lbl_remain_info",
- Utils.formatNumber(item.remainPog, 2) +
- "/" +
- Utils.formatNumber(item.seasonPog, 0)
- );
- this.setText(
- "lbl_my_reward_pog",
- Utils.formatNumber(item.myRewardPog, 0)
- );
- } else {
- this.setText("lbl_remain_info", "Coming soon");
- this.setText(
- "lbl_my_reward_pog",
- Utils.formatNumber(item.myRewardPog, 0)
- );
- }
- this.setIcon(item.gameId);
- }
- async setIcon(gameId: number) {
- let path = "texture/play/icon_" + gameId;
- let spriteFrame = await AB.ins.loadSpriteFrame(path);
- this.FindAs("icon_game", Sprite).spriteFrame = spriteFrame;
- }
- protected simpleOnBtnClick(name: string): void {
- if (name === "btn_play") {
- if (!DebugM.ins.isOpenPlayGame()) {
- Tips.show("Coming soon");
- return;
- }
- GameDetailLayer.show(this.data.gameId, this.FindNode("icon_game"));
- }
- }
- }
|