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 diff is collapsed.
{
"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
{
"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
{
"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
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
This diff is collapsed.
...@@ -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