160 lines
4.3 KiB
TypeScript
160 lines
4.3 KiB
TypeScript
import { _decorator, Component, Director, director, Node, UITransform } from 'cc';
|
|
import { StartGameUINode } from './StartGameUINode';
|
|
import { CharacterType, GamerNode } from './GamerNode';
|
|
import { BaseSprite } from '../GlobalScript/CommonComponent/BaseSprite';
|
|
import { NpkImage } from '../Tool/NPKImage';
|
|
import { AnimationNode } from '../GlobalScript/Animation/AnimationNode';
|
|
import { BaseButton, BaseButtonState } from '../GlobalScript/CommonComponent/BaseButton';
|
|
import { DiceButtonNode } from './DiceButtonNode';
|
|
import { OtherWinNode, otherWinType } from './OtherWinNode';
|
|
const { ccclass } = _decorator;
|
|
|
|
@ccclass('UIRoot')
|
|
export class UIRoot extends Component {
|
|
|
|
/// 等待玩家
|
|
private awaitGamerNode: Node;
|
|
/// 玩家一
|
|
private gamerOne: GamerNode;
|
|
/// 玩家二
|
|
private gamerTwo: GamerNode;
|
|
/// 玩家三
|
|
private gamerThree: GamerNode;
|
|
/// 投骰子按钮
|
|
private diceButton: DiceButtonNode;
|
|
/// 其他胜利条件
|
|
private otherWinNode: OtherWinNode;
|
|
|
|
|
|
/// 初始化开始游戏界面的UI
|
|
initStartGameUI(){
|
|
const startGameUINode = new StartGameUINode();
|
|
startGameUINode.addComponent( UITransform).setContentSize(1067,600);
|
|
this.node.addChild(startGameUINode);
|
|
}
|
|
|
|
/// 初始化游戏界面UI
|
|
initGameUI(){
|
|
/// 玩家UI
|
|
this.initGamerUI();
|
|
/// 右下骰子操作按钮
|
|
this.initDiceButton();
|
|
/// 等待玩家加载
|
|
this.initAwaitGamerUI();
|
|
/// 其他胜利条件
|
|
this.initOtherNode();
|
|
}
|
|
|
|
/// 初始化玩家UI
|
|
initGamerUI(){
|
|
this.gamerOne = new GamerNode('玩家一')
|
|
this.gamerOne.setPosition(0,-540);
|
|
this.gamerOne.charchterType = CharacterType.JianHun;
|
|
this.node.addChild( this.gamerOne );
|
|
|
|
this.gamerTwo = new GamerNode('')
|
|
this.gamerTwo.setPosition(877,0);
|
|
this.node.addChild( this.gamerTwo );
|
|
|
|
this.gamerThree = new GamerNode('')
|
|
this.node.addChild( this.gamerThree );
|
|
|
|
this.initDiceButton();
|
|
|
|
}
|
|
|
|
/// 初始化加载UI
|
|
initAwaitGamerUI(){
|
|
const node = new Node();
|
|
node.setPosition(177.5,-244.5);
|
|
this.node.addChild(node);
|
|
|
|
|
|
const spr = node.addComponent( BaseSprite);
|
|
spr.updateSpriteFrame(NpkImage.loading_loop,0);
|
|
|
|
const ani = new AnimationNode('ani/loading_loop01.ani');
|
|
ani.setPosition(350,-110);
|
|
node.addChild( ani );
|
|
|
|
this.awaitGamerNode = node;
|
|
|
|
/// 2秒后 结束加载
|
|
this.scheduleOnce(()=>{
|
|
/// 这一帧结束之后销毁
|
|
director.once(Director.EVENT_END_FRAME,()=>{
|
|
// 销毁
|
|
this.awaitGamerNode.destroy();
|
|
});
|
|
|
|
this.aniDone();
|
|
|
|
/// 初始化开始倒计时
|
|
// this.initCountFontAni(5);
|
|
|
|
},2);
|
|
}
|
|
|
|
/// 初始化倒计时动画
|
|
initCountFontAni(index:number){
|
|
const ani = new AnimationNode('ani/dnf_quiz_' + index +'.ani',()=>{
|
|
director.once(Director.EVENT_END_FRAME,()=>{
|
|
ani.destroy();
|
|
});
|
|
if (index > 1){
|
|
this.initCountFontAni(index-1);
|
|
}else{
|
|
/// 动画结束
|
|
this.aniDone();
|
|
}
|
|
});
|
|
ani.setPosition(420,-180);
|
|
|
|
this.node.addChild( ani );
|
|
}
|
|
|
|
|
|
/// 初始化投骰子按钮
|
|
initDiceButton(){
|
|
this.diceButton = new DiceButtonNode();
|
|
this.diceButton.setPosition(849,-453);
|
|
this.node.addChild(this.diceButton);
|
|
|
|
/// 显示其他胜利条件
|
|
this.diceButton.winButtonBlock = ()=>{
|
|
this.otherWinNode.active = true;
|
|
};
|
|
}
|
|
|
|
/// 初始化其他胜利条件
|
|
initOtherNode(){
|
|
this.otherWinNode = new OtherWinNode(otherWinType.longRun);
|
|
this.node.addChild(this.otherWinNode);
|
|
|
|
this.otherWinNode.active = false;
|
|
}
|
|
|
|
|
|
aniDone(){
|
|
/// 恢复其他胜利按钮的状态
|
|
this.diceButton.winButtonComponent.ButtonState = BaseButtonState.Normal;
|
|
/// 显示其他胜利条件
|
|
this.otherWinNode.active = true;
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
this.node.addComponent( UITransform ).setContentSize(1067,600);
|
|
this.initStartGameUI();
|
|
|
|
}
|
|
|
|
update(deltaTime: number) {
|
|
|
|
}
|
|
}
|
|
|
|
|