[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,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "86163c02-256d-4232-952f-2f9c3c03ab0a",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,29 @@
import { _decorator, Component, LabelComponent, Vec3, UITransform, Size, isValid, AnimationComponent } from 'cc';
import {PoolManager} from '../../framework/poolManager';
const { ccclass, property } = _decorator;
@ccclass('Tips')
export class Tips extends Component {
@property(LabelComponent)
lbTips: LabelComponent = null!;
targetPos: any;
show (content: string, callback?: Function) {
this.targetPos = new Vec3(0, 0, 0);
this.node.setPosition(this.targetPos);
this.lbTips.string = content;
let size: Size = this.lbTips.node.getComponent(UITransform)?.contentSize as Size;
if (!isValid(size)) {
PoolManager.instance.putNode(this.node);
return;
}
this.node.getComponent(UITransform)?.setContentSize(size.width + 100 < 240 ? 240 : size.width + 100, size.height + 30);
let animation: AnimationComponent = this.node.getComponent(AnimationComponent) as AnimationComponent;
animation.play();
animation.once(AnimationComponent.EventType.FINISHED, () => {
callback && callback();
PoolManager.instance.putNode(this.node);
})
}
}

View File

@@ -0,0 +1,11 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "a91d7339-e96d-451b-8be6-e1c5dbf91132",
"files": [],
"subMetas": {},
"userData": {
"simulateGlobals": []
}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "8c8ec3c3-e63c-49f2-a4b8-0dd46b0eaa4a",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,158 @@
import { _decorator, Component, Node, CCInteger, Vec3 } from 'cc';
import { Constant } from '../../framework/constant';
import { Util } from '../../framework/util';
import { PlayerData } from '../../framework/playerData';
const { ccclass, property } = _decorator;
/**
* Predefined variables
* Name = easyTouch
* DateTime = Wed May 11 2022 14:12:44 GMT+0800 (中国标准时间)
* Author = yu_meng123
* FileBasename = easyTouch.ts
* FileBasenameNoExtension = easyTouch
* URL = db://assets/script/game/easyTouch.ts
* ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
*
*/
@ccclass('EasyTouch')
export class EasyTouch extends Component {
@property(Node)
centerCircleNode: Node = null!;
@property(Node)
directionNode: Node = null!;
@property(CCInteger)
bgLength: number = 0;
@property
isLeftTouch: boolean = false;
private _vec3_1: Vec3 = new Vec3();
private _lastPos: Vec3 = new Vec3();
private _vec3_Angle: Vec3 = new Vec3(0, 0, 0);
private _lastX: number = 0;
private _lastY: number = 0;
start () {
this.directionNode.active = false;
setTimeout(() => {
this._lastPos.set(this.node.position);
});
}
public startTouch (x: number, y: number) {
this.node.setPosition(new Vec3(x, y));
this.directionNode.active = false;
}
public endTouch () {
this.node.setPosition(this._lastPos);
this.directionNode.active = false;
// 左手
if (this.isLeftTouch) {
PlayerData.instance.updateEasyTouchInfo(Constant.EASY_TOUCH.TOUCH_LEFT_X, 0);
PlayerData.instance.updateEasyTouchInfo(Constant.EASY_TOUCH.TOUCH_LEFT_Y, 0);
}
// 右手
else {
PlayerData.instance.updateEasyTouchInfo(Constant.EASY_TOUCH.TOUCH_RIGHT_X, 0);
PlayerData.instance.updateEasyTouchInfo(Constant.EASY_TOUCH.TOUCH_RIGHT_Y, 0);
}
}
/**
* 移动
*
* @param x
* @param y
*/
public moveTouch (x: number, y: number) {
var dis = Math.sqrt(x * x + y * y);
if (dis > this.bgLength) {
var per: number = this.bgLength / dis;
x = per * x;
y = per * y;
this._vec3_1.set(x, y, 0);
this.centerCircleNode.setPosition(this._vec3_1);
}
else {
this._vec3_1.set(x, y, 0);
this.centerCircleNode.setPosition(this._vec3_1);
}
var z: number = Math.atan(x / y) * 180 / Math.PI;
if (y < 0) {
z -= 180;
}
this._vec3_Angle.set(0, 0, z * -1);
this.directionNode.eulerAngles = this._vec3_Angle;
this.directionNode.active = true;
// 左手
if (this.isLeftTouch) {
PlayerData.instance.updateEasyTouchInfo(Constant.EASY_TOUCH.TOUCH_LEFT_X, x / this.bgLength);
PlayerData.instance.updateEasyTouchInfo(Constant.EASY_TOUCH.TOUCH_LEFT_Y, y / this.bgLength);
}
// 右手
else {
PlayerData.instance.updateEasyTouchInfo(Constant.EASY_TOUCH.TOUCH_RIGHT_X, x / this.bgLength);
PlayerData.instance.updateEasyTouchInfo(Constant.EASY_TOUCH.TOUCH_RIGHT_Y, y / this.bgLength);
}
}
/**
* 设置 上次便移的点
* @param x
* @param y
*/
public setLastXY (x: number, y: number) {
this._lastX = x;
this._lastY = y;
}
/**
* 通过数值更改位置
*
* @param x
* @param y
*/
public moveTouchByXY (x: number, y: number) {
x = Math.ceil(x * 10) * 0.1;
y = Math.ceil(y * 10) * 0.1;
this._lastX = Util.lerp(this._lastX, x, 0.1);
this._lastY = Util.lerp(this._lastY, y, 0.1);
this._vec3_1.set(this._lastX * this.bgLength, this._lastY * this.bgLength, 0);
this.centerCircleNode.setPosition(this._vec3_1);
var z: number = Math.atan(x / y) * 180 / Math.PI;
if (y < 0) {
z -= 180;
}
this._vec3_Angle.set(0, 0, z * -1);
this.directionNode.eulerAngles = this._vec3_Angle;
}
}
/**
* [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.4/manual/zh/scripting/
* Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/decorator.html
* Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html
*/

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "2ab5d37b-dce3-45ce-b8c6-247477bb702f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,140 @@
import { _decorator, Touch, input, Input, view, EventTouch, Vec2, Component } from 'cc';
import { Constant } from '../../framework/constant';
import { EasyTouch } from './easy_touch';
import { ClientEvent } from '../../framework/clientEvent';
const { ccclass, property } = _decorator;
@ccclass('EasyTouchPanel')
export class EasyTouchPanel extends Component {
// 左 横杆
@property(EasyTouch)
leftEasyTouch: EasyTouch = null!;
@property(EasyTouch)
rightEasyTouch: EasyTouch = null!;
// 移动位置
private _startLeftMoveX: number = 0;
// 移动坐标
private _startLeftMoveY: number = 0;
// 移动位置
private _startRightMoveX: number = 0;
// 移动坐标
private _startRightMoveY: number = 0;
// 屏幕宽
private _canvasMidWidth: number = 0;
// 屏幕高
private _canvasMidHeight: number = 0;
private _leftTouchId: number = -1;
private _rightTouchId: number = -1;
start () {
let size = view.getVisibleSize();
let width = Math.round(size.width);
let height = Math.round(size.height);
this._canvasMidWidth = width * 0.5;
this._canvasMidHeight = height * 0.5;
}
onEnable () {
ClientEvent.on(Constant.EVENT_NAME.GAME_INIT, this._init, this);
input.on(Input.EventType.TOUCH_START, this._onTouchStart, this);
input.on(Input.EventType.TOUCH_MOVE, this._onTouchMove, this);
input.on(Input.EventType.TOUCH_END, this._onTouchEnd, this);
}
onDisable () {
input.off(Input.EventType.TOUCH_START, this._onTouchStart, this);
input.off(Input.EventType.TOUCH_MOVE, this._onTouchMove, this);
input.off(Input.EventType.TOUCH_END, this._onTouchEnd, this);
}
/**
* 鼠标触摸
* @param event
*/
private _onTouchStart (event: EventTouch) {
var touch: Touch = event.touch;
var touchX: number = touch.getUIStartLocation().x;
var touchY: number = touch.getUIStartLocation().y;
// 屏幕左边
if (touchX < this._canvasMidWidth) {
this._startLeftMoveX = touchX;
this._startLeftMoveY = touchY;
this._leftTouchId = touch.getID();
this.leftEasyTouch.startTouch(touchX - this._canvasMidWidth, touchY - this._canvasMidHeight);
}
else {
this._startRightMoveX = touchX;
this._startRightMoveY = touchY;
this._rightTouchId = touch.getID();
this.rightEasyTouch.startTouch(touchX - this._canvasMidWidth, touchY - this._canvasMidHeight);
}
}
/**
* 鼠标触摸
* @param event
*/
private _onTouchMove (event: EventTouch) {
var touchs: Touch[] = event.getTouches();
for (var index: number = 0; index < touchs.length; index++) {
var touch: Touch = touchs[index];
var vec2: Vec2 = touch.getUILocation();
if (touch.getID() == this._leftTouchId) {
this.leftEasyTouch.moveTouch(touch.getUILocation().x - this._startLeftMoveX, touch.getUILocation().y - this._startLeftMoveY);
}
else if (touch.getID() == this._rightTouchId) {
this.rightEasyTouch.moveTouch(vec2.x - this._startRightMoveX, vec2.y - this._startRightMoveY);
}
}
}
private _init(){
this._leftTouchId = -1;
this.leftEasyTouch.endTouch();
this.leftEasyTouch.moveTouchByXY(
0,
0
);
}
/**
* 鼠标触摸
* @param event
*/
private _onTouchEnd (event: EventTouch) {
var touch: Touch = event.touch;
var touchId: number = touch.getID();
if (touchId == this._leftTouchId) {
this._leftTouchId = -1;
this.leftEasyTouch.endTouch();
this.leftEasyTouch.moveTouchByXY(
0,
0
);
}
else {
this._rightTouchId = -1;
this.rightEasyTouch.endTouch();
this.rightEasyTouch.moveTouchByXY(
0,
0
);
}
if (this._leftTouchId == -1 && this._rightTouchId == -1) {
// 双手都移开屏幕
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "e1f2a28c-3bf2-49c7-91b1-c5c641bb0edd",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "25fcc73d-99be-4f5b-8e35-2ea1cdf93fb6",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

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": {}
}

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "842459a7-ecd4-4753-af20-225081e3b3c0",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -0,0 +1,231 @@
import { _decorator, Component, Node, LabelComponent, AnimationComponent, SpriteComponent, SpriteFrame, Prefab, Label, Animation } from 'cc';
import { GobeUtil, WIFI_TYPE } from '../../core/gobeUtil';
import {ClientEvent }from '../../framework/clientEvent';
import { Constant } from '../../framework/constant';
import { ResourceUtil } from '../../framework/resourceUtil';
import { PoolManager } from '../../framework/poolManager';
import { EffectManager } from '../../framework/effectManager';
import { FighterModel } from '../../core/fighterModel';
import { PlayerInfo } from '../../libs/GOBE';
import { UIManager } from '../../framework/uiManager';
const { ccclass, property } = _decorator;
/**
* Predefined variables
* Name = Ready2
* DateTime = Thu Sep 02 2021 17:35:37 GMT+0800 (中国标准时间)
* Author = yanli.huang
* FileBasename = ready2.ts
* FileBasenameNoExtension = ready2
* URL = db://assets/script/ui/ready/ready2.ts
* ManualUrl = https://docs.cocos.com/creator/3.3/manual/zh/
*
*/
const MODEL_BOY: number = 0;
const MODEL_GIRL: number = 1;
@ccclass('Ready')
export class Ready extends Component {
@property(AnimationComponent)
animation: AnimationComponent = null!;
@property([Node])
aryPlayerWait: Node[] = [];
@property([Node])
aryPlayer: Node[] = [];
@property([LabelComponent])
aryPlayerName: LabelComponent[] = [];
@property([SpriteComponent])
aryPlayerHead: SpriteComponent[] = [];
@property([SpriteFrame])
aryHead: SpriteFrame[] = [];
@property(Node)
leftNode: Node = null!;
@property(Node)
rightNode: Node = null!;
@property(Node)
btnClose: Node = null!;
@property(Label)
txtNum:Label = null!;
@property(Animation)
vsAni:Animation = null!;
@property(Node)
girlNode: Node = null!;
@property(Node)
boyNode: Node = null!;
private _vsNode: Node | null = null;
private _isShowAni:boolean = false;
private _isFightOpen:boolean = false;
onEnable () {
PoolManager.instance.putNode(this._vsNode as Node);
ClientEvent.on(Constant.EVENT_NAME.ON_OTHER_JOIN_ROOM, this._onOtherJoinRoom, this);
}
onDisable () {
this._cleanModel();
ClientEvent.off(Constant.EVENT_NAME.ON_OTHER_JOIN_ROOM, this._onOtherJoinRoom, this);
}
show(isFight:boolean = false) {
this._isFightOpen = isFight;
this._isShowAni = false;
this.txtNum.string = "房间号:" + GobeUtil.instance.room.roomCode;
var count:number = this.aryPlayerHead.length;
for(var index = 0; index < count; index ++){
this._showPlayerReady(index, false);
}
this.animation.play();
this.animation.once(Animation.EventType.FINISHED, () => {
this._isShowAni = true;
this._updatePlayerShow();
this._checkStart();
});
this.vsAni.node.active = false;
if(GobeUtil.instance.wifiType == WIFI_TYPE.STAND_ALONE){
this.btnClose.active = false;
}
}
/**
* 退出组队
*/
public onClose(){
UIManager.instance.showDialog(Constant.PANEL_NAME.TIP_PANEL, [
Constant.ROOM_TIPS.LEAVE_ROOM_MSG, ()=>{
GobeUtil.instance.leaveRoom(()=>{
UIManager.instance.hideDialog(Constant.PANEL_NAME.READY);
UIManager.instance.showTips(Constant.ROOM_TIPS.LEAVE_ROOM_SUCCESS);
if(this._isFightOpen){
UIManager.instance.showTransition(Constant.SCENE_NAME.SLECT);
}
},()=>{
UIManager.instance.showTips(Constant.ROOM_TIPS.LEAVE_ROOM_ERROR);
},
false);
}]
);
}
/**
* 显示玩家
*
* @param isOwn
* @returns
*/
private _updatePlayerShow(playerId?:string){
var roomPlayers:PlayerInfo[] = GobeUtil.instance.roomPlayers;
for (let idx = 0; idx < roomPlayers.length; idx++) {
let player: PlayerInfo = roomPlayers[idx];
if(playerId && playerId != ""){
if( player.playerId == playerId){
let i = MODEL_BOY;
if (!GobeUtil.instance.checkIsRoomOwner(player.playerId)) {
i = MODEL_GIRL;
}
this._showPlayerReady(i, true, player.customPlayerProperties);
this._showModel(i);
}
}else{
let i = MODEL_BOY;
if (!GobeUtil.instance.checkIsRoomOwner(player.playerId)) {
i = MODEL_GIRL;
}
this._showPlayerReady(i, true, player.customPlayerProperties);
this._showModel(i);
}
}
}
/**
* 其他玩家加入房间
*/
private _onOtherJoinRoom(playerId:string){
this._updatePlayerShow(playerId);
this._checkStart();
}
private _showPlayerReady (idx: number, isReady: boolean, playerName:string = "") {
(this.aryPlayerHead[idx].node.parent as Node).active = isReady;
this.aryPlayerName[idx].node.active = isReady;
this.aryPlayer[idx].active = isReady;
this.aryPlayerWait[idx].active = !isReady;
if(playerName != ""){
this.aryPlayerName[idx].string = playerName;
}
}
private _showModel (idx: number) {
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;
}
EffectManager.instance.playEffect(parent, Constant.READY_PREFAB.JOIN_EFFECT, true, true);
if(idx === MODEL_GIRL){
this.girlNode.active = true;
}else{
this.boyNode.active = true;
}
}
private _cleanModel () {
this.girlNode.active = false;
this.girlNode.active = false;
}
private _checkStart(){
if(!this._isShowAni){
return;
}
var roomPlayers:PlayerInfo[] = GobeUtil.instance.roomPlayers;
if (roomPlayers.length >= Constant.MIN_PLAYER) {
UIManager.instance.hideDialog(Constant.PANEL_NAME.TIP_PANEL);
UIManager.instance.hideDialog(Constant.PANEL_NAME.MEDIA_PANEL);
GobeUtil.instance.mediaLeaveRoom();
GobeUtil.instance.leaveChannel();
this.animation.off(Animation.EventType.FINISHED);
this.vsAni.node.active = true;
this.vsAni.play();
this.vsAni.once(AnimationComponent.EventType.FINISHED, () => {
UIManager.instance.showTransition(Constant.SCENE_NAME.FIGHT);
})
}
}
}
/**
* [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": "2003981c-1b31-4dbb-9881-0b4aa3b879fc",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,64 @@
import { _decorator, Component, director, game, Input, input, Prefab, sys } from 'cc';
import { PlayerData } from '../framework/playerData';
import { AudioManager } from '../framework/audioManager';
import { GobeUtil } from '../core/gobeUtil';
import { UIManager } from '../framework/uiManager';
import { Constant } from '../framework/constant';
import { Util } from '../framework/util';
import { PREVIEW } from 'cc/env';
const { ccclass, property } = _decorator;
@ccclass('Select')
export class Select extends Component {
@property([Prefab])
public backPrefabs: Prefab[] = [];
start() {
if(PlayerData.instance.isInit == false){
game.frameRate = 30;
AudioManager.instance.init();
PlayerData.instance.loadFromCache();
var playerId:string = PlayerData.instance.playerInfo['playerId'];
if(playerId == null){
playerId = "cocos" + (new Date().getTime()).toString().substring(6);
var staticId:number = Math.floor(Math.random() * 2);
PlayerData.instance.createPlayerInfo({
'playerId': playerId,
"playerName": "",
"score": 0,
"icon": Math.floor(Math.random() * 10),
"staticId": staticId
});
Util.randomName(staticId).then((playerName)=>{
PlayerData.instance.updatePlayerInfo("playerName", playerName);
})
}
//h5 Android 进入全屏模式
if (!PREVIEW) {
input.once(Input.EventType.TOUCH_END, () => {
if (sys.isBrowser && document.documentElement) {
let de = document.documentElement;
if (de.requestFullscreen) {
de.requestFullscreen();
} else if (de.mozRequestFullScreen) {
de.mozRequestFullScreen();
} else if (de.webkitRequestFullScreen) {
de.webkitRequestFullScreen();
}
}
}, this);
}
}
var ownPlayerId:string = GobeUtil.instance.ownPlayerId;
if(ownPlayerId == ""){
UIManager.instance.showDialog(Constant.PANEL_NAME.START_GAME);
}else{
UIManager.instance.showDialog(Constant.PANEL_NAME.SELECT_GAME);
}
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"8b2984aa-6cab-4db7-a54d-58048b09b078","files":[],"subMetas":{},"userData":{}}