GameRoot节点控制和注销修改
This commit is contained in:
parent
3accbc5f3a
commit
d94ea3f4a9
|
|
@ -22,4 +22,6 @@ node_modules/
|
||||||
#//////////////////////////
|
#//////////////////////////
|
||||||
# WebStorm
|
# WebStorm
|
||||||
#//////////////////////////
|
#//////////////////////////
|
||||||
.idea/
|
.idea/
|
||||||
|
assets/ImagePack/!幻想模拟战.NPK
|
||||||
|
assets/ImagePack/!幻想模拟战.NPK.meta
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,37 @@
|
||||||
import { _decorator, Component, Node } from 'cc';
|
import { _decorator, Component, Director, director, Node } from 'cc';
|
||||||
const { ccclass, property } = _decorator;
|
import { SelectNumberNode } from './DialogNode/SelectNumberNode';
|
||||||
|
const { ccclass, property } = _decorator;
|
||||||
@ccclass('DialogRoot')
|
|
||||||
export class DialogRoot extends Component {
|
@ccclass('DialogRoot')
|
||||||
start() {
|
export class DialogRoot extends Component {
|
||||||
|
start() {
|
||||||
}
|
|
||||||
|
}
|
||||||
update(deltaTime: number) {
|
|
||||||
|
update(deltaTime: number) {
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//* 初始化并显示顺序选择node
|
||||||
|
initSelectNumberNode(){
|
||||||
|
const selectNode = new SelectNumberNode();
|
||||||
|
selectNode.name = 'SelectNumberNode';
|
||||||
|
this.node.addChild(selectNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//* 销毁顺序选择node
|
||||||
|
destroySelectNumberNode(){
|
||||||
|
/// 一帧结束之后销毁
|
||||||
|
director.once(Director.EVENT_END_FRAME,()=>{
|
||||||
|
// 销毁
|
||||||
|
this.node.getChildByName('SelectNumberNode').destroy();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "949ead83-9b0e-4202-8007-c50ab2ceeeb5",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ import { BaseButton } from '../../GlobalScript/CommonComponent/BaseButton';
|
||||||
import { AnimationNode } from '../../GlobalScript/Animation/AnimationNode';
|
import { AnimationNode } from '../../GlobalScript/Animation/AnimationNode';
|
||||||
import { UIRoot } from '../UIRoot';
|
import { UIRoot } from '../UIRoot';
|
||||||
import {CloseButtonNode } from '../Common/CloseButtonNode';
|
import {CloseButtonNode } from '../Common/CloseButtonNode';
|
||||||
|
import { GameRootSingleton } from '../GameRootController';
|
||||||
const { ccclass } = _decorator;
|
const { ccclass } = _decorator;
|
||||||
|
|
||||||
/// 开始游戏按钮界面
|
/// 开始游戏按钮界面
|
||||||
|
|
@ -12,18 +13,7 @@ const { ccclass } = _decorator;
|
||||||
export class StartGameUINode extends Node {
|
export class StartGameUINode extends Node {
|
||||||
|
|
||||||
/// 玩法介绍
|
/// 玩法介绍
|
||||||
private _pressenNode: Node;
|
private pressenNode: Node;
|
||||||
|
|
||||||
set pressenNode(node: Node){
|
|
||||||
if (this._pressenNode){
|
|
||||||
this._pressenNode.destroy();
|
|
||||||
this._pressenNode = null;
|
|
||||||
}
|
|
||||||
this._pressenNode = node;
|
|
||||||
}
|
|
||||||
get pressenNode(): Node{
|
|
||||||
return this._pressenNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(){
|
constructor(){
|
||||||
super();
|
super();
|
||||||
|
|
@ -156,7 +146,7 @@ export class StartGameUINode extends Node {
|
||||||
|
|
||||||
/// 开始游戏
|
/// 开始游戏
|
||||||
startOnTouchEnd(event:Event){
|
startOnTouchEnd(event:Event){
|
||||||
const uiroot = this.parent.getComponent( UIRoot );
|
const uiroot = GameRootSingleton.getInstance().UIRoot;
|
||||||
uiroot.initGameUI();
|
uiroot.initGameUI();
|
||||||
|
|
||||||
/// 一帧结束之后销毁
|
/// 一帧结束之后销毁
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ import { DiceButtonNode } from "./UINode/DiceButtonNode";
|
||||||
import { OtherWinNode, otherWinType } from "./UINode/OtherWinNode";
|
import { OtherWinNode, otherWinType } from "./UINode/OtherWinNode";
|
||||||
import { BoardRoot } from "./BoardRoot";
|
import { BoardRoot } from "./BoardRoot";
|
||||||
import { StartGameUINode } from "./StartGameNode/StartGameUINode";
|
import { StartGameUINode } from "./StartGameNode/StartGameUINode";
|
||||||
|
import { SelectNumberNode } from "./DialogNode/SelectNumberNode";
|
||||||
|
import { GameRootSingleton } from "./GameRootController";
|
||||||
const { ccclass } = _decorator;
|
const { ccclass } = _decorator;
|
||||||
|
|
||||||
@ccclass("UIRoot")
|
@ccclass("UIRoot")
|
||||||
|
|
@ -32,14 +34,14 @@ export class UIRoot extends Component {
|
||||||
/// 其他胜利条件
|
/// 其他胜利条件
|
||||||
private otherWinNode: OtherWinNode;
|
private otherWinNode: OtherWinNode;
|
||||||
|
|
||||||
/// 初始化开始游戏界面的UI
|
//* 初始化开始游戏界面的UI
|
||||||
initStartGameUI() {
|
initStartGameUI() {
|
||||||
const startGameUINode = new StartGameUINode();
|
const startGameUINode = new StartGameUINode();
|
||||||
startGameUINode.addComponent(UITransform).setContentSize(1067, 600);
|
startGameUINode.addComponent(UITransform).setContentSize(1067, 600);
|
||||||
this.node.addChild(startGameUINode);
|
this.node.addChild(startGameUINode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 初始化游戏界面UI
|
//* 初始化游戏界面UI
|
||||||
initGameUI() {
|
initGameUI() {
|
||||||
/// 玩家UI
|
/// 玩家UI
|
||||||
this.initGamerUI();
|
this.initGamerUI();
|
||||||
|
|
@ -48,10 +50,10 @@ export class UIRoot extends Component {
|
||||||
/// 等待玩家加载
|
/// 等待玩家加载
|
||||||
this.initAwaitGamerUI();
|
this.initAwaitGamerUI();
|
||||||
/// 其他胜利条件
|
/// 其他胜利条件
|
||||||
this.initOtherNode();
|
this.initOtherWinNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 初始化玩家UI
|
//* 初始化玩家UI
|
||||||
initGamerUI() {
|
initGamerUI() {
|
||||||
this.gamerOne = new GamerNode("玩家一");
|
this.gamerOne = new GamerNode("玩家一");
|
||||||
this.gamerOne.setPosition(0, -540);
|
this.gamerOne.setPosition(0, -540);
|
||||||
|
|
@ -68,7 +70,7 @@ export class UIRoot extends Component {
|
||||||
this.initDiceButton();
|
this.initDiceButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 初始化等待玩家加载UI
|
//* 初始化等待玩家加载UI
|
||||||
initAwaitGamerUI() {
|
initAwaitGamerUI() {
|
||||||
const node = new Node();
|
const node = new Node();
|
||||||
node.setPosition(177.5, -244.5);
|
node.setPosition(177.5, -244.5);
|
||||||
|
|
@ -83,40 +85,43 @@ export class UIRoot extends Component {
|
||||||
|
|
||||||
this.awaitGamerNode = node;
|
this.awaitGamerNode = node;
|
||||||
|
|
||||||
/// 2秒后 结束加载
|
|
||||||
|
|
||||||
|
//todo 自动跳过,接入网络后修改
|
||||||
|
// 1秒后 结束加载
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
/// 这一帧结束之后销毁
|
/// 这一帧结束之后销毁
|
||||||
director.once(Director.EVENT_END_FRAME, () => {
|
director.once(Director.EVENT_END_FRAME, () => {
|
||||||
// 销毁
|
// 销毁
|
||||||
this.awaitGamerNode.destroy();
|
this.awaitGamerNode.destroy();
|
||||||
|
|
||||||
|
// todo 开发时跳过倒计时动画
|
||||||
/// 初始化开始倒计时动画
|
/// 初始化开始倒计时动画
|
||||||
// this.initCountFontAni(5);
|
// this.initCountFontAni(5);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// todo 开发时跳过倒计时动画
|
||||||
this.aniDone();
|
this.aniDone();
|
||||||
}, 2000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 初始化倒计时动画
|
//* 初始化倒计时动画
|
||||||
initCountFontAni(index: number) {
|
initCountFontAni(index: number) {
|
||||||
const ani = new AnimationNode("ani/dnf_quiz_" + index + ".ani", () => {
|
const ani = new AnimationNode('ani/count_font.ani',()=>{
|
||||||
|
/// 这一帧结束之后销毁
|
||||||
director.once(Director.EVENT_END_FRAME, () => {
|
director.once(Director.EVENT_END_FRAME, () => {
|
||||||
|
// 销毁
|
||||||
ani.destroy();
|
ani.destroy();
|
||||||
});
|
});
|
||||||
if (index > 1) {
|
/// 动画结束
|
||||||
this.initCountFontAni(index - 1);
|
|
||||||
} else {
|
|
||||||
/// 动画结束
|
|
||||||
this.aniDone();
|
this.aniDone();
|
||||||
}
|
})
|
||||||
});
|
ani.setPosition(500, -200);
|
||||||
ani.setPosition(420, -180);
|
|
||||||
|
|
||||||
this.node.addChild(ani);
|
this.node.addChild(ani);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 初始化投骰子按钮
|
//* 初始化投骰子按钮
|
||||||
initDiceButton() {
|
initDiceButton() {
|
||||||
this.diceButton = new DiceButtonNode();
|
this.diceButton = new DiceButtonNode();
|
||||||
this.diceButton.setPosition(849, -453);
|
this.diceButton.setPosition(849, -453);
|
||||||
|
|
@ -128,15 +133,15 @@ export class UIRoot extends Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 初始化其他胜利条件
|
//* 初始化其他胜利条件
|
||||||
initOtherNode() {
|
initOtherWinNode() {
|
||||||
this.otherWinNode = new OtherWinNode(otherWinType.longRun);
|
this.otherWinNode = new OtherWinNode(otherWinType.longRun);
|
||||||
this.node.addChild(this.otherWinNode);
|
this.node.addChild(this.otherWinNode);
|
||||||
|
|
||||||
this.otherWinNode.active = false;
|
this.otherWinNode.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 动画结束
|
//* 动画结束 显示选择顺序
|
||||||
aniDone() {
|
aniDone() {
|
||||||
/// 恢复其他胜利按钮的状态
|
/// 恢复其他胜利按钮的状态
|
||||||
this.diceButton.winButtonComponent.ButtonState = BaseButtonState.Normal;
|
this.diceButton.winButtonComponent.ButtonState = BaseButtonState.Normal;
|
||||||
|
|
@ -146,6 +151,15 @@ export class UIRoot extends Component {
|
||||||
/// 显示最底层的地图块
|
/// 显示最底层的地图块
|
||||||
const board = boardNode.getComponent(BoardRoot);
|
const board = boardNode.getComponent(BoardRoot);
|
||||||
board.initMapTile();
|
board.initMapTile();
|
||||||
|
|
||||||
|
//* 1秒后自动关闭胜利条件显示,并显示顺序选择
|
||||||
|
setTimeout(() => {
|
||||||
|
|
||||||
|
//* 显示顺序选择node
|
||||||
|
this.otherWinNode.active = false;
|
||||||
|
|
||||||
|
GameRootSingleton.getInstance().DialogRoot.initSelectNumberNode();
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,6 @@
|
||||||
"width": 1067,
|
"width": 1067,
|
||||||
"height": 600
|
"height": 600
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"custom_joint_texture_layouts": []
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue