import { _decorator, Component, Label, Node, Sprite, SpriteFrame, director } from 'cc'; import {RoomEvent} from "db://assets/module_basic/scripts/GameMgr"; import {UserMgr} from "db://assets/module_basic/scripts/UserMgr"; import {ModuleDef} from "db://assets/scripts/ModuleDef"; import {UIChooseHeadLayer} from "db://assets/module_arean/ui_player_info/UIChooseHeadLayer"; import {tgxUIMgr} from "db://assets/core_tgx/tgx"; const { ccclass, property } = _decorator; @ccclass('UserHead') export class UserHead extends Component { @property(Label) lblUserName: Label; @property(Label) lblUserId: Label; @property(Sprite) headImg: Sprite; @property(Sprite) headFrame: Sprite; @property(Label) lblCoin: Label; start() { director.on(RoomEvent.DanUpdate, this.updateDanImg.bind(this), this); director.on("AreanEvent.UpdateHeadOrFrame", this.updateHeadOrFrame.bind(this), this); UserMgr.inst.setUserIconAndName1(UserMgr.inst.userId, this.headImg,this.headFrame,this.lblUserName, ModuleDef.BASIC); this.lblUserId.string = 'ID:' + UserMgr.inst.userId; this.lblCoin.string = '战币:' + UserMgr.inst.coin; // this.updateDanImg(); } async onHeadImgClicked() { // let info = await UserMgr.inst.rpc_GetUserInfo(UserMgr.inst.userId); // tgxUIMgr.inst.showUI(UIUserInfo, null, null, info); // tgxUIMgr.inst.showUI(UIChooseHeadLayer); } onDestroy(){ director.off(RoomEvent.DanUpdate, this.updateDanImg.bind(this), this); director.off("AreanEvent.UpdateHeadOrFrame", this.updateHeadOrFrame.bind(this), this); } update(deltaTime: number) { } public updateHeadOrFrame() : void{ UserMgr.inst.setUserIconAndName1(UserMgr.inst.userId, this.headImg,this.headFrame,this.lblUserName, ModuleDef.BASIC); } public updateDanImg() { } }