58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
|
|
import { _decorator,Component, Node } from 'cc';
|
||
|
|
import { BoardRoot } from './BoardRoot';
|
||
|
|
import { UIRoot } from './UIRoot';
|
||
|
|
import { DialogRoot } from './DialogRoot';
|
||
|
|
const { ccclass, property } = _decorator;
|
||
|
|
|
||
|
|
|
||
|
|
export class GameRootSingleton {
|
||
|
|
private static readonly _instance: GameRootSingleton = new GameRootSingleton();
|
||
|
|
|
||
|
|
private constructor() {}
|
||
|
|
|
||
|
|
public static getInstance(): GameRootSingleton {
|
||
|
|
return GameRootSingleton._instance;
|
||
|
|
}
|
||
|
|
|
||
|
|
boardRootNode:Node;
|
||
|
|
UIRootNode: Node;
|
||
|
|
DialogRootNode: Node;
|
||
|
|
|
||
|
|
boardRoot: BoardRoot;
|
||
|
|
UIRoot: UIRoot;
|
||
|
|
DialogRoot: DialogRoot;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
@ccclass('GameRootController')
|
||
|
|
export class GameRootController extends Component {
|
||
|
|
|
||
|
|
@property(Node) boardRootNode:Node;
|
||
|
|
@property(Node) UIRootNode: Node;
|
||
|
|
@property(Node) DialogRootNode: Node;
|
||
|
|
|
||
|
|
|
||
|
|
start() {
|
||
|
|
|
||
|
|
/// 给三个图层添加 root 根脚本
|
||
|
|
const game = GameRootSingleton.getInstance();
|
||
|
|
game.boardRootNode = this.boardRootNode;
|
||
|
|
game.UIRootNode = this.UIRootNode;
|
||
|
|
game.DialogRootNode = this.DialogRootNode;
|
||
|
|
|
||
|
|
/// 给三个图层添加 root 根脚本
|
||
|
|
game.boardRoot = this.boardRootNode.getComponent(BoardRoot);
|
||
|
|
game.UIRoot = this.UIRootNode.getComponent(UIRoot);
|
||
|
|
game.DialogRoot = this.DialogRootNode.getComponent(DialogRoot);
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
update(deltaTime: number) {
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|