1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import { _decorator, Component, director, Label, Node } from 'cc';
- import { EventManager } from '../EventManager';
- 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;
- protected onLoad(): void {
- EventManager.instance.et.on(EventManager.EventType.OpenUIPnael, this.OpenUIPnael, this);
- }
- OpenUIPnael() {
- 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.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() {
- EventManager.instance.et.emit(EventManager.EventType.Add_haert);
- EventManager.instance.et.emit(EventManager.EventType.Set_Add_Score_BOOL, true);
- EventManager.instance.et.emit(EventManager.EventType.Reset_Role);
- this.close()
- }
- close() {
- this.unscheduleAllCallbacks()
- this.node.children.forEach((item: Node) => {
- item.active = false;
- })
- }
- }
|