[add] first

This commit is contained in:
2023-11-07 09:17:57 +08:00
commit 23924175a2
1102 changed files with 313997 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import { _decorator, Component } from 'cc';
import { UIManager } from '../../framework/uiManager';
import { Constant } from '../../framework/constant';
import { GobeUtil } from '../../core/gobeUtil';
const { ccclass, property } = _decorator;
@ccclass('DownOffPanel')
export class DownOffPanel extends Component {
show(){
}
onCancel(){
GobeUtil.instance.leaveGame();
UIManager.instance.showTransition(Constant.SCENE_NAME.SLECT)
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"83f5cf78-decc-42fa-bfbb-99ef5ca1fb7d","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,121 @@
import { _decorator, Component, Node, LabelComponent, SpriteFrame, SpriteComponent} from 'cc';
import { GameState, Player } from '../../core/gameState';
import { GobeUtil, ROOM_TYPE } from '../../core/gobeUtil';
import {Util} from '../../framework/util';
import { Constant } from '../../framework/constant';
import { ClientEvent } from '../../framework/clientEvent';
import { ResourceUtil } from '../../framework/resourceUtil';
import { DisplayManager } from '../../core/displayManager';
const { ccclass, property } = _decorator;
/**
* Predefined variables
* Name = FightUI2
* DateTime = Mon Sep 06 2021 15:55:45 GMT+0800 (中国标准时间)
* Author = yanli.huang
* FileBasename = fightUI2.ts
* FileBasenameNoExtension = fightUI2
* URL = db://assets/script/ui/fight/fightUI2.ts
* ManualUrl = https://docs.cocos.com/creator/3.3/manual/zh/
*
*/
const MODEL_BOY: number = 0;//蓝色房主
const MODEL_GIRL: number = 1;
@ccclass('FightUI')
export class FightUI extends Component {
@property([LabelComponent])
public aryPlayerDelay: LabelComponent[] = [];
@property([LabelComponent])
public aryPlayerScore: LabelComponent[] = [];
@property([Node])
public aryPlayerNode: Node[] = [];
@property([SpriteComponent])
public aryPlayerHead: SpriteComponent[] = [];
@property([SpriteFrame])
public aryHead: SpriteFrame[] = [];
@property(LabelComponent)
public lbCountDown: LabelComponent = null!;
@property([Node])
public ringNode: Node[] = [];
private _parent: DisplayManager = null!;
show(parent: DisplayManager) {
this.lbCountDown.string = Util.formatTimeForSecond(60, true);
this._parent = parent;
let gameState: GameState = this._parent.logicManager.currentGameState;
let players: Array<Player> = gameState.players;
for (let idx = 0; idx < players.length; idx++) {
let player: Player = players[idx];
if (!player.channel) {
this.aryPlayerNode[idx].active = false;
} else {
this.aryPlayerNode[idx].active = true;
let i = MODEL_BOY;
if (!GobeUtil.instance.checkIsRoomOwner(player.channel.openId)) {
i = MODEL_GIRL;
}
if (player.channel.headUrl && player.channel.headUrl.length) {
ResourceUtil.loadSpriteFrameURL(player.channel.headUrl, this.aryPlayerHead[i]);
} else {
this.aryPlayerHead[i].spriteFrame = this.aryHead[i];
}
}
}
var isRoomOwner:boolean = GobeUtil.instance.checkIsRoomOwner(GobeUtil.instance.ownPlayerId);
this.ringNode[0].active = isRoomOwner;
this.ringNode[1].active = !isRoomOwner;
ClientEvent.dispatchEvent(Constant.EVENT_NAME.GAME_INIT);
}
private _updatePlayerState() {
if (GobeUtil.instance.room
&& GobeUtil.instance.roomType != ROOM_TYPE.START) {
return;
}
let gameState: GameState = this._parent.logicManager.currentGameState;
let players: Array<Player> = gameState.players;
for (let idx = 0; idx < players.length; idx++) {
let player: Player = players[idx];
if (player.channel) {
let i = MODEL_BOY;
if (!GobeUtil.instance.checkIsRoomOwner(player.channel.openId)) {
i = MODEL_GIRL;
}
this.aryPlayerScore[i].string = `${player.score}`;
// this.aryPlayerDelay[i].string = `${player.channel.delayTime}ms`;
}
}
let curTime = gameState.time > 0 ? gameState.time : 0;
if(curTime > Constant.GAME_TIME){
curTime = Constant.GAME_TIME;
}
this.lbCountDown.string = Util.formatTimeForSecond(curTime, true);
}
lateUpdate (deltaTime: number) {
this._updatePlayerState();
}
}
/**
* [1] Class member could be defined like this.
* [2] Use `property` decorator if your want the member to be serializable.
* [3] Your initialization goes here.
* [4] Your update function goes here.
*
* Learn more about scripting: https://docs.cocos.com/creator/3.3/manual/zh/scripting/
* Learn more about CCClass: https://docs.cocos.com/creator/3.3/manual/zh/scripting/ccclass.html
* Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.3/manual/zh/scripting/life-cycle-callbacks.html
*/

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "65e1e7b6-dc46-4def-8d19-0198b4d4215a",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,224 @@
import { _decorator, Component, Node, LabelComponent, SpriteComponent, SpriteFrame, Prefab, AnimationComponent, AnimationClip, Animation, sys } from 'cc';
import { DisplayManager } from '../../core/displayManager';
import { FighterModel } from '../../core/fighterModel';
import { UIManager } from '../../framework/uiManager';
import { AudioManager } from '../../framework/audioManager';
import { Constant } from '../../framework/constant';
import { Player } from '../../core/gameState';
import { ResourceUtil } from '../../framework/resourceUtil';
import { PoolManager } from '../../framework/poolManager';
import { GobeUtil, WIFI_TYPE } from '../../core/gobeUtil';
const { ccclass, property } = _decorator;
/**
* Predefined variables
* Name = GameOver2
* DateTime = Wed Sep 08 2021 19:12:52 GMT+0800 (中国标准时间)
* Author = yanli.huang
* FileBasename = gameOver2.ts
* FileBasenameNoExtension = gameOver2
* URL = db://assets/script/ui/fight/gameOver2.ts
* ManualUrl = https://docs.cocos.com/creator/3.3/manual/zh/
*
*/
const MODEL_BOY: number = 0;
const MODEL_GIRL: number = 1;
@ccclass('gameOver')
export class GameOver extends Component {
@property([Node])
aryNodeWin: Node[] = [];
@property([LabelComponent])
aryLbScore: LabelComponent[] = [];
@property([LabelComponent])
aryLbName: LabelComponent[] = [];
@property([SpriteComponent])
arySpIcon: SpriteComponent[] = [];
@property([SpriteFrame])
aryHead: SpriteFrame[] = [];
@property(Node)
leftNode: Node = null!;
@property(Node)
rightNode: Node = null!;
@property(Animation)
winAni: Animation = null!;
@property(Node)
btnAgc: Node = null!;
private _parent: DisplayManager = null!;
private _girlNode: Node | null = null;
private _boyNode: Node | null = null;
onDisable () {
this._cleanModel();
this.winAni.stop();
this.winAni.node.active = false;
UIManager.instance.hideDialog(Constant.PANEL_NAME.FIGHT_UI);
}
public show (parent: DisplayManager, winner: number) {
this.winAni.stop();
this.winAni.node.active = false;
this._parent = parent;
let players: Player[] = parent.logicManager.currentGameState.players;
if(players.length < 2){
return;
}
AudioManager.instance.stop(Constant.AUDIO_NAME.BACKGROUND);
AudioManager.instance.playSound(Constant.AUDIO_NAME.WIN);
for (let pos in players) {
let player: Player = players[pos];
if (player.channel) {
let i = MODEL_BOY;
if (!GobeUtil.instance.checkIsRoomOwner(player.channel.openId)) {
i = MODEL_GIRL;
}
if (parseInt(pos) === winner) {
this.winAni.node.setPosition(this.aryNodeWin[i].position);
this.winAni.node.active = true;
let aniStateIn = this.winAni.getState("leaveWinAniIn");
if (aniStateIn) {
aniStateIn.time = 0;
aniStateIn.sample();
this.winAni.play("leaveWinAniIn");
aniStateIn.wrapMode = AnimationClip.WrapMode.Normal;
}
this.winAni.once(AnimationComponent.EventType.FINISHED, ()=>{
let aniStateIdle = this.winAni.getState("leaveWinAniIdle");
if (aniStateIdle) {
aniStateIdle.time = 0;
aniStateIdle.sample();
this.winAni.play("leaveWinAniIdle");
aniStateIdle.wrapMode = AnimationClip.WrapMode.Loop;
}
})
}
this._showModel(i, winner == -1 ? true : parseInt(pos) === winner);
this.aryLbScore[i].string = player.score + '';
this.aryLbName[i].string = player.channel.name;
if (player.channel.headUrl && player.channel.headUrl.length) {
ResourceUtil.loadSpriteFrameURL(player.channel.headUrl, this.arySpIcon[i]);
} else {
this.arySpIcon[i].spriteFrame = this.aryHead[i];
}
}
}
GobeUtil.instance.leaveRoom();
// 开启内置社区
this.btnAgc.active = GobeUtil.instance.isOpenPgs && GobeUtil.instance.isHwLogin;
}
/**
* 重新开始
*/
onAgainBtnClick() {
UIManager.instance.showDialog(Constant.PANEL_NAME.MATCH_PANEL, [], ()=>{}, true);
if(GobeUtil.instance.wifiType == WIFI_TYPE.WIFI){
GobeUtil.instance.matchRoom(()=>{
UIManager.instance.hideDialog(Constant.PANEL_NAME.MATCH_PANEL);
UIManager.instance.hideDialog(Constant.PANEL_NAME.GAME_OVER);
UIManager.instance.showDialog(Constant.PANEL_NAME.READY, [true]);
this._parent.reset();
}, ()=>{
UIManager.instance.showTips(Constant.ROOM_TIPS.MATCH_ROOM_ERROR);
UIManager.instance.hideDialog(Constant.PANEL_NAME.MATCH_PANEL);
});
}else{
GobeUtil.instance.createRoomAI(()=>{
UIManager.instance.hideDialog(Constant.PANEL_NAME.MATCH_PANEL);
UIManager.instance.hideDialog(Constant.PANEL_NAME.GAME_OVER);
UIManager.instance.showDialog(Constant.PANEL_NAME.READY, [true]);
this._parent.reset();
}, ()=>{
UIManager.instance.showTips(Constant.ROOM_TIPS.MATCH_ROOM_ERROR);
UIManager.instance.hideDialog(Constant.PANEL_NAME.MATCH_PANEL);
})
}
}
/**
* 离开场景
*/
onClickLeave(){
if(!GobeUtil.instance.isChangeWifiType){
UIManager.instance.showDialog(Constant.PANEL_NAME.TIP_PANEL, [Constant.ROOM_TIPS.LEAVE_GAME, ()=>{
GobeUtil.instance.leaveGame();
UIManager.instance.hideDialog(Constant.PANEL_NAME.GAME_OVER);
UIManager.instance.showTransition(Constant.SCENE_NAME.SLECT);
}],()=>{},true);
}else{
this._parent.reset();
UIManager.instance.showTips(Constant.ROOM_TIPS.LEAVE_ROOM_SUCCESS);
UIManager.instance.hideDialog(Constant.PANEL_NAME.GAME_OVER);
UIManager.instance.showTransition(Constant.SCENE_NAME.SLECT);
}
}
onClickAgc(){
GobeUtil.instance.forumPagePublish();
GobeUtil.instance.leaveRoom();
}
private _showModel (idx: number, isWin: boolean) {
let prefabName: string = Constant.READY_PREFAB.BOY_MODEL;
let parent: Node = this.leftNode;
if (idx === MODEL_GIRL) {
parent = this.rightNode;
prefabName = Constant.READY_PREFAB.GIRL_MODEL;
}
if ((idx === MODEL_GIRL? this._girlNode : this._boyNode) === null) {
ResourceUtil.getUIPrefabRes(prefabName, (err: {}, prefab: Prefab) =>{
if ((idx === MODEL_GIRL? this._girlNode : this._boyNode) === null) {
let node: Node = PoolManager.instance.getNode(prefab, parent);
let fighterModel: FighterModel = node.getComponent(FighterModel) as FighterModel;
if (isWin) {
fighterModel.playAni(Constant.ANI_TYPE.VICTORY, true, false, ()=>{}, 13);
} else {
fighterModel.playAni(Constant.ANI_TYPE.LOSE, false, false, ()=>{
fighterModel.playAni(Constant.ANI_TYPE.LOSE_1, true, false, ()=>{}, 15);
}, 14);
}
if (idx === MODEL_GIRL) {
this._girlNode = node;
} else {
this._boyNode = node;
}
}
});
}
}
private _cleanModel () {
PoolManager.instance.putNode(this._girlNode as Node);
this._girlNode = null;
PoolManager.instance.putNode(this._boyNode as Node);
this._boyNode = null!;
}
}
/**
* [1] Class member could be defined like this.
* [2] Use `property` decorator if your want the member to be serializable.
* [3] Your initialization goes here.
* [4] Your update function goes here.
*
* Learn more about scripting: https://docs.cocos.com/creator/3.3/manual/zh/scripting/
* Learn more about CCClass: https://docs.cocos.com/creator/3.3/manual/zh/scripting/ccclass.html
* Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.3/manual/zh/scripting/life-cycle-callbacks.html
*/

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "7da34920-bf2e-4647-bda1-7254ca048096",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,47 @@
import { _decorator, Component, EditBox } from 'cc';
import { GobeUtil } from '../../core/gobeUtil';
import { UIManager } from '../../framework/uiManager';
import { Constant } from '../../framework/constant';
const { ccclass, property } = _decorator;
@ccclass('JoinRoomPanel')
export class JoinRoomPanel extends Component {
@property(EditBox)
editBox:EditBox = null!;
private _callback:Function = null!;
show(callback:Function){
this.editBox.string = "";
this._callback = callback;
}
onJoinRoom(){
if(this.editBox.string == ""){
UIManager.instance.showTips(Constant.ROOM_TIPS.NO_ROOM_ID);
return;
}
GobeUtil.instance.joinRoom(
this.editBox.string,
()=>{
UIManager.instance.showDialog(Constant.PANEL_NAME.READY);
UIManager.instance.showTips(Constant.ROOM_TIPS.JOIN_ROOM_SUCCESS);
UIManager.instance.hideDialog(Constant.PANEL_NAME.JOIN_ROOM_PANEL);
this._callback && this._callback();
}, (error:any)=>{
UIManager.instance.showTips(Constant.ROOM_TIPS.NO_ROOM_ID);
}
);
}
onClose(){
UIManager.instance.hideDialog(Constant.PANEL_NAME.JOIN_ROOM_PANEL);
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"4c16c5ba-22e0-4464-9371-a28da4ebcf8d","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,22 @@
import { _decorator, Component, Label } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('MatchPanel')
export class MatchPanel extends Component {
@property(Label)
txtTip: Label = null!;
private _matchTime:number = 0;
show(){
this._matchTime = 0;
}
protected update(dt: number): void {
this._matchTime += dt;
this.txtTip.string = "当前等待时长为" + Math.floor(this._matchTime) + "秒"
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"580ef00b-12b3-4ef6-90fd-b8614b8fd5cb","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,164 @@
import { _decorator, Component, Node} from 'cc';
import { GobeUtil } from '../../core/gobeUtil';
import { Constant } from '../../framework/constant';
import { ClientEvent } from '../../framework/clientEvent';
import { UIManager } from '../../framework/uiManager';
const { ccclass, property } = _decorator;
@ccclass('MediaPanel')
export class MediaPanel extends Component {
@property(Node)
public mediaOpen:Node = null!;
@property(Node)
public mediaClose:Node = null!;
@property(Node)
public micClose:Node = null!;
@property(Node)
public micOpen:Node = null!;
@property(Node)
public noMessageOpen:Node = null!;
@property(Node)
public messageClose:Node = null!;
@property(Node)
public messageOpen:Node = null!;
private _isOpenMessage:boolean = false; // message界面开启
private _isFirstOpenM:boolean = true; // 是否第一次开启
onEnable(): void {
ClientEvent.on(Constant.EVENT_NAME.SEND_MSG, this._onSendMsg, this);
ClientEvent.on(Constant.EVENT_NAME.OPEN_MEDIA, this._openMedia, this);
ClientEvent.on(Constant.EVENT_NAME.OPEN_CHANNEL, this._openChannel, this);
}
onDisable(): void {
ClientEvent.off(Constant.EVENT_NAME.SEND_MSG, this._onSendMsg, this);
ClientEvent.off(Constant.EVENT_NAME.OPEN_MEDIA, this._openMedia, this);
ClientEvent.off(Constant.EVENT_NAME.OPEN_CHANNEL, this._openChannel, this);
}
private _openMedia(){
if(GobeUtil.instance.isOpenMedia){
this.mediaClose.active = true;
this.mediaOpen.active = false;
this.micClose.active = true;
this.micOpen.active = false;
}else{
this.mediaClose.active = false;
this.mediaOpen.active = false;
this.micClose.active = false;
this.micOpen.active = false;
}
}
private _openChannel(){
if(GobeUtil.instance.isChannelId){
this.noMessageOpen.active = true;
this.messageClose.active = false;
this.messageOpen.active = false;
}
else{
this.noMessageOpen.active = false;
this.messageClose.active = false;
this.messageOpen.active = false;
}
}
show() {
this._isFirstOpenM = true;
this.mediaClose.active = false;
this.mediaOpen.active = false;
this.micClose.active = false;
this.micOpen.active = false;
this.noMessageOpen.active = false;
this.messageClose.active = false;
this.messageOpen.active = false;
}
/**
* 打开语音
*/
public onClickOpenMedia(){
GobeUtil.instance.mediaMuteAllPlayers(true);
this.mediaClose.active = false;
this.mediaOpen.active = true;
}
/**
* 关闭语音
*/
public onClickCloseMedia(){
GobeUtil.instance.mediaMuteAllPlayers(false);
this.mediaClose.active = true;
this.mediaOpen.active = false;
}
/**
* 开启四周音
*/
public onOpenMic(){
GobeUtil.instance.mediaEnableMic(true);
this.micClose.active = false;
this.micOpen.active = true;
}
/**
* 关闭四周音
*/
public onCloseMic(){
GobeUtil.instance.mediaEnableMic(false);
this.micClose.active = true;
this.micOpen.active = false;
}
public onOpenMessage(){
this._isOpenMessage = true;
UIManager.instance.showDialog(Constant.PANEL_NAME.MESSAGE_PANEL, [this._isFirstOpenM]);
this.messageClose.active = true;
this.noMessageOpen.active = false;
this.messageOpen.active = false;
this._isFirstOpenM = false;
}
public onCloseMessage(){
this._isOpenMessage = false;
UIManager.instance.hideDialog(Constant.PANEL_NAME.MESSAGE_PANEL);
this.messageClose.active = false;
this.noMessageOpen.active = true;
this.messageOpen.active = false;
}
private _onSendMsg(msg:string){
if(msg != "" && !this._isOpenMessage){
this.noMessageOpen.active = false;
this.messageOpen.active = true;
}
}
}
/**
* [1] Class member could be defined like this.
* [2] Use `property` decorator if your want the member to be serializable.
* [3] Your initialization goes here.
* [4] Your update function goes here.
*
* Learn more about scripting: https://docs.cocos.com/creator/3.3/manual/zh/scripting/
* Learn more about CCClass: https://docs.cocos.com/creator/3.3/manual/zh/scripting/ccclass.html
* Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.3/manual/zh/scripting/life-cycle-callbacks.html
*/

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"5cde5ed2-e0f8-4872-834b-5847b3cf7232","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,81 @@
import { _decorator, Component, Label, Node, UITransform } from 'cc';
import { GobeUtil } from '../../core/gobeUtil';
import { ClientEvent } from '../../framework/clientEvent';
import { Constant } from '../../framework/constant';
const { ccclass, property } = _decorator;
@ccclass('MessageItem')
export class MessageItem extends Component {
@property(Node)
headBoy: Node = null!;
@property(Node)
headGirl: Node = null!;
@property(UITransform)
messageUITF:UITransform = null!;
@property(Node)
msgTxtNode:Node = null!;
@property(Label)
nameTxt:Label = null!;
// @property(UITransform)
msgTxtUITF:UITransform = null!;
// @property(Label)
msgTxt:Label = null!;
public show(msg:object){
if(this.msgTxtUITF == null){
this.msgTxtUITF = this.msgTxtNode.getComponent(UITransform);
}
if(this.msgTxt == null){
this.msgTxt = this.msgTxtNode.getComponent(Label);
}
this.nameTxt.string = msg["sendId"];
if(msg["isOwn"]){
if(GobeUtil.instance.room == null){
this.headBoy.active = false;
this.headGirl.active = true;
}
else if( GobeUtil.instance.checkIsRoomOwner(GobeUtil.instance.ownPlayerId)){
this.headBoy.active = true;
this.headGirl.active = false;
}else{
this.headBoy.active = false;
this.headGirl.active = true;
}
}else{
if(GobeUtil.instance.room == null){
this.headBoy.active = true;
this.headGirl.active = false;
}
else if(GobeUtil.instance.checkIsRoomOwner(GobeUtil.instance.ownPlayerId)){
this.headBoy.active = false;
this.headGirl.active = true;
}else{
this.headBoy.active = true;
this.headGirl.active = false;
}
}
this.msgTxt.string = msg["content"];
setTimeout(()=>{
var height:number = this.msgTxtUITF.contentSize.height;
this.messageUITF.setContentSize(291, height + 10);
if(height < 60){
height = 60;
}
ClientEvent.dispatchEvent(Constant.EVENT_NAME.SEND_MSG_HEIGHT, height + 50);
}, 100);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "0a4ba360-91b5-48bf-a783-66863300129a",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,258 @@
import { _decorator, Component, EditBox, Label, Node, Prefab, ProgressBar, ScrollView, UITransform } from 'cc';
import { UIManager } from '../../framework/uiManager';
import { Constant } from '../../framework/constant';
import { GobeUtil } from '../../core/gobeUtil';
import { ClientEvent } from '../../framework/clientEvent';
import { PoolManager } from '../../framework/poolManager';
import { MessageItem } from './message_item';
const { ccclass, property } = _decorator;
@ccclass('MessagePanel')
export class MessagePanel extends Component {
@property(Node)
content: Node = null!;
@property(Prefab)
leftPrefab:Prefab = null!;
@property(Prefab)
rightPrefab:Prefab = null!;
@property(Node)
startNode:Node = null!;
@property(Node)
inputNode:Node = null!;
@property(EditBox)
editBox:EditBox = null!;
private _currY:number = -45;
@property(Node)
voiceInputNode:Node = null!;
@property(Node)
voiceNode:Node = null!;
@property(ProgressBar)
bar:ProgressBar = null!;
@property(Label)
barTxt:Label = null!;
@property(Label)
inputTxt:Label = null!;
@property(UITransform)
inputSpUIF:UITransform = null!;
@property(UITransform)
inputTxtUIF:UITransform = null!;
@property(ScrollView)
scrollView:ScrollView = null!;
@property(Label)
labelTxt:Label = null!;
// 上一条显示完全
private _isMsgShow:boolean = false;
show(isClear:boolean){
this.startNode.active = true;
this.inputNode.active = false;
this.voiceInputNode.active = false;
this.voiceNode.active = false;
if(GobeUtil.instance.room == null
|| GobeUtil.instance.room.players.length < 2){
this.labelTxt.string = Constant.ROOM_TIPS.WORLD_LABEL;
}else{
this.labelTxt.string = Constant.ROOM_TIPS.ROOM_LABEL + GobeUtil.instance.room.roomCode;
}
if(isClear){
this._clearItem();
this._currY = -45;
}
this._onSendMsg();
}
protected onEnable(): void {
ClientEvent.on(Constant.EVENT_NAME.SEND_MSG, this._onSendMsg, this);
ClientEvent.on(Constant.EVENT_NAME.SEND_MSG_HEIGHT, this._onSendMsgHeight, this);
ClientEvent.on(Constant.EVENT_NAME.SEND_VT, this._onSendVT, this);
}
protected onDisable(): void {
ClientEvent.off(Constant.EVENT_NAME.SEND_MSG, this._onSendMsg, this);
ClientEvent.off(Constant.EVENT_NAME.SEND_MSG_HEIGHT, this._onSendMsgHeight, this);
ClientEvent.off(Constant.EVENT_NAME.SEND_VT, this._onSendVT, this);
}
public onControlIM(){
this.startNode.active = true;
this.inputNode.active = false;
this.voiceInputNode.active = false;
this.editBox.string = "";
}
public onStartIM(){
this.startNode.active = false;
this.inputNode.active = true;
}
public onClickInput(){
if(this.editBox.string == ""){
UIManager.instance.showTips(Constant.ROOM_TIPS.INPUT_MSG);
return;
}
GobeUtil.instance.sendTextMsg(this.editBox.string);
this.editBox.string = "";
this.voiceNode.active = false;
this.voiceInputNode.active = false;
this.inputNode.active = false;
this.startNode.active = true;
}
public onClickVInput(){
if(this.inputTxt.string == ""){
UIManager.instance.showTips(Constant.ROOM_TIPS.INPUT_MSG);
return;
}
GobeUtil.instance.sendTextMsg(this.inputTxt.string);
this.inputTxt.string = "";
this.voiceNode.active = false;
this.voiceInputNode.active = false;
this.inputNode.active = false;
this.startNode.active = true;
}
/**
* 显示msg
*/
private _onSendMsg(){
if(this._isMsgShow){
return
}
if(GobeUtil.instance.msgLst.length > 0){
this._isMsgShow = true;
var msg:object = GobeUtil.instance.msgLst[0];
if(msg["isOwn"]){
var rightN:Node = PoolManager.instance.getNode(this.rightPrefab, this.content);
rightN.setPosition(45, this._currY, 0);
rightN.getComponent(MessageItem).show(msg);
}else{
var rightN:Node = PoolManager.instance.getNode(this.leftPrefab, this.content);
rightN.setPosition(45, this._currY, 0);
rightN.getComponent(MessageItem).show(msg);
}
GobeUtil.instance.msgLst.splice(0, 1);
}
}
/**
* 更新height
* @param height
*/
private _onSendMsgHeight(height:number){
this._isMsgShow = false;
this._currY -= height - 10;
this.content.getComponent(UITransform)?.setContentSize(424, this._currY * -1);
if(this._currY < -570){
this.scrollView.scrollToBottom();
}
this._onSendMsg();
}
protected update(dt: number): void {
if(this._isRecording){
this._recordTime += dt;
this.bar.progress = this._recordTime * 0.2;
this.barTxt.string = this._recordTime.toFixed(2) + "秒";
if(this._recordTime >= 5){
this.onStopVoice();
}
}
}
private _onSendVT(msg:string){
if(msg == ""){
UIManager.instance.showTips(Constant.ROOM_TIPS.VT_ERROR);
this.voiceNode.active = false;
this.voiceInputNode.active = false;
this.inputNode.active = false;
this.startNode.active = true;
this._isEffectRecording = false;
return;
}
if(this._isEffectRecording){
this.voiceNode.active = false;
this.voiceInputNode.active = true;
this.inputTxt.string = msg;
setTimeout(()=>{
this.inputSpUIF.setContentSize(314, this.inputTxtUIF.contentSize.height + 7);
});
}
this._isEffectRecording = false;
}
private _isRecording:boolean = false;
private _isEffectRecording = false;
private _recordTime:number = 0;
public onClickStartVoice(){
this.voiceNode.active = true;
this.startNode.active = false;
GobeUtil.instance.startRecordAudioToText();
this._isRecording = true;
this._isEffectRecording = true;
this._recordTime = 0;
}
public onCancelVoice(){
GobeUtil.instance.stopRecordAudioToText();
this.voiceNode.active = false;
this.voiceInputNode.active = false;
this.startNode.active = true;
this._isRecording = false;
this._isEffectRecording = false;
}
public onStopVoice(){
GobeUtil.instance.stopRecordAudioToText();
this._isRecording = false;
}
private _clearItem(){
var count:number = this.content.children.length;
for(var index:number = count - 1; index > -1; index --){
PoolManager.instance.putNode(this.content.children[index]);
}
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"6c443359-2382-4c41-a90c-0c535f26bdfc","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,26 @@
import { _decorator, Component, AnimationComponent} from "cc";
import { AudioManager } from "../../framework/audioManager";
import { Constant } from "../../framework/constant";
const { ccclass, property } = _decorator;
@ccclass("readyGo")
export class readyGo extends Component {
@property(AnimationComponent)
ani: AnimationComponent = null!;
show (callback: Function) {
this.ani.play();
this.ani.once(AnimationComponent.EventType.FINISHED, ()=>{
callback && callback();
});
}
tick () {
AudioManager.instance.playSound(Constant.AUDIO_NAME.TICK);
}
go () {
AudioManager.instance.playSound(Constant.AUDIO_NAME.GO);
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "041fedc3-6584-4e8d-847b-40c0b81e9e5d",
"files": [],
"subMetas": {},
"userData": {
"moduleId": "project:///assets/script/ui/fight/readyGo.js",
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,156 @@
import { _decorator, Component, JsonAsset, Label, randomRange, Node } from 'cc';
import { GobeUtil, WIFI_TYPE } from '../../core/gobeUtil';
import { UIManager } from '../../framework/uiManager';
import { Constant } from '../../framework/constant';
import { PlayerData } from '../../framework/playerData';
import { ClientEvent } from '../../framework/clientEvent';
import { ResourceUtil } from '../../framework/resourceUtil';
import { Util } from '../../framework/util';
const { ccclass, property } = _decorator;
@ccclass('SelectPanel')
export class SelectPanel extends Component {
@property(Label)
txtName:Label = null!;
@property(Label)
txtCoin:Label = null!;
@property(Node)
btnStrategy:Node = null!;
@property(Node)
btnCommunity:Node = null!;
@property(Node)
btnShare:Node = null!;
show(){
if(PlayerData.instance.playerInfo["playerName"] == ""){
var staticId = PlayerData.instance.playerInfo["playerName"];
// 随机名字
Util.randomName(staticId).then((playerName:string)=>{
this.txtName.string = playerName;
PlayerData.instance.updatePlayerInfo("playerName", playerName);
})
}else{
this.txtName.string = PlayerData.instance.playerInfo["playerName"];
}
UIManager.instance.showDialog(Constant.PANEL_NAME.MEDIA_PANEL);
if(!PlayerData.instance.isInit){
PlayerData.instance.isInit = true;
GobeUtil.instance.startMedia(GobeUtil.instance.openId);
GobeUtil.instance.startForumPage();
}else{
GobeUtil.instance.joinTeamRoom(Constant.WORLD_ID);
GobeUtil.instance.joinGroupChannel(Constant.WORLD_ID);
}
// 开启 分享
this._onOpenPgs();
}
protected onEnable(): void {
ClientEvent.on(Constant.EVENT_NAME.INIT_MEDIA, this._onInitMedia, this);
ClientEvent.on(Constant.EVENT_NAME.INIT_CHANNEL, this._onSendChannel, this);
ClientEvent.on(Constant.EVENT_NAME.OPEN_PGS, this._onOpenPgs, this);
}
protected onDisable(): void {
ClientEvent.off(Constant.EVENT_NAME.INIT_MEDIA, this._onInitMedia, this);
ClientEvent.off(Constant.EVENT_NAME.INIT_CHANNEL, this._onSendChannel, this);
ClientEvent.off(Constant.EVENT_NAME.OPEN_PGS, this._onOpenPgs, this);
UIManager.instance.hideDialog(Constant.PANEL_NAME.MEDIA_PANEL);
}
/**
* 开启分享
*/
private _onOpenPgs(){
this.btnCommunity.active = GobeUtil.instance.isOpenPgs;
this.btnStrategy.active = GobeUtil.instance.isOpenPgs && GobeUtil.instance.isHwLogin;
this.btnShare.active = GobeUtil.instance.isOpenPgs && GobeUtil.instance.isHwLogin;
}
private _onInitMedia(){
GobeUtil.instance.joinTeamRoom(Constant.WORLD_ID);
}
private _onSendChannel(){
GobeUtil.instance.joinGroupChannel(Constant.WORLD_ID);
}
public onOpenForumPage(){
GobeUtil.instance.openForumPage();
}
public onForumPageCheckScene(){
GobeUtil.instance.forumPageCheckScene();
}
public onForumPagePublish(){
GobeUtil.instance.forumPagePublish();
}
/**
* 人机模式
*/
onCreateRoomAi(){
GobeUtil.instance.createRoomAI(()=>{
UIManager.instance.showDialog(Constant.PANEL_NAME.READY);
},()=>{
UIManager.instance.showTips(Constant.ROOM_TIPS.CREATE_ROOM_ERROR);
});
}
/**
* 创建room
*/
onCreateRoom(){
GobeUtil.instance.createRoom(()=>{
UIManager.instance.showDialog(Constant.PANEL_NAME.READY);
},()=>{
UIManager.instance.showTips(Constant.ROOM_TIPS.CREATE_ROOM_ERROR);
});
}
/**
* 加入room
*/
onJoinRoom(){
UIManager.instance.showDialog(Constant.PANEL_NAME.JOIN_ROOM_PANEL,[()=>{
// UIManager.instance.hideDialog(Constant.PANEL_NAME.SELECT_GAME);
}]);
}
/**
* 随机匹配
*/
onMatchRoom(){
UIManager.instance.showDialog(Constant.PANEL_NAME.MATCH_PANEL);
GobeUtil.instance.matchRoom(()=>{
UIManager.instance.showDialog(Constant.PANEL_NAME.READY);
UIManager.instance.showTips(Constant.ROOM_TIPS.JOIN_ROOM_SUCCESS);
UIManager.instance.hideDialog(Constant.PANEL_NAME.MATCH_PANEL);
},()=>{
// UIManager.instance.showTips(Constant.ROOM_TIPS.MATCH_ROOM_ERROR);
// UIManager.instance.hideDialog(Constant.PANEL_NAME.MATCH_PANEL);
});
}
/**
* 退出账号
*/
onLeaveClient(){
UIManager.instance.showDialog(Constant.PANEL_NAME.TIP_PANEL, [Constant.ROOM_TIPS.LEAVE_GAME, ()=>{
GobeUtil.instance.leaveGame();
UIManager.instance.hideDialog(Constant.PANEL_NAME.SELECT_GAME);
UIManager.instance.showDialog(Constant.PANEL_NAME.START_GAME);
}]);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "fc853374-496a-482b-9248-79fdb6694f89",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,142 @@
import { _decorator, Node, Component, Animation, sp, sys, log} from 'cc';
import { UIManager } from '../../framework/uiManager';
import { Constant } from '../../framework/constant';
import { GobeUtil, WIFI_TYPE } from '../../core/gobeUtil';
import { PlayerData } from '../../framework/playerData';
import { Util } from '../../framework/util';
import { ClientEvent } from '../../framework/clientEvent';
const { ccclass, property } = _decorator;
@ccclass('StartPanel')
export class StartPanel extends Component {
@property(sp.Skeleton)
startSk:sp.Skeleton = null!;
@property(Node)
btnNode:Node = null!;
@property(Node)
btnNodeHw:Node = null!;
@property(Animation)
loadAni:Animation = null!;
private _isClick:boolean = false;
show(){
this.loadAni.node.active = false;
this.loadAni.stop();
this.startSk.setAnimation(0, 'start', false);
this.startSk.addAnimation(0, 'idle', true);
this.btnNode.active = false;
this.btnNodeHw.active = false;
setTimeout(()=>{
this.btnNode.active = true;
if(GobeUtil.instance.isHwInit){
this.btnNodeHw.active = true;
}
}, 1500);
if(!GobeUtil.instance.isHwInit){
GobeUtil.instance.initHuawei();
}
}
protected onEnable(): void {
ClientEvent.on(Constant.EVENT_NAME.HUAWEI_LOGIN_MSG, this._initSuccess, this);
}
protected onDisable(): void {
ClientEvent.off(Constant.EVENT_NAME.HUAWEI_LOGIN_MSG, this._initSuccess, this);
}
private _initSuccess(code:number, msg:string){
// 账号登录
if(code == Constant.HUAWEI_LOGIN.SIGN_IN_SUCCESS){
GobeUtil.instance.isHwLogin = true;
this._loginGame();
}else if(code == Constant.HUAWEI_LOGIN.INIT_SUCCESS){
// 华为初始化
this.btnNodeHw.active = true;
}
else if(code == Constant.HUAWEI_LOGIN.INIT_UNDER_AGE){
}
else if(code == Constant.HUAWEI_LOGIN.INIT_ERROR){
}
else if(code == Constant.HUAWEI_LOGIN.SIGN_IN_ERROR){
UIManager.instance.showTips(Constant.ROOM_TIPS.HUA_WEI_LOAGIN_ERROR);
this.loadAni.node.active = false;
this.loadAni.stop();
this._isClick = false;
}
}
/**
* 开始游戏
*
* @returns
*/
public onStartGameHW(){
if(this._isClick){
return;
}
this._isClick = true;
this.loadAni.node.active = true;
this.loadAni.play();
GobeUtil.instance.hwSignIn();
}
/**
* 开始游戏
*
* @returns
*/
public onStartGame(){
if(this._isClick){
return;
}
this._isClick = true;
this.loadAni.node.active = true;
this.loadAni.play();
this._loginGame();
}
/**
* 登录游戏
*/
private _loginGame(){
if(!GobeUtil.instance.isChangeWifiType){
GobeUtil.instance.createRoomAI(()=>{
UIManager.instance.showDialog(Constant.PANEL_NAME.READY);
},()=>{
UIManager.instance.showTips(Constant.ROOM_TIPS.CREATE_ROOM_ERROR);
});
}else{
// 登录
var playerId:string = PlayerData.instance.playerInfo['playerId'];
GobeUtil.instance.initSDK(playerId, (successInit:boolean)=>{
if(successInit){
UIManager.instance.showDialog(Constant.PANEL_NAME.SELECT_GAME);
UIManager.instance.hideDialog(Constant.PANEL_NAME.START_GAME);
}else{
UIManager.instance.showTips(Constant.ROOM_TIPS.LOGIN_GAME_ERROR);
}
this.loadAni.node.active = false;
this.loadAni.stop();
this._isClick = false;
});
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f65802ea-e53a-4068-83de-f11ac45391a9",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,31 @@
import { _decorator, Component, Label} from 'cc';
import { UIManager } from '../../framework/uiManager';
import { Constant } from '../../framework/constant';
const { ccclass, property } = _decorator;
@ccclass('TipPanel')
export class TipPanel extends Component {
@property(Label)
txtTip: Label = null!;
private _callback:Function = null!;
show(tip:string, callback:Function){
this.txtTip.string = tip;
this._callback = callback;
}
onOk(){
if(this._callback){
this._callback();
}
UIManager.instance.hideDialog(Constant.PANEL_NAME.TIP_PANEL);
}
onCancel(){
UIManager.instance.hideDialog(Constant.PANEL_NAME.TIP_PANEL);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "a8b69cad-378a-4e50-97bd-da72b7d3b802",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,38 @@
import { _decorator, Component, AnimationComponent, director } from 'cc';
import { PoolManager } from '../../framework/poolManager';
const { ccclass, property } = _decorator;
@ccclass('TransitionBgPanel')
export class TransitionBgPanel extends Component {
private static TRANSITION_IN: string = 'transitionIn';
private static TRANSITION_OUT: string = 'transitionOut';
@property(AnimationComponent)
animation: AnimationComponent = null!;
show (callback:Function) {
director.addPersistRootNode(this.node);
this.animation.play(TransitionBgPanel.TRANSITION_IN);
this.animation.once(AnimationComponent.EventType.FINISHED, () => {
this.animation.play(TransitionBgPanel.TRANSITION_OUT);
this.animation.once(AnimationComponent.EventType.FINISHED, () => {
director.removePersistRootNode(this.node);
PoolManager.instance.putNode(this.node);
callback && callback();
});
});
}
}
/**
* [1] Class member could be defined like this.
* [2] Use `property` decorator if your want the member to be serializable.
* [3] Your initialization goes here.
* [4] Your update function goes here.
*
* Learn more about scripting: https://docs.cocos.com/creator/3.3/manual/zh/scripting/
* Learn more about CCClass: https://docs.cocos.com/creator/3.3/manual/zh/scripting/ccclass.html
* Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.3/manual/zh/scripting/life-cycle-callbacks.html
*/

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"6c0e1633-e119-474b-9755-70d8f46d705e","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,58 @@
import { _decorator, Component, AnimationComponent, director } from 'cc';
import { PoolManager } from '../../framework/poolManager';
import { ClientEvent } from '../../framework/clientEvent';
import { Constant } from '../../framework/constant';
const { ccclass, property } = _decorator;
@ccclass('TransitionPanel')
export class TransitionPanel extends Component {
private static TRANSITION_IN: string = 'transitionIn';
private static TRANSITION_OUT: string = 'transitionOut';
@property(AnimationComponent)
animation: AnimationComponent = null!;
private _loadSceneOver: boolean = false;
private _sceneName: string = '';
show (sceneName: string) {
this._sceneName = sceneName;
director.addPersistRootNode(this.node);
this._loadSceneOver = false;
this.animation.play(TransitionPanel.TRANSITION_IN);
director.preloadScene(Constant.SCENE_NAME.SLECT, () => {
this._loadSceneOver = true;
this._transitionOut();
});
}
private _transitionOut () {
if (this._loadSceneOver) {
var self = this;
director.loadScene(this._sceneName, ()=>{
self.animation.play(TransitionPanel.TRANSITION_OUT);
self.animation.once(AnimationComponent.EventType.FINISHED, () => {
director.removePersistRootNode(self.node);
PoolManager.instance.putNode(self.node);
ClientEvent.dispatchEvent(Constant.EVENT_NAME.ON_GAME_321);
});
});
}
}
}
/**
* [1] Class member could be defined like this.
* [2] Use `property` decorator if your want the member to be serializable.
* [3] Your initialization goes here.
* [4] Your update function goes here.
*
* Learn more about scripting: https://docs.cocos.com/creator/3.3/manual/zh/scripting/
* Learn more about CCClass: https://docs.cocos.com/creator/3.3/manual/zh/scripting/ccclass.html
* Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.3/manual/zh/scripting/life-cycle-callbacks.html
*/

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "958f129c-362a-437a-a2a0-92a5a63d3a31",
"files": [],
"subMetas": {},
"userData": {}
}