123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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;
- })
- }
- }
|