Commit a10dd21d authored by 范雪寒's avatar 范雪寒

feat:

parent 2503cdba
{
"ver": "2.0.1",
"uuid": "a84e8986-8a75-4804-b57b-c7b984f65283",
"downloadMode": 0,
"duration": 3.474286,
"subMetas": {}
}
\ No newline at end of file
{"frameRate":24,"name":"vs","version":"5.5","compatibleVersion":"5.5","armature":[{"type":"Armature","frameRate":24,"name":"Armature","aabb":{"x":-296.5,"y":-297,"width":593,"height":594},"bone":[{"name":"root"},{"name":"star","parent":"root"},{"name":"vs","parent":"root"},{"name":"star1","parent":"root"},{"name":"star11","parent":"root"},{"name":"star12","parent":"root"},{"name":"star13","parent":"root"},{"name":"star14","parent":"root"},{"name":"star15","parent":"root"},{"name":"star16","parent":"root"},{"name":"star17","parent":"root"},{"name":"star18","parent":"root"},{"name":"star19","parent":"root"},{"name":"star110","parent":"root"}],"slot":[{"name":"star_01","parent":"star","color":{"aM":0}},{"name":"star_011","parent":"star1","color":{"aM":0}},{"name":"star_0111","parent":"star11","color":{"aM":0}},{"name":"star_0112","parent":"star12","color":{"aM":0}},{"name":"star_0113","parent":"star13","color":{"aM":0}},{"name":"star_0114","parent":"star14","color":{"aM":0}},{"name":"star_0115","parent":"star15","color":{"aM":0}},{"name":"star_0116","parent":"star16","color":{"aM":0}},{"name":"star_0117","parent":"star17","color":{"aM":0}},{"name":"star_0118","parent":"star18","color":{"aM":0}},{"name":"star_0119","parent":"star19","color":{"aM":0}},{"name":"star_01110","parent":"star110","color":{"aM":0}},{"name":"img_vs","parent":"vs"}],"skin":[{"slot":[{"name":"star_0115","display":[{"name":"star_01"}]},{"name":"star_0111","display":[{"name":"star_01"}]},{"name":"star_0118","display":[{"name":"star_01"}]},{"name":"star_01","display":[{"name":"star_01"}]},{"name":"star_011","display":[{"name":"star_01"}]},{"name":"img_vs","display":[{"name":"img_vs"}]},{"name":"star_0113","display":[{"name":"star_01"}]},{"name":"star_0117","display":[{"name":"star_01"}]},{"name":"star_0119","display":[{"name":"star_01"}]},{"name":"star_0116","display":[{"name":"star_01"}]},{"name":"star_01110","display":[{"name":"star_01"}]},{"name":"star_0112","display":[{"name":"star_01"}]},{"name":"star_0114","display":[{"name":"star_01"}]}]}],"animation":[{"duration":35,"playTimes":0,"name":"normal","bone":[{"name":"star","translateFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":-293.5}],"scaleFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":0.01,"y":0.01}]},{"name":"vs","scaleFrame":[{"duration":6,"tweenEasing":0},{"duration":8,"tweenEasing":0,"x":1.47,"y":1.47},{"duration":11,"tweenEasing":0,"x":1.47,"y":1.47},{"duration":10}]},{"name":"star1","translateFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":388.5}],"scaleFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":0.01,"y":0.01}]},{"name":"star11","translateFrame":[{"duration":20},{"duration":11,"tweenEasing":0},{"duration":4,"x":-315,"y":-153.5}],"scaleFrame":[{"duration":20},{"duration":11,"tweenEasing":0},{"duration":4,"x":-0.36,"y":-0.36}]},{"name":"star12","translateFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":-189,"y":277}],"scaleFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":0.01,"y":0.01}]},{"name":"star13","translateFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":-165,"y":-345.5}],"scaleFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":0.01,"y":0.01}]},{"name":"star14","translateFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":125,"y":297}],"scaleFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":0.01,"y":0.01}]},{"name":"star15","translateFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":129.5,"y":-340}],"scaleFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":0.01,"y":0.01}]},{"name":"star16","translateFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":199.5,"y":247.5}],"scaleFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":0.01,"y":0.01}]},{"name":"star17","translateFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"y":-389}],"scaleFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":0.01,"y":0.01}]},{"name":"star18","translateFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":-32.5,"y":370.5}],"scaleFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":0.01,"y":0.01}]},{"name":"star19","translateFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":-311.5,"y":181.5}],"scaleFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":0.01,"y":0.01}]},{"name":"star110","translateFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":321,"y":-202}],"scaleFrame":[{"duration":20},{"duration":15,"tweenEasing":0},{"duration":0,"x":0.01,"y":0.01}]}],"slot":[{"name":"star_01","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":5,"tweenEasing":0,"value":{"aM":0}},{"duration":10}]},{"name":"star_011","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":5,"tweenEasing":0,"value":{"aM":0}},{"duration":6,"tweenEasing":0},{"duration":4,"tweenEasing":0},{"duration":0,"value":{"aM":0}}]},{"name":"star_0111","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":5,"tweenEasing":0,"value":{"aM":0}},{"duration":6,"tweenEasing":0},{"duration":4,"tweenEasing":0},{"duration":0,"value":{"aM":0}}]},{"name":"star_0112","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":5,"tweenEasing":0,"value":{"aM":0}},{"duration":6,"tweenEasing":0},{"duration":4,"tweenEasing":0},{"duration":0,"value":{"aM":0}}]},{"name":"star_0113","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":5,"tweenEasing":0,"value":{"aM":0}},{"duration":6,"tweenEasing":0},{"duration":4,"tweenEasing":0},{"duration":0,"value":{"aM":0}}]},{"name":"star_0114","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":5,"tweenEasing":0,"value":{"aM":0}},{"duration":10}]},{"name":"star_0115","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":5,"tweenEasing":0,"value":{"aM":0}},{"duration":10}]},{"name":"star_0116","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":6,"tweenEasing":0,"value":{"aM":0}},{"duration":9}]},{"name":"star_0117","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":6,"tweenEasing":0,"value":{"aM":0}},{"duration":9}]},{"name":"star_0118","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":6,"tweenEasing":0,"value":{"aM":0}},{"duration":9}]},{"name":"star_0119","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":6,"tweenEasing":0,"value":{"aM":0}},{"duration":5,"tweenEasing":0},{"duration":4,"tweenEasing":0},{"duration":0,"value":{"aM":0}}]},{"name":"star_01110","colorFrame":[{"duration":20,"tweenEasing":0,"value":{"aM":0}},{"duration":6,"tweenEasing":0,"value":{"aM":0}},{"duration":5,"tweenEasing":0},{"duration":4,"tweenEasing":0},{"duration":0,"value":{"aM":0}}]}],"zOrder":{"frame":[{"duration":35}]}}],"defaultActions":[{"gotoAndPlay":"normal"}],"canvas":{"width":1024,"height":1024}},{"type":"MovieClip","frameRate":24,"name":"MovieClip","bone":[{"name":"root"}],"defaultActions":[{}]}]}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "e84b01ac-5237-4326-8da5-d00c302b7579",
"subMetas": {}
}
\ No newline at end of file
{"name":"vs","SubTexture":[{"name":"star_01","x":1,"height":169,"y":597,"width":174},{"name":"img_vs","x":1,"height":594,"y":1,"width":593}],"height":1024,"imagePath":"vs_tex.png","width":1024}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "bc069cc1-8ec1-4427-b94d-345f05fd81b4",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "38e3a4c0-56a6-49d1-ab2b-d989a30fe5ef",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1024,
"height": 1024,
"platformSettings": {},
"subMetas": {
"vs_tex": {
"ver": "1.0.4",
"uuid": "952faf36-6ef8-4e33-8baf-a1e3ee74ba8c",
"rawTextureUuid": "38e3a4c0-56a6-49d1-ab2b-d989a30fe5ef",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -214.5,
"offsetY": 128.5,
"trimX": 1,
"trimY": 1,
"width": 593,
"height": 765,
"rawWidth": 1024,
"rawHeight": 1024,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "2cc89da2-6889-41ef-83ce-e2df1ef87d40",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
export as namespace Play;
declare class EventEmitter<T> {
on<K extends keyof T>(event: K, listener: (payload: T[K]) => any): this;
on(evt: string, listener: Function): this;
once<K extends keyof T>(event: K, listener: (payload: T[K]) => any): this;
once(evt: string, listener: Function): this;
off<K extends keyof T>(evt: K | string, listener?: Function): this;
emit<K extends keyof T>(evt: K | string, ...args: any[]): boolean;
}
export enum Event {
/** 断开连接 */
DISCONNECTED = 'disconnected',
/** 加入到大厅 */
LOBBY_JOINED = 'lobbyJoined',
/** 大厅房间列表变化 */
LOBBY_ROOM_LIST_UPDATED = 'lobbyRoomListUpdate',
/** 有新玩家加入房间 */
PLAYER_ROOM_JOINED = 'newPlayerJoinedRoom',
/** 有玩家离开房间 */
PLAYER_ROOM_LEFT = 'playerLeftRoom',
/** 玩家活跃属性变化 */
PLAYER_ACTIVITY_CHANGED = 'playerActivityChanged',
/** 主机变更 */
MASTER_SWITCHED = 'masterSwitched',
/** 离开房间 */
ROOM_LEFT = 'roomLeft',
/** 被踢出房间 */
ROOM_KICKED = 'roomKicked',
/** 房间系统属性变化 */
ROOM_SYSTEM_PROPERTIES_CHANGED = 'roomSystemPropertiesChanged',
/** 房间自定义属性变化 */
ROOM_CUSTOM_PROPERTIES_CHANGED = 'roomCustomPropertiesChanged',
/** 玩家自定义属性变化 */
PLAYER_CUSTOM_PROPERTIES_CHANGED = 'playerCustomPropertiesChanged',
/** 自定义事件 */
CUSTOM_EVENT = 'customEvent',
/** 错误事件 */
ERROR = 'error',
}
export enum ReceiverGroup {
/** 其他人(除了自己之外的所有人) */
Others,
/** 所有人(包括自己) */
All,
/** 主机客户端 */
MasterClient,
}
interface CustomProperties {
[key: string]: any;
}
interface CustomEventData {
[key: string]: any;
}
interface ErrorEvent {
code: number;
detail: string;
}
declare interface PlayEvent {
connected: void;
connectFailed: ErrorEvent;
disconnected: void;
lobbyJoined: void;
lobbyLeft: void;
lobbyRoomListUpdate: void;
roomCreated: void;
roomCreateFailed: ErrorEvent;
roomJoined: void;
roomJoinFailed: ErrorEvent;
newPlayerJoinedRoom: {
newPlayer: Player;
};
playerLeftRoom: {
leftPlayer: Player;
};
playerActivityChanged: {
player: Player;
};
masterSwitched: {
newMaster: Player;
};
roomLeft: void;
roomKicked: {
code: number;
msg: string;
};
roomCustomPropertiesChanged: {
changedProps: CustomProperties;
};
roomSystemPropertiesChanged: {
changedProps: CustomProperties;
};
playerCustomPropertiesChanged: {
player: Player;
changedProps: CustomProperties;
};
customEvent: {
eventId: number;
eventData: CustomEventData;
senderId: number;
};
error: ErrorEvent;
}
export class LobbyRoom {
readonly roomName: string;
readonly maxPlayerCount: number;
readonly expectedUserIds: string[];
readonly emptyRoomTtl: number;
readonly playerTtl: number;
readonly playerCount: number;
readonly customRoomPropertiesForLobby: CustomProperties;
}
export class Player {
readonly userId: string;
readonly actorId: number;
readonly isLocal: boolean;
readonly isMaster: boolean;
readonly isActive: boolean;
setCustomProperties(
properties: CustomProperties,
opts?: {
expectedValues?: CustomProperties;
}
): Promise<void>;
readonly customProperties: CustomProperties;
}
export class Room {
readonly name: string;
readonly open: boolean;
readonly visible: boolean;
readonly maxPlayerCount: number;
readonly master: Player;
readonly masterId: number;
readonly expectedUserIds: string[];
readonly playerList: Player[];
getPlayer(actorId: number): Player;
setCustomProperties(
properties: CustomProperties,
opts?: {
expectedValues?: CustomProperties;
}
): Promise<void>;
readonly customProperties: CustomProperties;
setOpen(open: boolean): Promise<void>;
setVisible(visible: boolean): Promise<void>;
setRoomMaxPlayerCount(count: number): Promise<void>;
setRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
clearRoomExpectedUserIds(): Promise<void>;
addRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
removeRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
setMaster(newMasterId: number): Promise<void>;
sendEvent(
eventId: number,
eventData?: CustomEventData,
options?: {
receiverGroup?: ReceiverGroup;
targetActorIds?: number[];
}
): Promise<void>;
kickPlayer(
actorId: number,
opts?: {
code?: number;
msg?: string;
}
): Promise<void>;
leave(): Promise<void>;
}
export class Client extends EventEmitter<PlayEvent> {
readonly room: Room;
readonly player: Player;
readonly lobbyRoomList: LobbyRoom[];
userId: string;
constructor(opts: {
appId: string;
appKey: string;
userId: string;
ssl?: boolean;
feature?: string;
gameVersion?: string;
playServer?: string;
});
connect(): Promise<Client>;
reconnect(): Promise<Client>;
reconnectAndRejoin(): Promise<Room>;
close(): Promise<void>;
joinLobby(): Promise<void>;
leaveLobby(): Promise<void>;
createRoom(opts?: {
roomName?: string;
roomOptions?: Object;
expectedUserIds?: string[];
}): Promise<Room>;
joinRoom(
roomName: string,
opts?: {
expectedUserIds?: string[];
}
): Promise<Room>;
rejoinRoom(roomName: string): Promise<Room>;
joinOrCreateRoom(
roomName: string,
opts?: {
roomOptions?: Object;
expectedUserIds: string[];
}
): Promise<Room>;
joinRandomRoom(opts?: {
matchProperties?: Object;
expectedUserIds?: string[];
}): Promise<Room>;
matchRandom(
piggybackPeerId: string,
opts?: { matchProperties?: Object; expectedUserIds?: string[] }
): Promise<LobbyRoom>;
setRoomOpen(open: boolean): Promise<void>;
setRoomVisible(visible: boolean): Promise<void>;
setRoomMaxPlayerCount(count: number): Promise<void>;
setRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
clearRoomExpectedUserIds(): Promise<void>;
addRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
removeRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
setMaster(newMasterId: number): Promise<void>;
sendEvent(
eventId: number,
eventData?: CustomEventData,
options?: {
receiverGroup?: ReceiverGroup;
targetActorIds?: number[];
}
): Promise<void>;
leaveRoom(): Promise<void>;
kickPlayer(
actorId: number,
opts?: {
code?: number;
msg?: string;
}
): Promise<void>;
pauseMessageQueue(): void;
resumeMessageQueue(): void;
}
export enum CreateRoomFlag {
FixedMaster = 1,
MasterUpdateRoomProperties = 2,
}
export function setAdapters(newAdapters: { WebSocket: Function }): void;
export enum LogLevel {
Debug = 'Debug',
Warn = 'Warn',
Error = 'Error',
}
export function setLogger(logger: {
Debug: (...args: any[]) => any;
Warn: (...args: any[]) => any;
Error: (...args: any[]) => any;
}): void;
export enum PlayErrorCode {
OPEN_WEBSOCKET_ERROR = 10001,
SEND_MESSAGE_STATE_ERROR = 10002,
}
export function registerType<T>(
type: T,
typeId: number,
serializeMethod: (obj: T) => Uint8Array,
deserializeMethod: (bytes: Uint8Array) => T
): void;
export function serializeObject(obj: Object): Uint8Array;
export function deserializeObject(bytes: Uint8Array): Object;
{
"ver": "2.0.0",
"uuid": "a7afbd1f-ecca-4b8d-900b-f08e4c515178",
"subMetas": {}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"ver": "1.0.8",
"uuid": "085c535c-a6c0-4b0d-b107-5318e9a50303",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "a69551c2-3f6e-43b9-89dc-fef6d1ce6488",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
import { asyncDelay } from "../script/util";
import { NetworkHelper } from "./NetworkHelper";
export class AI {
networkHelper: NetworkHelper;
playerData: any;
_status: any;
params: any;
constructor(networkHelper: NetworkHelper, playerData: any, params: any) {
this.networkHelper = networkHelper;
this.playerData = playerData;
this.params = params;
}
async onFrameEvent(event) {
if (event.type == "SERVER_updateStatus") {
const serverStatus = JSON.parse(JSON.stringify(event.status));
if (!this._status?.round && serverStatus.round == 1) {
this._status = serverStatus;
this.startGame();
} else if (this._status.round == 1 && serverStatus.round == 2) {
this._status = serverStatus;
this.startGame();
}
this._status = serverStatus;
}
}
startGame() {
const boatIdxList = this._status.boats
.map((boat, idx) => boat.show ? idx : -1)
.filter(idx => idx != -1)
.sort(() => Math.random() - 0.5);
let time = 0;
for (let i = 0; i < 8; i++) {
time += this.params.testDuration + Math.random() * 5;
setTimeout(() => {
if (Math.random() < 0.7) {
this.networkHelper.sendFrame({
type: "right",
playerId: this.playerData.uuid,
boatIdx: boatIdxList[i]
});
} else {
this.networkHelper.sendFrame({
type: "wrong",
playerId: this.playerData.uuid,
boatIdx: boatIdxList[i]
});
}
}, time * 1000);
}
}
}
{
"ver": "1.0.8",
"uuid": "226d318b-5a74-4418-bdd7-65d4558235ef",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import { RandomInt } from "../script/util";
export class NetworkHelper {
_eventListeners: any = {};
ctor() { }
on(eventName, func) {
this._eventListeners[eventName] = func;
}
async init(roomType: string, maxPlayers: number) {
await this.initRoom();
return await this.joinRoom(roomType, maxPlayers);
}
async startGame() {
await this.startFrameSync();
await this.closeRoom();
}
async stopGame() {
await this.stopFrameSync();
await this.closeRoom();
await this.leaveRoom();
}
listenerInited = false;
room: any;
client: any;
async initRoom() {
const client = new globalThis.Play.Client({
appId: "JCKc6bU8FywdjIPupjNH8Jwx-gzGzoHsz",
appKey: "WUrRDpb46z2qFLsUNbhknYcP",
userId: `${new Date().getTime()}_${RandomInt(100000000)}`,
playServer: 'https://lyn5nahs.lc-cn-n1-shared.com'
});
console.log('client = ', client);
await client.connect();
this.client = client;
console.log('连接成功');
}
player: any;
joinRoom(roomType: string, maxPlayers: number) {
return new Promise((resolve, reject) => {
const roomProp = { roomType, maxPlayers };
this.client.joinRandomRoom({
matchProperties: roomProp,
}).then((room) => {
resolve(this.onJoinRoomSuccess(room));
}).catch((error) => {
console.log('加入房间失败');
if (error.code == 4301) {
const options = {
visible: true,
playerTtl: 0,
emptyRoomTtl: 0,
maxPlayerCount: maxPlayers,
customRoomProperties: roomProp,
customRoomPropertyKeysForLobby: ['roomType', 'maxPlayers'],
flag: globalThis.Play.CreateRoomFlag.MasterUpdateRoomProperties
};
this.client.createRoom({
roomOptions: options,
}).then((room) => {
resolve(this.onJoinRoomSuccess(room));
}).catch((error) => {
console.error(error.code, error.detail);
});
}
});
});
}
onJoinRoomSuccess(room: globalThis.Play.Room) {
console.log('加入房间成功 room = ', room);
const playerMe = room.playerList.find(player => player.isLocal);
const masterPlayer = room.playerList.find(player => player.isMaster);
const masterId = masterPlayer.userId;
const playerId = playerMe.userId;
this.room = new FakeRoom(masterId);
this.room.players.push(this.room.player);
this.player = this.room.player;
this.client.on(globalThis.Play.Event.PLAYER_ROOM_LEFT, (event) => {
this.onLeaveRoom({ data: { leavePlayerId: event.leftPlayer.userId } });
});
this.client.on(globalThis.Play.Event.PLAYER_ROOM_JOINED, (event) => {
this.onJoinRoom({ playerId: event.newPlayer.userId });
});
this.client.on(globalThis.Play.Event.CUSTOM_EVENT, (event) => {
this.onRecvFrame({ data: event.eventData });
});
// this.room.onDisconnect(this.onDisconnect.bind(this));
// this.room.onDismiss(this.onDisconnect.bind(this));
return playerId;
}
async leaveRoom() {
await this.client.close();
console.log("退房成功");
}
async dismissRoom() {
if (this.room.ownerId == this.player.id) {
console.log("房间已解散");
}
}
async closeRoom() {
// 设置房间不可见
await this.client.setRoomVisible(false);
console.log(this.client.room.visible);
}
async startFrameSync() {
console.log("开始帧同步成功");
}
async stopFrameSync() {
console.log("停止帧同步成功");
}
sendFrame(data: any) {
this.client.sendEvent(0, { frame: { items: [{ data: data }] } }, {
receiverGroup: globalThis.Play.ReceiverGroup.All,
});
}
onJoinRoom(event) {
console.log("新玩家加入", event);
if (this._eventListeners["playerJoin"]) {
this._eventListeners["playerJoin"](event);
}
this.room.players.forEach(player => {
console.log('player.playerId = ', player.playerId);
});
}
onLeaveRoom(event) {
console.log("onLeaveRoom");
if (this._eventListeners["playerLeave"]) {
this._eventListeners["playerLeave"](event);
}
console.log("玩家退出", event.data.leavePlayerId);
}
onRecvFromClient() { }
onDisconnect(event) {
this.log("玩家掉线了: " + JSON.stringify(event));
if (this._eventListeners["playerOffLine"]) {
this._eventListeners["playerOffLine"](event);
}
}
onRecvFrame(event) {
if (this._eventListeners["frameEvent"]) {
this._eventListeners["frameEvent"](event);
}
}
onStartFrameSync(event) {
console.log('onStartFrameSync');
if (this._eventListeners["gameStart"]) {
this._eventListeners["gameStart"](event);
}
}
onStopFrameSync(event) { }
onRecvFromGameSvr() { }
async onDestroy() {
try {
console.log("onDestroy1");
// MGOBE.Listener.clear();
this.stopFrameSync();
this.closeRoom();
this.dismissRoom();
this.leaveRoom();
console.log("onDestroy2");
} catch (e) {
console.log(JSON.stringify(e));
}
}
log(str) {
const node = cc.find("middleLayer");
if (node) {
node.getComponent("middleLayer").log(str);
} else {
cc.log(str);
}
}
callNetworkApiGet(baseUrl, uri, data, callBack) {
let queryStr = "?";
const params = [];
for (const key in data) {
if (Object.hasOwnProperty.call(data, key)) {
params.push(`${key}=${data[key]}`);
}
}
queryStr += params.join("&");
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 400) {
callBack(xhr.responseText);
}
};
const url = `${baseUrl}${uri}${queryStr}`;
console.log("url = " + url);
xhr.open("GET", url, true);
xhr.send();
}
}
export function asyncDelay(time) {
return new Promise((resolve, reject) => {
cc.tween(cc.find("Canvas"))
.delay(time)
.call(() => {
resolve(null);
})
.start();
});
}
class FakeRoom {
ownerId;
players = [];
player: any;
roomInfo;
constructor(playerId) {
this.player = { playerId: playerId };
this.ownerId = playerId;
this.roomInfo = { owner: playerId }
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "0b46dfe7-5041-471b-b0b6-6579970d9473",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import { asyncDelay, RandomInt } from "../script/util";
import { AI } from "./AI";
import { NetworkHelper } from "./NetworkHelper";
export class GameServer {
playerList = [];
playerMaxNumber = 0;
networkHelper: NetworkHelper = null;
nameList = [
"Chris", "Benny", "Leslie", "Devin", "Sam", "Kerry",
"Joey", "Hailey", "Fred", "Arrow", "Tony", "Michael",
];
headUrls = [
"http://staging-teach.cdn.ireadabc.com/0751c28419a0e8ffb1f0e84435b081ce.png",
"http://staging-teach.cdn.ireadabc.com/f596e586a31ac2813b1702557941c022.png",
"http://staging-teach.cdn.ireadabc.com/f0f396c52c42239913fd94523db979fa.png",
"http://staging-teach.cdn.ireadabc.com/9f2d2ef622fa33d4e2abcbdc4b40ab6a.png",
"http://staging-teach.cdn.ireadabc.com/f40ce4a8630039c4cf48a63fc1399c52.png",
];
params: any;
gameStatus: any;
constructor(playerMaxNumber, networkHelper, params) {
this.playerMaxNumber = playerMaxNumber;
this.networkHelper = networkHelper;
this.params = params;
this._timeoutIds = [];
this._intervalIds = [];
this.headUrls = this.headUrls.sort((a, b) => Math.random() - 0.5);
this.nameList = this.nameList.sort((a, b) => Math.random() - 0.5);
this.networkHelper.startFrameSync();
this.gameStatus = {
round: 0,// 0: 未开始, 1: 回合1, 2: 回合2, 3: 已结束
boats: [],
};
for (let i = 0; i < 16; i++) {
this.gameStatus.boats.push({
show: false
});
}
}
async addPlayer(player) {
console.log("addPlayer");
this.playerList.push({
name: this.nameList.splice(0, 1)[0],
uuid: player.uuid,
color:
player.uuid == this.networkHelper.room.roomInfo.owner ? "Blue" : "Red",
isAI: player.isAI,
headUrl: this.headUrls.splice(0, 1)[0],
});
if (player.isAI) {
await asyncDelay(1);
this.networkHelper.sendFrame({
type: "SERVER_allPlayerInfo",
playerData: this.playerList,
});
if (this.playerList.length == this.playerMaxNumber) {
this.networkHelper.closeRoom();
await asyncDelay(0.5);
this.startGame();
this.startAI();
}
}
}
startGame() {
let idxList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
const boatList = idxList
.sort(() => Math.random() - 0.5)
.splice(0, 8);
this.gameStatus.round = 1;
this.gameStatus.boats.forEach((boat, idx) => {
boat.show = boatList.includes(idx);
});
this.networkHelper.sendFrame({
type: "SERVER_updateStatus",
status: this.gameStatus,
});
}
onPlayerJoin(event) {
this.addPlayer({
uuid: event.data.joinPlayerId,
isAI: false,
});
}
_aiPlayerList = [];
startMatch() {
for (let i = 0; i < this.playerMaxNumber; i++) {
this._timeoutIds.push(
setTimeout(() => {
const count = this.playerMaxNumber - this.playerList.length;
if (count > 0) {
const playerInfo = {
uuid: "ai_" + i,
isAI: true,
color: "Red",
};
this._aiPlayerList.push(new AI(this.networkHelper, playerInfo, this.params));
this.addPlayer(playerInfo);
}
}, RandomInt(10000, 15000))
);
}
}
async onFrameEvent(data) {
if (this.gameStatus['gameOver']) {
return;
}
if (data.type == "playerInfo") {
const player = this.playerList.find(p => p.uuid == data.playerId);
player.name = data.playerName;
player.headUrl = data.playerHeadUrl;
this.networkHelper.sendFrame({
type: "SERVER_allPlayerInfo",
playerData: this.playerList,
});
if (this.playerList.length == this.playerMaxNumber) {
this.networkHelper.closeRoom();
await asyncDelay(0.5);
this.startGame();
this.startAI();
}
} else if (data.type == "right") {
if (this.gameStatus.round == 3) {
return;
}
this.gameStatus.boats[data.boatIdx][data.playerId] = 'right';
this.networkHelper.sendFrame({
type: "SERVER_updateStatus",
status: this.gameStatus,
});
this.checkover();
} else if (data.type == "wrong") {
if (this.gameStatus.round == 3) {
return;
}
this.gameStatus.boats[data.boatIdx][data.playerId] = 'wrong';
this.networkHelper.sendFrame({
type: "SERVER_updateStatus",
status: this.gameStatus,
});
this.checkover();
} else {
this._aiPlayerList.forEach((ai: AI) => {
ai.onFrameEvent(data);
});
}
}
checkover() {
if (this.gameStatus.boats
.filter(boat => boat.show)
.every(boat => Object.keys(boat).length == 3)
) {
this.gameStatus.round++;
this.gameStatus.boats.forEach(boat => {
boat.show = !boat.show;
});
this.networkHelper.sendFrame({
type: "SERVER_updateStatus",
status: this.gameStatus,
});
}
}
startAI() {
this.playerList
.filter((player) => player.isAI == true)
.forEach((player) => {
});
}
_timeoutIds = null;
_intervalIds = null;
// 生命周期
onDestroy() {
this._timeoutIds.forEach((id) => {
clearTimeout(id);
});
this._intervalIds.forEach((id) => {
clearInterval(id);
});
}
}
{
"ver": "1.0.8",
"uuid": "061b0c50-5687-4a88-8f8b-23474fafc20d",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "1931cf8b-bc13-44bc-a83f-630c62ccbe8b",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "b75aa40f-9cf1-467b-83cf-c6292dbb7474",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "LoadingLayer",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 7
},
{
"__id__": 11
},
{
"__id__": 14
},
{
"__id__": 17
},
{
"__id__": 21
},
{
"__id__": 25
},
{
"__id__": 34
},
{
"__id__": 54
}
],
"_active": true,
"_components": [
{
"__id__": 59
},
{
"__id__": 60
}
],
"_prefab": {
"__id__": 61
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 2560,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 4
},
{
"__id__": 5
}
],
"_prefab": {
"__id__": 6
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 2560,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
1280,
960,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "f29707ed-4120-4cee-8b97-e7a7ed611557"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 2176,
"_originalHeight": 1600,
"_id": ""
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "a1GjpGzJdD65Biy/y88Sq8",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "layout",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 8
},
{
"__id__": 9
}
],
"_prefab": {
"__id__": 10
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 300,
"height": 200
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
1280,
1210,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Layout",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"_layoutSize": {
"__type__": "cc.Size",
"width": 300,
"height": 200
},
"_resize": 1,
"_N$layoutType": 1,
"_N$cellSize": {
"__type__": "cc.Size",
"width": 40,
"height": 40
},
"_N$startAxis": 0,
"_N$paddingLeft": 0,
"_N$paddingRight": 0,
"_N$paddingTop": 0,
"_N$paddingBottom": 0,
"_N$spacingX": 500,
"_N$spacingY": 0,
"_N$verticalDirection": 1,
"_N$horizontalDirection": 0,
"_N$affectedByScale": false,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 18,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 250,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "afaLDsGNdF8rTS2GfZ3h3s",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "left",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 12
}
],
"_prefab": {
"__id__": 13
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
880,
1210,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
},
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 18,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 250,
"_horizontalCenter": -400,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "24ejo0WoZJxpoRK40tkCN+",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "right",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 15
}
],
"_prefab": {
"__id__": 16
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
1680,
1210,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
},
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 18,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 250,
"_horizontalCenter": 400,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "42DCsVISJGIKgyDyhKrDpv",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "vs",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 18
},
{
"__id__": 19
}
],
"_prefab": {
"__id__": 20
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 593,
"height": 594
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
1280,
1210,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 17
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 18,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 250,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "dragonBones.ArmatureDisplay",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 17
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_armatureName": "Armature",
"_animationName": "",
"_preCacheMode": 0,
"_cacheMode": 0,
"playTimes": 1,
"premultipliedAlpha": false,
"_armatureKey": "e84b01ac-5237-4326-8da5-d00c302b7579#bc069cc1-8ec1-4427-b94d-345f05fd81b4",
"_accTime": 0,
"_playCount": 0,
"_frameCache": null,
"_curFrame": null,
"_playing": false,
"_armatureCache": null,
"_N$dragonAsset": {
"__uuid__": "e84b01ac-5237-4326-8da5-d00c302b7579"
},
"_N$dragonAtlasAsset": {
"__uuid__": "bc069cc1-8ec1-4427-b94d-345f05fd81b4"
},
"_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 0,
"_N$_defaultCacheMode": 0,
"_N$timeScale": 1,
"_N$debugBones": false,
"_N$enableBatch": false,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "4cZmgdmo1Az6QuveaZ6W/3",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "label",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 22
},
{
"__id__": 23
}
],
"_prefab": {
"__id__": 24
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 63
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
1280,
633.901,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 21
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "",
"_N$string": "",
"_fontSize": 50,
"_lineHeight": 50,
"_enableWrapText": true,
"_N$file": {
"__uuid__": "34b18543-1119-458b-928b-969e7e48d0fd"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 21
},
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 16,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "8bJSQRyJRA0Jkcc+8GY5Do",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "progressBar",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 26
}
],
"_active": true,
"_components": [
{
"__id__": 30
},
{
"__id__": 31
},
{
"__id__": 32
}
],
"_prefab": {
"__id__": 33
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1578,
"height": 42
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
1280,
555,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "bar",
"_objFlags": 512,
"_parent": {
"__id__": 25
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 27
},
{
"__id__": 28
}
],
"_prefab": {
"__id__": 29
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 32
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-784,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 26
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "b435887d-bae1-49a8-bd0c-aeeeda4c6c73"
},
"_type": 2,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 26
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 8,
"_left": 5,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "1coIwLNVZGEZEzF3dItpuK",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 25
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "afa1a774-a1cf-4476-b01f-bdc83069f46c"
},
"_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.ProgressBar",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 25
},
"_enabled": true,
"_N$totalLength": 1568,
"_N$barSprite": {
"__id__": 27
},
"_N$mode": 0,
"_N$progress": 0,
"_N$reverse": false,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 25
},
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 16,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "55nJZ9Uk5CArtjDKXyL9xa",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "head",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 35
},
{
"__id__": 38
},
{
"__id__": 44
},
{
"__id__": 47
},
{
"__id__": 50
}
],
"_active": false,
"_components": [],
"_prefab": {
"__id__": 53
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 340,
"height": 340
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-1233.11,
-606.716,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 34
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 36
}
],
"_prefab": {
"__id__": 37
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 258,
"height": 258
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 35
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "59b5cf19-b997-4572-b537-8b94f22b26bf"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "eauguU1wtOrbhO0xPWGhAt",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "mask",
"_objFlags": 0,
"_parent": {
"__id__": 34
},
"_children": [
{
"__id__": 39
}
],
"_active": true,
"_components": [
{
"__id__": 42
}
],
"_prefab": {
"__id__": 43
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 258,
"height": 258
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "headImg",
"_objFlags": 0,
"_parent": {
"__id__": 38
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 40
}
],
"_prefab": {
"__id__": 41
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 40,
"height": 36
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 39
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "60BI1U1b9OoZRIDunWHW0a",
"sync": false
},
{
"__type__": "cc.Mask",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 38
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_spriteFrame": {
"__uuid__": "59b5cf19-b997-4572-b537-8b94f22b26bf"
},
"_type": 2,
"_segments": 64,
"_N$alphaThreshold": 0.6,
"_N$inverted": false,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "5cd2Jos1dOS46NiARvN6qg",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "frame",
"_objFlags": 0,
"_parent": {
"__id__": 34
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 45
}
],
"_prefab": {
"__id__": 46
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 280,
"height": 280
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 44
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "61f66300-e031-447d-9107-251b09648d7a"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "8aSOlD3bNAYbWZEGUBpU7X",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "frame_self",
"_objFlags": 0,
"_parent": {
"__id__": 34
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 48
}
],
"_prefab": {
"__id__": 49
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 388,
"height": 388
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 47
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "922c0839-c8d1-4f42-936b-1be1d3bb6af5"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "ddBCn3FshPQ4V9KDNSlBfr",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "name",
"_objFlags": 0,
"_parent": {
"__id__": 34
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 51
}
],
"_prefab": {
"__id__": 52
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 122.34,
"height": 63
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-203.314,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 50
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "Label",
"_N$string": "Label",
"_fontSize": 50,
"_lineHeight": 50,
"_enableWrapText": true,
"_N$file": {
"__uuid__": "343540a1-2609-4367-b74f-cfa6d2e2cb6b"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "6anh4wjaRPMqyS2LhXSx4j",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "f9qrJyDh5P1oErn3FfsNL7",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "res",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 55
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 58
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "match",
"_objFlags": 0,
"_parent": {
"__id__": 54
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 56
}
],
"_prefab": {
"__id__": 57
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 55
},
"_enabled": true,
"_clip": {
"__uuid__": "a84e8986-8a75-4804-b57b-c7b984f65283"
},
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "24pM39t0xAcpeV3Rbf7iK5",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "28B+az6rRACpZT/KUohVaz",
"sync": false
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "4d354gk3w1AIKtlOv2FygBk",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d"
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "eeb30776-64d3-4ec2-962b-a1f4bee3b27d",
"optimizationPolicy": "SINGLE_INSTANCE",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
import { asyncPlayDragonBoneAnimation } from "../../script/util";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends cc.Component {
ctor() {
}
// 生命周期 onLoad
onLoad() {
// this.initSize();
}
_designSize; // 设计分辨率
_frameSize; // 屏幕分辨率
_mapScaleMin; // 场景中常用缩放(取大值)
_mapScaleMax; // 场景中常用缩放(取小值)
_cocosScale; // cocos 自缩放 (较少用到)
initSize() {
// 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
let screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height
let design_size = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height
let f = screen_size >= design_size
cc.Canvas.instance.fitHeight = f
cc.Canvas.instance.fitWidth = !f
const frameSize = cc.view.getFrameSize();
this._frameSize = frameSize;
this._designSize = cc.view.getDesignResolutionSize();
let sx = cc.winSize.width / frameSize.width;
let sy = cc.winSize.height / frameSize.height;
this._cocosScale = Math.min(sx, sy);
sx = frameSize.width / this._designSize.width;
sy = frameSize.height / this._designSize.height;
this._mapScaleMin = Math.min(sx, sy) * this._cocosScale;
this._mapScaleMax = Math.max(sx, sy) * this._cocosScale;
}
// 生命周期 start
async start() {
this.updateLabel('创建房间中');
this.progressTo(0.1, 1);
await this.asyncDelay(1);
this.updateLabel('匹配小伙伴中');
}
async initView() {
this.setMaxPlayerNumber(5);
}
_maxPlayerNum;
setMaxPlayerNumber(number) {
this._maxPlayerNum = number;
}
_playerList;
addPlayer(name, isSelf, headUrl, uuid) {
if (!this._playerList) {
this._playerList = [];
}
if (this._playerList.find(player => player.uuid == uuid)) {
return;
}
this._playerList.push({ name, isSelf, headUrl, uuid });
console.log('name = ' + name);
const layout = cc.find('layout', this.node);
const headNode = cc.instantiate(cc.find('head', this.node));
headNode.x = 0;
headNode.y = 0;
headNode.active = true;
const frameSelf = cc.find('frame_self', headNode);
if (!isSelf) {
frameSelf.opacity = 0;
}
const nameLabel = cc.find('name', headNode);
nameLabel.getComponent(cc.Label).string = name;
const headImg = cc.find('mask/headImg', headNode);
this.loadSpriteByUrl(headImg, headUrl, () => {
const scale = Math.max(
headImg.parent.width / headImg.width,
headImg.parent.height / headImg.height
);
headImg.scale = scale;
});
if (this._playerList.length == 1) {
cc.find('left', this.node).addChild(headNode);
} else {
cc.find('right', this.node).addChild(headNode);
const vs = cc.find('vs', this.node);
asyncPlayDragonBoneAnimation(vs, 'normal', 1);
this.playLocalAudio('match');
}
const rate = Math.min(1, this._playerList.length / this._maxPlayerNum);
if (rate == 1) {
this.updateLabel('同步中');
}
this.progressTo(rate, 3);
}
_onLoadFinishFunc;
onLoadFinished(func) {
this._onLoadFinishFunc = func;
}
async asyncDelay(time) {
return new Promise((resolve, reject) => {
try {
this._timeoutIds.push(setTimeout(() => {
resolve(null);
}, time * 1000));
} catch (e) {
reject(e);
}
});
}
updateLabel(str) {
const label = cc.find('label', this.node).getComponent(cc.Label);
if (label['tweenAction']) {
label['tweenAction'].stop();
}
label['tweenAction'] = cc.tween(label)
.set({ string: `${str}` })
.delay(0.4)
.set({ string: `${str}.` })
.delay(0.4)
.set({ string: `${str}..` })
.delay(0.4)
.set({ string: `${str}...` })
.delay(0.4)
.union()
.repeatForever()
.start();
}
_maxRate = 0;
progressTo(rate, time) {
this._maxRate = Math.max(this._maxRate, rate);
const duration = Math.max(time + this.RandomInt(-1, 1), 1);
const progress = cc.find('progressBar', this.node).getComponent(cc.ProgressBar);
if (progress['tweenAction']) {
progress['tweenAction'].stop();
}
const easingList = [
'linear',
'quadInOut',
'cubicInOut',
];
progress['tweenAction'] = cc.tween(progress)
.to(duration, { progress: this._maxRate }, { easing: easingList[this.RandomInt(easingList.length)] })
.call(() => {
if (rate == 1) {
if (this._onLoadFinishFunc) {
this._onLoadFinishFunc();
}
this.node.active = false;
}
})
.start();
}
RandomInt(a, b = 0) {
let max = Math.max(a, b);
let min = Math.min(a, b);
return Math.floor(Math.random() * (max - min) + min);
}
// ------------------------------------------------
loadSpriteByUrl(node, url, cb) {
cc.loader.load({ url }, (err, img) => {
if (!node) {
cb && cb();
}
const spriteFrame = new cc.SpriteFrame(img)
const spr = node.getComponent(cc.Sprite);
spr.spriteFrame = spriteFrame;
cb && cb();
});
}
currentPlayedAudioId;
stopCurrentPlayedAudio() {
if (this.currentPlayedAudioId !== null) {
cc.audioEngine.stop(this.currentPlayedAudioId);
this.currentPlayedAudioId = null;
}
}
playEffect(name, cb) {
this.stopCurrentPlayedAudio();
const audioNode = cc.find(`audios/${name}`);
const audioClip = audioNode.getComponent(cc.AudioSource).clip;
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
this.currentPlayedAudioId = audioId;
if (cb) {
cc.audioEngine.setFinishCallback(audioId, cb);
}
}
playAudioByUrl(audio_url, cb = null) {
if (!audio_url) {
if (cb) {
cb();
}
return;
}
this.stopCurrentPlayedAudio();
cc.assetManager.loadRemote(audio_url.toLowerCase(), (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
this.currentPlayedAudioId = audioId;
if (cb) {
cc.audioEngine.setFinishCallback(audioId, cb);
}
});
}
playLocalAudio(name) {
return new Promise((resolve, reject) => {
this.stopCurrentPlayedAudio();
const audioNode = cc.find(`res/${name}`, this.node);
if (!audioNode) {
resolve(null);
return;
}
const audioClip = audioNode.getComponent(cc.AudioSource).clip;
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
this.currentPlayedAudioId = audioId;
cc.audioEngine.setFinishCallback(audioId, () => {
resolve(null);
});
});
}
_timeoutIds = [];
_intervalIds = [];
// 生命周期
onDestroy() {
this._timeoutIds.forEach(id => {
clearTimeout(id);
});
this._intervalIds.forEach(id => {
clearInterval(id);
});
}
}
{
"ver": "1.0.8",
"uuid": "4d354824-df0d-4020-ab65-3afd85ca0064",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "00fa1703-9dbc-4184-9faf-7d3077c615fe",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "343540a1-2609-4367-b74f-cfa6d2e2cb6b",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "0a933136-2f52-4fa8-ae58-f0de6b381f41",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 2176,
"height": 1600,
"platformSettings": {},
"subMetas": {
"bg": {
"ver": "1.0.4",
"uuid": "f29707ed-4120-4cee-8b97-e7a7ed611557",
"rawTextureUuid": "0a933136-2f52-4fa8-ae58-f0de6b381f41",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 2176,
"height": 1600,
"rawWidth": 2176,
"rawHeight": 1600,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "34b18543-1119-458b-928b-969e7e48d0fd",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "a2433807-efd6-466a-a0a3-3ab3f0a5dbf6",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "point",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1568,
"height": 32,
"platformSettings": {},
"subMetas": {
"progress_bar": {
"ver": "1.0.4",
"uuid": "b435887d-bae1-49a8-bd0c-aeeeda4c6c73",
"rawTextureUuid": "a2433807-efd6-466a-a0a3-3ab3f0a5dbf6",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1568,
"height": 32,
"rawWidth": 1568,
"rawHeight": 32,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "cd5a4b74-7b02-4477-988a-744a7be97b61",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "point",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1578,
"height": 42,
"platformSettings": {},
"subMetas": {
"progress_bg": {
"ver": "1.0.4",
"uuid": "afa1a774-a1cf-4476-b01f-bdc83069f46c",
"rawTextureUuid": "cd5a4b74-7b02-4477-988a-744a7be97b61",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1578,
"height": 42,
"rawWidth": 1578,
"rawHeight": 42,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "37c4e6f0-5f20-4a83-8e31-321837bf1c40",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 280,
"height": 280,
"platformSettings": {},
"subMetas": {
"tx_01": {
"ver": "1.0.4",
"uuid": "61f66300-e031-447d-9107-251b09648d7a",
"rawTextureUuid": "37c4e6f0-5f20-4a83-8e31-321837bf1c40",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 280,
"height": 280,
"rawWidth": 280,
"rawHeight": 280,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ef6d8c0a-f5c5-42fa-b25d-dcd50f04a3e3",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 258,
"height": 258,
"platformSettings": {},
"subMetas": {
"tx_01zw": {
"ver": "1.0.4",
"uuid": "59b5cf19-b997-4572-b537-8b94f22b26bf",
"rawTextureUuid": "ef6d8c0a-f5c5-42fa-b25d-dcd50f04a3e3",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 258,
"height": 258,
"rawWidth": 258,
"rawHeight": 258,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "96aa5a20-e629-42ba-8e51-405e6ab04003",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 388,
"height": 388,
"platformSettings": {},
"subMetas": {
"tx_xuanzhong": {
"ver": "1.0.4",
"uuid": "922c0839-c8d1-4f42-936b-1be1d3bb6af5",
"rawTextureUuid": "96aa5a20-e629-42ba-8e51-405e6ab04003",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 388,
"height": 388,
"rawWidth": 388,
"rawHeight": 388,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "6370eb2e-2259-4bfb-9da6-6681b1bc5852",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
cc.Class({
extends: cc.Component,
properties: {
},
start() {
const BtnExit = cc.find('BtnFrame/BtnExit', this.node);
this.buttonOnClick(BtnExit, () => {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
if (middleLayerComponent.onClickExitBtn) {
middleLayerComponent.onClickExitBtn();
}
} else {
cc.director.getScene().destroy();
cc.audioEngine.stopAll();
if (window.courseware) {
window.courseware.freeAllOcMethod();
}
var bundle = cc.assetManager.bundles.find((obj) => {
return obj.getSceneInfo('debug_shell');
});
if (bundle) {
cc.director.loadScene("debug_shell", null, null, (err, scene) => { });
} else {
cc.director.loadScene("OXFORDCORE", null, null, (err, scene) => { });
}
}
});
const BtnPlayAgain = cc.find('BtnFrame/BtnPlayAgain', this.node);
this.buttonOnClick(BtnPlayAgain, () => {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
if (middleLayerComponent) {
middleLayerComponent.reloadBundle();
}
} else {
const sceneName = cc.director.getScene().name;
cc.director.getScene().destroy();
cc.audioEngine.stopAll();
if (window.courseware) {
window.courseware.freeAllOcMethod();
}
cc.director.loadScene(sceneName, null, null, (err, scene) => { });
}
});
},
buttonOnClick(button, callback, scale = 1.0) {
button.on('click', () => {
if (button['cantClick']) {
return;
}
button['cantClick'] = true;
cc.tween(button)
.to(0.1, { scale: scale * 1.1 })
.to(0.1, { scale: scale })
.call(() => {
button['cantClick'] = false;
callback && callback();
})
.start();
});
}
});
{
"ver": "1.0.8",
"uuid": "72d2fadf-ee6a-43f2-b21a-5a1087fde153",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "PlayerOffLineLayer",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 7
}
],
"_active": false,
"_components": [
{
"__id__": 20
},
{
"__id__": 21
}
],
"_prefab": {
"__id__": 22
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 2560,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
1280,
960,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 4
},
{
"__id__": 5
}
],
"_prefab": {
"__id__": 6
},
"_opacity": 100,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 2560,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 100,
"_originalHeight": 100,
"_id": ""
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "359db7a9-6c66-4325-a51f-831118e6405f"
},
"fileId": "a2lcBX6axJcYgWizPAwXJQ",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "BtnFrame",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 8
},
{
"__id__": 13
}
],
"_active": true,
"_components": [
{
"__id__": 18
}
],
"_prefab": {
"__id__": 19
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 684,
"height": 244
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
2,
2,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "BtnExit",
"_objFlags": 0,
"_parent": {
"__id__": 7
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 9
},
{
"__id__": 10
},
{
"__id__": 11
}
],
"_prefab": {
"__id__": 12
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 158,
"height": 60
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
150,
-50,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "2b5dd43a-655a-4ac5-8116-f646a0e03ef9"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 16,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 150,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "359db7a9-6c66-4325-a51f-831118e6405f"
},
"fileId": "2dFg2BRxNDIbzNQUJzInwD",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "BtnPlayAgain",
"_objFlags": 0,
"_parent": {
"__id__": 7
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 14
},
{
"__id__": 15
},
{
"__id__": 16
}
],
"_prefab": {
"__id__": 17
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 158,
"height": 60
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-150,
-50,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 13
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "627f41fc-5bc7-4455-bde4-d8192ec8c1cb"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 13
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 16,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": -150,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 13
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "359db7a9-6c66-4325-a51f-831118e6405f"
},
"fileId": "426YGeaQ1GSqxAl0es/FZ5",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 7
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "8cd35174-8a10-4be2-ae94-bb979d92c001"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "359db7a9-6c66-4325-a51f-831118e6405f"
},
"fileId": "1bsWjap9JK84XN2hkYfXDb",
"sync": false
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"alignMode": 2,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "72d2frf7mpD8rIaWhCH/eFT",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "359db7a9-6c66-4325-a51f-831118e6405f"
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "359db7a9-6c66-4325-a51f-831118e6405f",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "422eb759-9563-4d4a-a8c5-9825dfd985dc",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "cad89ca0-36b3-4714-94d2-d9ef3df6b4ba",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 158,
"height": 60,
"platformSettings": {},
"subMetas": {
"BtnExit": {
"ver": "1.0.4",
"uuid": "2b5dd43a-655a-4ac5-8116-f646a0e03ef9",
"rawTextureUuid": "cad89ca0-36b3-4714-94d2-d9ef3df6b4ba",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 158,
"height": 60,
"rawWidth": 158,
"rawHeight": 60,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "43b4e521-9123-4fb9-8d0f-3fe09b4bc3bd",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 684,
"height": 244,
"platformSettings": {},
"subMetas": {
"BtnFrame": {
"ver": "1.0.4",
"uuid": "8cd35174-8a10-4be2-ae94-bb979d92c001",
"rawTextureUuid": "43b4e521-9123-4fb9-8d0f-3fe09b4bc3bd",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 684,
"height": 244,
"rawWidth": 684,
"rawHeight": 244,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "a78958f5-493f-480c-ab6b-5b144fe67fe8",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 158,
"height": 60,
"platformSettings": {},
"subMetas": {
"BtnPlayAgain": {
"ver": "1.0.4",
"uuid": "627f41fc-5bc7-4455-bde4-d8192ec8c1cb",
"rawTextureUuid": "a78958f5-493f-480c-ab6b-5b144fe67fe8",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 158,
"height": 60,
"rawWidth": 158,
"rawHeight": 60,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
import { asyncDelay, onHomeworkFinish, RandomInt } from "../script/util"; import { asyncDelay, onHomeworkFinish, RandomInt } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import { GameServer } from "../network/Server";
import { NetworkHelper } from "../network/NetworkHelper";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -15,22 +17,255 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -15,22 +17,255 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initView(); this.initView();
} }
initData() { playerId;
isRoomOwner;
server: GameServer;
networkHelper: NetworkHelper;
loadingLayer: any;
_status: any;
async initData() {
this._status = {
round: 0,// 0: 未开始, 1: 回合1, 2: 回合2, 3: 已结束
boats: [],
};
for (let i = 0; i < 16; i++) {
this._status.boats.push({
show: false,
player1: '', // 'right', 'wrong', ''
player2: '',
});
}
this.networkHelper = new NetworkHelper();
this.loadingLayer = cc.find('Canvas/LoadingLayer').getComponent('OP_Boardgame_L3R4_LoadingLayer');
this.loadingLayer.setMaxPlayerNumber(2);
this.initNetworkListener();
do {
this.playerId = await this.networkHelper.init("OP_Boardgame_L3R4", 2);
if (this.playerId === null) {
console.log("onDestroy");
this.networkHelper.onDestroy();
}
console.log("this.playerId = " + this.playerId);
} while (this.playerId === null);
const room = this.networkHelper.room;
if (this.playerId == room.roomInfo.owner) {
console.log("房主");
this.isRoomOwner = true;
const serverParams = { testDuration: this.data.testDuration };
this.server = new GameServer(2, this.networkHelper, serverParams);
await this.networkHelper.startFrameSync();
this.server.addPlayer({
uuid: this.playerId,
isAI: false,
});
this.server.startMatch();
}
await this.initHeadImgAndName();
}
loadPlayerHeadImage() {
const player1 = cc.find("Canvas/bg/frame/headImg");
const player2 = cc.find("Canvas/bg/frame2/headImg");
this.allPlayerList.forEach((player) => {
this.getSpriteFrimeByUrl(player.headUrl, (sf) => {
if (player.color == "Red") {
player1.getComponent(cc.Sprite).spriteFrame = sf;
player1.width = 111;
player1.height = 111;
} else {
player2.getComponent(cc.Sprite).spriteFrame = sf;
player2.width = 111;
player2.height = 111;
}
});
});
}
allPlayerList: Array<any> = [];
initNetworkListener() {
this.networkHelper.on("playerJoin", (event) => {
if (this.server) {
this.server.onPlayerJoin({ data: { joinPlayerId: event.playerId } });
}
cc.log("playerJoin" + JSON.stringify(event));
});
this.networkHelper.on("playerLeave", (event) => {
cc.log("playerLeave" + JSON.stringify(event));
cc.find("Canvas/PlayerOffLineLayer").active = true;
this.networkHelper.leaveRoom();
});
this.networkHelper.on("playerOffLine", (event) => {
cc.find("Canvas/PlayerOffLineLayer").active = true;
this.networkHelper.leaveRoom();
this.log("playerOffLine" + JSON.stringify(event));
});
this.networkHelper.on("gameStart", (event) => { });
this.networkHelper.on("frameEvent", (event) => {
event.data.frame.items.forEach(async (item) => {
if (this.server) {
this.server.onFrameEvent(item.data);
}
if (item.data.type.startsWith('SERVER_')) {
console.log(`${item.data.type}: ${JSON.stringify(item.data)}`);
}
if (item.data.type == "SERVER_allPlayerInfo") {
item.data.playerData.forEach((player) => {
if (
!this.allPlayerList.find(
(listPlayer) => listPlayer.uuid == player.uuid
)
) {
this.allPlayerList.push({
uuid: player.uuid,
name: player.name,
color: player.color,
headUrl: player.headUrl,
});
}
this.loadPlayerHeadImage();
this.loadingLayer.addPlayer(
player.name,
player.uuid == this.playerId,
player.headUrl,
player.uuid
);
});
} else if (item.data.type == "SERVER_updateStatus") {
const serverStatus = JSON.parse(JSON.stringify(item.data.status));
serverStatus.boats.forEach((boat, index) => {
this._status.boats[index] = { ...boat };
});
if (this._status.round == 0 && serverStatus.round == 1) {
this._status.round = serverStatus.round;
this.initCountDown(this.onTimerFinish.bind(this));
this.initBoats();
} else if (this._status.round == 1 && serverStatus.round == 2) {
this._status.round = serverStatus.round;
this.initBoats();
} else {
this.updateBoats();
}
this.updateProgress();
} else if (item.data.type == "SERVER_playerWin") {
const playerMe = this.allPlayerList.find(
(player) => player.uuid == this.playerId
);
if (playerMe.color == this._status.current) {
this.showWin();
onHomeworkFinish({ isWin: true });
} else {
this.showLoss();
onHomeworkFinish({ isWin: false });
}
}
});
});
}
showWin() {
}
showLoss() {
} }
async initHeadImgAndName() {
const playerInfo: any = {
playerHeadUrl: "http://staging-teach.cdn.ireadabc.com/0751c28419a0e8ffb1f0e84435b081ce.png",
playerName: "test",
};
const middleLayer = cc.find("middleLayer");
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent("middleLayer");
if (middleLayerComponent.getUserInfo && middleLayerComponent.getHeadUrl) {
const kidInfo = await middleLayerComponent.getUserInfo();
const playerHeadUrl = middleLayerComponent.getHeadUrl(kidInfo.avatar_url || kidInfo.id);
playerInfo.playerHeadUrl = playerHeadUrl;
playerInfo.playerName = kidInfo.nick_name || '拼读达人';
}
}
this.networkHelper.sendFrame({
type: "playerInfo",
playerId: this.playerId,
playerName: playerInfo.playerName,
playerHeadUrl: playerInfo.playerHeadUrl,
});
}
async initView() { async initView() {
this.initProgress(); this.initProgress();
this.initBubbles(); this.initBubbles();
this.initCountDown(); this.initLoadingLayer();
this.initBoats(); }
await this.startTest(0);
initLoadingLayer() {
const LoadingLayer = cc.find('Canvas/LoadingLayer');
LoadingLayer.active = true;
}
onTimerFinish() {
} }
async startTest(idx: number) {
async startQuestion(idx: number) {
this.showTestFrame(); this.showTestFrame();
this.showTestImage(idx); this.showTestImage(idx);
this.testCountDown(); const words = [
await this.coolCatSay(this.data.startAudio); 'toad', 'new', 'coat', 'boot',
'yellow', 'fruit', 'cube', 'window',
'moon', 'zoo', 'elbow', 'bow',
'suit', 'boat', 'blue', 'goat'
];
this.startTest(words[idx]);
this.coolCatSay(this.data.startAudio);
await this.testCountDown(this.data.testDuration);
const score = await this.stopTest();
if (score > 80) {
await this.showGoodJob();
this.networkHelper.sendFrame({
type: "right",
playerId: this.playerId,
boatIdx: idx
});
} else {
await this.showNiceTry();
this.networkHelper.sendFrame({
type: "wrong",
playerId: this.playerId,
boatIdx: idx
});
}
this.hideTestFrame();
}
startTest(word) {
(<any>window).courseware?.startTest(word);
}
stopTest() {
return new Promise<number>((resolve, reject) => {
if ((<any>window).courseware) {
(<any>window).courseware.stopTest((res) => {
if (typeof (res) == 'string') {
resolve(parseInt(JSON.parse(res).result.overall));
} else {
resolve(parseInt(res.result.overall));
}
});
} else {
resolve(Math.random() > 0.5 ? 100 : 0);
} }
});
}
showTestImage(idx: number) { showTestImage(idx: number) {
const img = cc.find(`images/img_${idx}`); const img = cc.find(`images/img_${idx}`);
const testImg = cc.find('Canvas/testBg/img_bg/img'); const testImg = cc.find('Canvas/testBg/img_bg/img');
...@@ -67,8 +302,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -67,8 +302,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}); });
} }
testCountDown(time = 5) { async testCountDown(time = 5) {
console.log('testCountDown'); return new Promise((resolve) => {
const countDown = cc.find('Canvas/testBg/clock/countDown'); const countDown = cc.find('Canvas/testBg/clock/countDown');
const countDownComponent = countDown.getComponent(cc.Sprite); const countDownComponent = countDown.getComponent(cc.Sprite);
cc.tween(countDown) cc.tween(countDown)
...@@ -79,12 +314,14 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -79,12 +314,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
.set({ fillRange: 1 }) .set({ fillRange: 1 })
.to(time, { fillRange: 0 }) .to(time, { fillRange: 0 })
.call(() => { .call(() => {
this.showGoodJob(); resolve(null);
}) })
.start(); .start();
});
} }
showGoodJob() { showGoodJob() {
return new Promise((resolve) => {
const result = cc.find('Canvas/testBg/result'); const result = cc.find('Canvas/testBg/result');
result.active = true; result.active = true;
const goodjob = cc.find('Canvas/testBg/result/goodjob'); const goodjob = cc.find('Canvas/testBg/result/goodjob');
...@@ -96,12 +333,16 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -96,12 +333,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc.tween(bg) cc.tween(bg)
.by(0.5, { angle: 90 }) .by(0.5, { angle: 90 })
.call(() => { .call(() => {
result.active = false;
goodjob.active = false;
}) })
.call(resolve)
.start(); .start();
});
} }
showNiceTry() { showNiceTry() {
return new Promise((resolve) => {
const result = cc.find('Canvas/testBg/result'); const result = cc.find('Canvas/testBg/result');
result.active = true; result.active = true;
const goodjob = cc.find('Canvas/testBg/result/goodjob'); const goodjob = cc.find('Canvas/testBg/result/goodjob');
...@@ -111,41 +352,192 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -111,41 +352,192 @@ export default class SceneComponent extends MyCocosSceneComponent {
const bg = cc.find('Canvas/testBg/result/bg'); const bg = cc.find('Canvas/testBg/result/bg');
bg.stopAllActions(); bg.stopAllActions();
cc.tween(bg) cc.tween(bg)
.by(2, { angle: 360 }) .by(0.5, { angle: 90 })
.repeatForever() .call(() => {
result.active = false;
niceTry.active = false;
})
.call(resolve)
.start(); .start();
});
} }
initBoats() { initBoats() {
let idxList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
const boatList = idxList
.sort(() => Math.random() - 0.5)
.splice(0, 8);
for (let i = 0; i < 16; i++) { for (let i = 0; i < 16; i++) {
const boatNode = cc.find(`Canvas/bg/boats/boat_${i}`); const boatNode = cc.find(`Canvas/bg/boats/boat_${i}`);
boatNode.removeComponent(cc.Sprite); boatNode.removeComponent(cc.Sprite);
if (boatList.indexOf(i) > -1) { boatNode.removeAllChildren();
if (this._status.boats[i].show) {
const boat = cc.instantiate(cc.find('boat')); const boat = cc.instantiate(cc.find('boat'));
boat.parent = boatNode; boat.parent = boatNode;
boat.name = 'boat';
boat.setPosition(0, 0); boat.setPosition(0, 0);
const image = cc.find(`images/img_${i}`); const image = cc.find(`images/img_${i}`);
const icon = boat.getChildByName('icon'); const icon = boat.getChildByName('icon');
icon.getComponent(cc.Sprite).spriteFrame = image.getComponent(cc.Sprite).spriteFrame; icon.getComponent(cc.Sprite).spriteFrame = image.getComponent(cc.Sprite).spriteFrame;
const btn = boat.getChildByName('btn');
btn.on('click', () => {
this.startQuestion(i);
});
} }
} }
} }
initCountDown() { updateBoats() {
const progressTopBar = cc.find('Canvas/bg/progressTop/progressTopBar'); for (let i = 0; i < 16; i++) {
const spriteComponent = progressTopBar.getComponent(cc.Sprite); const boat = cc.find(`Canvas/bg/boats/boat_${i}/boat`);
cc.tween(spriteComponent) const boatData = this._status.boats[i];
.to(20, { fillRange: 0 }) if (boatData.show) {
if (boatData[this.playerId] == 'wrong') {
boat.active = true;
const lock = boat.getChildByName('lock');
lock.active = true;
const btn = boat.getChildByName('btn');
btn.active = false;
const phone = boat.getChildByName('phone');
phone.active = false;
} else if (boatData[this.playerId] == 'right') {
const btn = boat.getChildByName('btn');
btn.active = false;
const phone = boat.getChildByName('phone');
phone.active = false;
if (boat.active == true && !boat['tween']) {
boat['tween'] = cc.tween(boat)
.to(0.5, { scale: 2, opacity: 0 })
.call(() => { .call(() => {
boat.active = false;
boat['tween'] = null;
})
.start();
}
}
} else {
if (boat) {
boat.active = false;
}
}
}
}
updateProgress() {
let leftRightNumber = 0;
let leftWrongNumber = 0;
let rightRightNumber = 0;
let rightWrongNumber = 0;
for (let i = 0; i < 16; i++) {
const boatData = this._status.boats[i];
if (boatData[this.playerId] == 'right') {
if (this.isRoomOwner) {
leftRightNumber++;
} else {
rightRightNumber++;
}
} else if (boatData[this.playerId] == 'wrong') {
if (this.isRoomOwner) {
leftWrongNumber++;
} else {
rightWrongNumber++;
}
}
Object.keys(boatData)
.filter((key) => key != this.playerId)
.filter((key) => key != 'show')
.forEach((key) => {
if (boatData[key] == 'right') {
if (this.isRoomOwner) {
rightRightNumber++;
} else {
leftRightNumber++;
}
} else if (boatData[key] == 'wrong') {
if (this.isRoomOwner) {
rightWrongNumber++;
} else {
leftWrongNumber++;
}
}
});
}
let shakeLeft = false;
let shakeRight = false;
for (let i = 0; i < 16; i++) {
const box = cc.find(`Canvas/bg/progress/layout/box_${i}`);
const lock = box.getChildByName('lock');
if (15 - i < leftWrongNumber) {
if (lock.active == false) {
lock.active = true;
shakeLeft = true;
}
}
if (i < leftRightNumber) {
if (!box['changeColor']) {
this.changeNodeColor(box);
box['changeColor'] = true;
shakeLeft = true;
}
} else {
this.changeNodeGray(box);
}
}
for (let i = 0; i < 16; i++) {
const box = cc.find(`Canvas/bg/progress2/layout/box_${i}`);
box.setPosition(2.5, 0);
const lock = box.getChildByName('lock');
if (15 - i < rightWrongNumber) {
if (lock.active == false) {
lock.active = true;
shakeRight = true;
}
}
if (i < rightRightNumber) {
if (!box['changeColor']) {
this.changeNodeColor(box);
box['changeColor'] = true;
shakeRight = true;
}
} else {
this.changeNodeGray(box);
}
}
if (shakeLeft) {
this.shakeProgress('Left');
}
if (shakeRight) {
this.shakeProgress('Right');
}
}
shakeProgress(side: string) {
let node;
let sideNumber = 1;
if (side == 'Left') {
node = cc.find('Canvas/bg/progress');
} else {
node = cc.find('Canvas/bg/progress2');
sideNumber = -1;
}
if (node['tween']) {
return;
}
node['tween'] = cc.tween(node)
.to(0.1, { scaleY: 1.05, scaleX: 1.05 * sideNumber })
.to(0.1, { scaleY: 1.00, scaleX: 1.00 * sideNumber })
.call(() => {
node['tween'] = null;
}) })
.start(); .start();
} }
initCountDown(callback: Function) {
const progressTopBar = cc.find('Canvas/bg/progressTop/progressTopBar');
const spriteComponent = progressTopBar.getComponent(cc.Sprite);
cc.tween(spriteComponent)
.to(this.data.roundTime, { fillRange: 0 })
.call(callback)
.start();
}
initProgress() { initProgress() {
const layoutLeft = cc.find('Canvas/bg/progress/layout'); const layoutLeft = cc.find('Canvas/bg/progress/layout');
for (let i = 0; i < 16; i++) { for (let i = 0; i < 16; i++) {
...@@ -153,11 +545,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -153,11 +545,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
box.setPosition(2.5, 0); box.setPosition(2.5, 0);
box.parent = layoutLeft; box.parent = layoutLeft;
box.name = `box_${i}`; box.name = `box_${i}`;
if (i < 4) {
this.changeNodeColor(box);
} else {
this.changeNodeGray(box); this.changeNodeGray(box);
} // this.changeNodeColor(box);
} }
const layoutRight = cc.find('Canvas/bg/progress2/layout'); const layoutRight = cc.find('Canvas/bg/progress2/layout');
for (let i = 0; i < 16; i++) { for (let i = 0; i < 16; i++) {
...@@ -165,6 +554,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -165,6 +554,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
box.setPosition(2.5, 0); box.setPosition(2.5, 0);
box.parent = layoutRight; box.parent = layoutRight;
box.name = `box_${i}`; box.name = `box_${i}`;
this.changeNodeGray(box);
} }
} }
......
export const defaultData = { export const defaultData = {
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png", roundTime: 80,
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png", testDuration: 5,
"text": "This is a test label.",
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3"
} }
\ No newline at end of file
...@@ -94,13 +94,13 @@ export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) { ...@@ -94,13 +94,13 @@ export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) {
} }
} }
export function getDistance (start, end){ export function getDistance(start, end) {
var pos = cc.v2(start.x - end.x, start.y - end.y); var pos = cc.v2(start.x - end.x, start.y - end.y);
var dis = Math.sqrt(pos.x*pos.x + pos.y*pos.y); var dis = Math.sqrt(pos.x * pos.x + pos.y * pos.y);
return dis; return dis;
} }
export function playAudioByUrl(audio_url, cb=null) { export function playAudioByUrl(audio_url, cb = null) {
if (audio_url) { if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => { cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8); const audioId = cc.audioEngine.play(audioClip, false, 0.8);
...@@ -114,21 +114,21 @@ export function playAudioByUrl(audio_url, cb=null) { ...@@ -114,21 +114,21 @@ export function playAudioByUrl(audio_url, cb=null) {
} }
export function btnClickAnima(btn, time=0.15, rate=1.05) { export function btnClickAnima(btn, time = 0.15, rate = 1.05) {
btn.tmpScale = btn.scale; btn.tmpScale = btn.scale;
btn.on(cc.Node.EventType.TOUCH_START, () => { btn.on(cc.Node.EventType.TOUCH_START, () => {
cc.tween(btn) cc.tween(btn)
.to(time / 2, {scale: btn.scale * rate}) .to(time / 2, { scale: btn.scale * rate })
.start() .start()
}) })
btn.on(cc.Node.EventType.TOUCH_CANCEL, () => { btn.on(cc.Node.EventType.TOUCH_CANCEL, () => {
cc.tween(btn) cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale}) .to(time / 2, { scale: btn.tmpScale })
.start() .start()
}) })
btn.on(cc.Node.EventType.TOUCH_END, () => { btn.on(cc.Node.EventType.TOUCH_END, () => {
cc.tween(btn) cc.tween(btn)
.to(time / 2, {scale: btn.tmpScale}) .to(time / 2, { scale: btn.tmpScale })
.start() .start()
}) })
} }
...@@ -179,7 +179,7 @@ export async function asyncDelay(time) { ...@@ -179,7 +179,7 @@ export async function asyncDelay(time) {
try { try {
cc.tween(cc.find('Canvas')) cc.tween(cc.find('Canvas'))
.delay(time) .delay(time)
.call(()=>{ .call(() => {
resolve(null); resolve(null);
}) })
.start(); .start();
...@@ -444,7 +444,7 @@ export function httpHeadCall(requsetUrl: string, callback) { ...@@ -444,7 +444,7 @@ export function httpHeadCall(requsetUrl: string, callback) {
} }
} }
export function onHomeworkFinish(data = "", callback = ()=>{}) { export function onHomeworkFinish(data: any = "", callback = () => { }) {
const middleLayer = cc.find('middleLayer'); const middleLayer = cc.find('middleLayer');
if (middleLayer) { if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer'); const middleLayerComponent = middleLayer.getComponent('middleLayer');
...@@ -464,3 +464,21 @@ export function callMiddleLayerFunction(apiName: string, data: any, callback: Fu ...@@ -464,3 +464,21 @@ export function callMiddleLayerFunction(apiName: string, data: any, callback: Fu
} }
} }
export async function asyncPlayDragonBoneAnimation(node, animationName, time = 1, onFrameEvent = null) {
return new Promise((resolve, reject) => {
node.getComponent(dragonBones.ArmatureDisplay)
.once(dragonBones.EventObject.COMPLETE, () => {
resolve(null);
});
node.getComponent(dragonBones.ArmatureDisplay)
.on(dragonBones.EventObject.FRAME_EVENT, ({ name }) => {
if (onFrameEvent && typeof (onFrameEvent) == 'function') {
onFrameEvent(name);
}
});
node.getComponent(dragonBones.ArmatureDisplay)
.playAnimation(animationName, time);
});
}
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 130, "width": 259,
"height": 263, "height": 259,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"clock_red": { "clock_red": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment