import { _decorator, Component, Node, Label, Prefab, instantiate } from 'cc'; import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils'; import { WindowManager } from '../../core/ui/window/WindowManager'; import { WindowOpenMode } from '../../core/ui/window/WindowOpenMode'; import { g } from '../../Data/g'; import { BonusLogItem } from '../../Item/BonusLogItem'; const { ccclass, property } = _decorator; @ccclass('GameBouns') export class GameBouns extends Component { @property({ type: Label, tooltip: "昨日收益" }) yesterdayIncomeLabel: Label; @property({ type: Label, tooltip: "昨日总分红" }) yesterdayBonusLabel: Label; @property({ type: Label, tooltip: "昨日人均分红" }) yesterdayAverageBonusLabel: Label; @property({ type: Label, tooltip: "昨日得财神人数" }) yesterdayCaishenNumLabel: Label; @property({ type: Label, tooltip: "已得财神总人数" }) caishenTotalNumLabel: Label; @property({ type: Node, tooltip: "获得分红财神的日志" }) public bonusLogs: Node; @property({ type: Node, tooltip: "日志的滚动视图" }) public logsScorllView; async start() { let data = g.gameData.gameBonus; this.caishenTotalNumLabel.string = data.bonusTotalUserNum + ""; this.yesterdayCaishenNumLabel.string = data.bonusUserNum + ""; let yesterdayAverageBonus = Math.floor(data.bonus / 100) / 100; this.yesterdayAverageBonusLabel.string = yesterdayAverageBonus + ""; let yesterdayBonus = Math.floor(yesterdayAverageBonus * data.bonusTotalUserNum); this.yesterdayBonusLabel.string = yesterdayBonus + ""; this.yesterdayIncomeLabel.string = yesterdayBonus * 5 + ""; data.logs.sort((a: { name: string, time: string }, b: { name: string, time: string }) => { return a.time > b.time ? 1 : -1; }); for (let i = 0; i < data.logs.length; i++) { let prefabData = await ResourcesUtils.load("Prefabs/Item/BonusLogItem", null, this.node); var itemNode = instantiate(prefabData); itemNode.parent = this.bonusLogs; itemNode.getComponent(BonusLogItem).setData(data.logs[i]); } } /**打开分红玩法说明窗口 */ public openBonusIntroduceWindow() { WindowManager.open("Prefabs/Windows/分红玩法说明", WindowOpenMode.NotCloseAndAdd); } } /** * [1] Class member could be defined like this. * [2] Use `property` decorator if your want the member to be serializable. * [3] Your initialization goes here. * [4] Your update function goes here. * * Learn more about scripting: https://docs.cocos.com/creator/3.0/manual/en/scripting/ * Learn more about CCClass: https://docs.cocos.com/creator/3.0/manual/en/scripting/ccclass.html * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.0/manual/en/scripting/life-cycle-callbacks.html */