import { _decorator, Component, director, Label, Node } from 'cc'; import { EventManager } from '../EventManager'; import HTTPS, { NetPost } from '../MyFrame/HTTPS'; import { SDKManager } from '../MyFrame/SDK/SDKManager'; const { ccclass, property } = _decorator; @ccclass('UI') export class UI extends Component { @property(Node) FuhuoNode: Node = null; @property(Node) RestartNode: Node = null; @property(Node) HomeNode: Node = null; @property(Label) ScoreNode: Label = null; protected onLoad(): void { EventManager.instance.et.on(EventManager.EventType.OpenUIPnael, this.OpenUIPnael, this); } OpenUIPnael() { HTTPS.Instance.post(NetPost.UpdateScore, { score: this.ScoreNode.string, }).then((resp) => { console.error('更新分数成功'); console.error(resp); }) this.init() } init() { this.node.children.forEach((item: Node) => { item.active = true; }) this.FuhuoNode.active = true; this.RestartNode.active = false; this.HomeNode.active = false; this.FuhuoNode.getComponentInChildren(Label).string = '3' this.schedule(() => { this.FuhuoNode.getComponentInChildren(Label).string = (parseInt(this.FuhuoNode.getComponentInChildren(Label).string) - 1) + '' }, 1, 3, 0) this.scheduleOnce(() => { this.FuhuoNode.active = false; this.RestartNode.active = true; this.HomeNode.active = true; }, 3) } Restart() { director.loadScene('Game', (err) => { if (err) { console.error(err); return; } console.log('加载场景成功'); }) this.close() } Home() { director.loadScene('loading', (err) => { if (err) { console.error(err); return; } console.log('加载场景成功'); }) this.close() } FuHuo() { SDKManager.getInstance().show_video((data) => { if (data == true) { EventManager.instance.et.emit(EventManager.EventType.Add_haert, 3); EventManager.instance.et.emit(EventManager.EventType.Set_Add_Score_BOOL, true); EventManager.instance.et.emit(EventManager.EventType.Reset_Role); this.close() } else { } }) } close() { this.unscheduleAllCallbacks() this.node.children.forEach((item: Node) => { item.active = false; }) } }