71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
/************************************************************************************
|
|
|
|
* FileName : ResourceBar.ts
|
|
* Description : 大厅顶部货币
|
|
* Version : v1.0.0
|
|
* CreateTime : 2024-10-31 10:11:13
|
|
* Author :
|
|
* Copyright (c) since 2024
|
|
* ==============================================================
|
|
* Method Description:
|
|
*
|
|
* ==============================================================
|
|
************************************************************************************/
|
|
import { _decorator, Component, Node, Label, director } from 'cc';
|
|
import {UserMgr} from "db://assets/module_basic/scripts/UserMgr";
|
|
import {tgxUIAlert} from "db://assets/core_tgx/tgx";
|
|
import { RoomEvent } from '../../module_basic/scripts/GameMgr';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('ResourceBar')
|
|
export class ResourceBar extends Component {
|
|
// 银币
|
|
@property(Label)
|
|
silver : Label = null;
|
|
|
|
// 点券
|
|
@property(Label)
|
|
coin : Label = null;
|
|
|
|
protected onLoad() {
|
|
this._registerListeners();
|
|
this._updateCurrency();
|
|
}
|
|
|
|
public onDestroy() {
|
|
this._unRegisterListeners();
|
|
}
|
|
|
|
private _registerListeners() : void{
|
|
director.on(RoomEvent.ChangeCoin,this._updateCurrency,this);
|
|
}
|
|
|
|
private _unRegisterListeners() : void{
|
|
director.off(RoomEvent.ChangeCoin,this._updateCurrency,this);
|
|
}
|
|
|
|
private _updateCurrency() : void{
|
|
UserMgr.inst.rpc_GetUserInfo(UserMgr.inst.userId).then((data) => {
|
|
if(data && data.diamond){
|
|
this.silver.string = data.diamond.toString();
|
|
}else{
|
|
this.silver.string = "0";
|
|
}
|
|
if(data && data.coin){
|
|
this.coin.string = data.coin.toString();
|
|
}else{
|
|
this.coin.string = "0";
|
|
}
|
|
});
|
|
}
|
|
|
|
// 点击增加晶石
|
|
public clickAddCrystal() : void{
|
|
tgxUIAlert.show("研发团队加班中,敬请期待!");
|
|
}
|
|
|
|
// 点击点券
|
|
public clickAddQuan() : void{
|
|
tgxUIAlert.show("研发团队加班中,敬请期待!");
|
|
}
|
|
} |