Commit f372b74b authored by 李维's avatar 李维

布局

parent 9f5f5457
No preview for this file type
{
"ver": "1.1.2",
"uuid": "a053204f-0fdd-431e-a2fb-808d5ca1ba8b",
"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": "aeab1a70-df7c-4379-9b09-bb4ef2f52517",
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "a972153c-c013-43d2-9a66-bcf8c0c7eae3",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": true,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "b70655f1-9593-4417-8dff-a0ac5f8a7515",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "25c82642-03fe-4266-8eb6-0890808fb93c",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
endLayer: null,
bg: null,
labelLoss: null,
labelWin: null,
start() {
this.endLayer = cc.find("EndLayer", this.node);
this.bg = cc.find("bg", this.endLayer);
this.labelLoss = cc.find("labelBg/labelLoss", this.endLayer);
this.labelWin = cc.find("labelBg/labelWin", this.endLayer);
},
showWin() {
this.endLayer.active = true;
cc.tween(this.bg).to(1, { opacity: 100 }).start();
labelLoss.active = false;
},
showLoss() {
this.endLayer.active = true;
cc.tween(this.bg).to(1, { opacity: 100 }).start();
labelWin.active = false;
},
// update (dt) {},
});
{
"ver": "1.0.8",
"uuid": "1f28bc36-5c01-40b2-b472-14d7a01e5c79",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "ac2c4d1b-8cc7-456e-8534-b2ec285f52d7",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "e453dc25-0330-42ed-9230-a2ccf84365dd",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"uuid": "711de3c1-ea7d-4b8d-b328-75c0cdce3297",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 61,
"height": 67,
"width": 2176,
"height": 485,
"platformSettings": {},
"subMetas": {
"btn_left": {
"bg": {
"ver": "1.0.4",
"uuid": "ce19457d-e8f3-4c38-ae3e-d4b99208ddb5",
"rawTextureUuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"uuid": "b64eecab-8092-4151-8ffb-75e8535fd4e2",
"rawTextureUuid": "711de3c1-ea7d-4b8d-b328-75c0cdce3297",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -22,10 +22,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 61,
"height": 67,
"rawWidth": 61,
"rawHeight": 67,
"width": 2176,
"height": 485,
"rawWidth": 2176,
"rawHeight": 485,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "aab78ada-5abe-4e86-ae69-9831d668ee68",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 2176,
"height": 1600,
"platformSettings": {},
"subMetas": {
"labelLoss": {
"ver": "1.0.4",
"uuid": "393f65e2-48ab-47f3-9f82-77cc15064688",
"rawTextureUuid": "aab78ada-5abe-4e86-ae69-9831d668ee68",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 12.5,
"offsetY": 109.5,
"trimX": 702,
"trimY": 592,
"width": 797,
"height": 197,
"rawWidth": 2176,
"rawHeight": 1600,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "b74e69d9-3cd2-42a6-90e9-27d8e57e2317",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 2176,
"height": 1600,
"platformSettings": {},
"subMetas": {
"labelWin": {
"ver": "1.0.4",
"uuid": "da9fcad7-1d93-4ead-b2ba-67090c270f76",
"rawTextureUuid": "b74e69d9-3cd2-42a6-90e9-27d8e57e2317",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 24.5,
"offsetY": 106.5,
"trimX": 730,
"trimY": 600,
"width": 765,
"height": 187,
"rawWidth": 2176,
"rawHeight": 1600,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "2aa56c60-2c7e-4f98-b567-ee24c12022e6",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "53251e61-3774-486f-807f-096e04b8db0c",
"optimizationPolicy": "AUTO",
"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 L2_boardgame2_treeSceneComponent 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": "39b9cad2-ee1f-4483-97e1-527941fdbd0f",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "0dc630b5-6bbb-40f6-a62b-286d5191f848",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "9e05c621-428f-40b4-915b-68430466d0da",
"downloadMode": 0,
"duration": 3.474286,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "6257561b-5edb-4f2f-b00e-ddd666ba5b44",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "cc649d19-13b2-481d-871a-a602e4f079a3",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"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": "39e40c57-b3c1-4137-a02b-eba4af316eb5",
"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": "993aad57-8b04-4221-9fa7-252444eb1d22",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "8c5e5572-ee59-48e0-8854-3e2eaeb3e887",
"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": "e2937a19-1577-4967-86a9-55dc9b64e409",
"rawTextureUuid": "8c5e5572-ee59-48e0-8854-3e2eaeb3e887",
"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": "65f5b1ca-d7f0-495f-a280-b996ee207aac",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "53278398-c9bb-46e6-858f-e4dd921c4885",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "e0596b40-c8f3-48ce-b583-54dde7ab2d7f",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "5bcd2bb9-a185-4a59-8785-0bf378bc7ee1",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e88eaf54-dcef-4f4b-bb62-e2d6ab0e7b41",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 2176,
"height": 1600,
"platformSettings": {},
"subMetas": {
"bg": {
"ver": "1.0.4",
"uuid": "99d96ba8-5c2e-4c87-aebd-f4af06eea4e5",
"rawTextureUuid": "e88eaf54-dcef-4f4b-bb62-e2d6ab0e7b41",
"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": "2.3.5",
"uuid": "925bb6fe-8e03-4b7d-a445-2f1181ecf72b",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 1568,
"height": 32,
"platformSettings": {},
"subMetas": {
"progress_bar": {
"ver": "1.0.4",
"uuid": "00f50aa6-6e2d-49bf-9818-b8df63326038",
"rawTextureUuid": "925bb6fe-8e03-4b7d-a445-2f1181ecf72b",
"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": "33c069c8-4e3e-4933-b7a1-9845224ccfab",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 1578,
"height": 42,
"platformSettings": {},
"subMetas": {
"progress_bg": {
"ver": "1.0.4",
"uuid": "0d6f89ef-1875-4a72-b1cc-1d719029dde9",
"rawTextureUuid": "33c069c8-4e3e-4933-b7a1-9845224ccfab",
"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": "073548ae-16d4-4217-a368-4959a266c4b4",
"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": "4d2b6d9e-145f-484b-bb01-0ea534602b67",
"rawTextureUuid": "073548ae-16d4-4217-a368-4959a266c4b4",
"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": "bba99ade-8113-421b-be34-c3a010862234",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 258,
"height": 258,
"platformSettings": {},
"subMetas": {
"tx_01zw": {
"ver": "1.0.4",
"uuid": "c55d14e6-554c-4ed7-a4e3-9b472bdbc5eb",
"rawTextureUuid": "bba99ade-8113-421b-be34-c3a010862234",
"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": "4e0e6c6b-992d-40b5-8604-96fa246cfb9c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 388,
"height": 388,
"platformSettings": {},
"subMetas": {
"tx_xuanzhong": {
"ver": "1.0.4",
"uuid": "b1fe6c96-ed10-4b64-a61b-34e3317de828",
"rawTextureUuid": "4e0e6c6b-992d-40b5-8604-96fa246cfb9c",
"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": "38fd0db8-d3cc-4f72-ba4b-8ff5cf1fc0ad",
"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) => { });
}
});
},
show() {
this.node.active = true;
},
hide() {
this.node.active = false;
},
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": "6637d58d-bf3a-42e0-b800-916feafdc3b3",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "cbd2fc08-1191-416a-9a19-07c4b03237f0",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "baf6dc35-9fc9-4a52-aee2-b640579cbeb6",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "f6949689-319c-479a-ad0f-5e66d3ab6212",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 158,
"height": 60,
"platformSettings": {},
"subMetas": {
"BtnExit": {
"ver": "1.0.4",
"uuid": "017c5ed0-31c1-4998-93b6-387dab90c6b3",
"rawTextureUuid": "f6949689-319c-479a-ad0f-5e66d3ab6212",
"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": "a85ec218-5341-4c8d-bfb1-3a940962fe5c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 684,
"height": 244,
"platformSettings": {},
"subMetas": {
"BtnFrame": {
"ver": "1.0.4",
"uuid": "24ac926d-04db-4aac-b588-d6f108ae46a2",
"rawTextureUuid": "a85ec218-5341-4c8d-bfb1-3a940962fe5c",
"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": "08d46bc2-bc85-42c0-b274-1188baba6578",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 158,
"height": 60,
"platformSettings": {},
"subMetas": {
"BtnPlayAgain": {
"ver": "1.0.4",
"uuid": "a41c052e-06da-4770-8873-06a6402e1e48",
"rawTextureUuid": "08d46bc2-bc85-42c0-b274-1188baba6578",
"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 diff is collapsed.
import {
asyncDelay,
asyncPlayDragonBoneAnimation,
asyncTweenTo,
onHomeworkFinish,
RandomInt,
} from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import { NetworkHelper } from "../script/NetworkHelper";
import { GameServer } from "../script/Server";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
@property(cc.Prefab)
loadingLayerPrefab = null; // 等待其他小伙伴加入页面
@property(cc.Prefab)
playerOffLineLayerPrefab = null; // 其他人掉线页面
@property(cc.Prefab)
endLayerPrefab = null; // 结束页面
server: GameServer;
networkHelper: NetworkHelper;
playerId; // 当前玩家ID
isRoomOwner; // 是否为房主
recordWaitCount; // 录音等待倒计时
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
// this._imageResList.push({ url: this.data.pic_url });
// this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源
// this._audioResList.push({ url: this.data.audio_url });
}
addPreloadAnima() {}
onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData();
this.initView();
this.initListener();
}
// 初始化数据
async initData() {
this.networkHelper = new NetworkHelper();
this.initNetworkListener();
do {
this.playerId = await this.networkHelper.init("l2_boardgame2_tree", 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;
this.server = new GameServer(2, this.networkHelper);
// this.server.jumpList = this.getJumpList();
await this.networkHelper.startFrameSync();
this.server.addPlayer({
uuid: this.playerId,
isAI: false,
});
this.server.startMatch();
}
await this.initHeadImgAndName();
this.recordWaitCount = 0;
}
// 获取用户头像
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,
});
}
// 把卡片数据附加到节点上
addComponents() {
// cc.find('Canvas/bg/chessBoard/boardItems').children.forEach(node => {
// let itemData = node.getComponent("BoardGame2_ItemData");
// if (!itemData) {
// itemData = node.addComponent('BoardGame2_ItemData');
// let name = node.name;
// console.log(name);
// if (name == 'start' || name == 'end') {
// } else {
// let arr = name.split('_');
// itemData.letter = arr[1];
// itemData.idx = Number(arr[0]);
// itemData.word = arr[1];
// itemData.jump = 0;
// }
// }
// });
}
initView() {
// 初始化界面
this.initLoadingLayer();
this.initOfflineLayer();
}
// update (dt) {},
initListener() {
// 初始化时间监听
}
playLocalAudio(audioName) {
const audio = cc
.find(`Canvas/res/audio/${audioName}`)
.getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
});
}
// 等待游戏开始加入
loadingLayer;
initLoadingLayer() {
cc.log("[Function]initLoadingLayer");
const loadingLayerBase = cc.find("Canvas/loadingLayerBase");
const loadingLayerNode = cc.instantiate(this.loadingLayerPrefab);
loadingLayerBase.addChild(loadingLayerNode);
this.loadingLayer = loadingLayerNode.getComponent("LoadingLayer");
this.loadingLayer.setMaxPlayerNumber(2);
this.loadingLayer.onLoadFinished(() => {});
}
// 初始化掉线提示组件
offlineLayer;
initOfflineLayer() {
cc.log("[Function]initOfflineLayer");
const offlineLayerBase = cc.find("Canvas/offlineLayerBase");
const offlineLayerNode = cc.instantiate(this.playerOffLineLayerPrefab);
offlineLayerBase.addChild(offlineLayerNode);
this.offlineLayer = offlineLayerNode.getComponent("PlayerOffLineLayer");
}
// 异步游戏核心事件控制
allPlayerList;
initNetworkListener() {
this.networkHelper.on("playerJoin", (event) => {
if (this.server) {
this.server.onPlayerJoin({ data: { joinPlayerId: event.playerId } });
}
console.log("playerJoin");
});
this.networkHelper.on("playerLeave", (event) => {
cc.log("playerLeave" + JSON.stringify(event));
this.offlineLayer.show();
this.networkHelper.leaveRoom();
});
this.networkHelper.on("playerOffLine", (event) => {
cc.log("playerOffLine" + JSON.stringify(event));
this.offlineLayer.show();
this.networkHelper.leaveRoom();
});
this.networkHelper.on("gameStart", (event) => {});
this.networkHelper.on("frameEvent", (event) => {
cc.log("Frame event");
event.data.frame.items.forEach(async (item) => {
if (this.server) {
this.server.onFrameEvent(item.data);
}
if (item.data.type == "SERVER_allPlayerInfo") {
cc.log(
"SERVER_allPlayerInfo: " + JSON.stringify(item.data.playerData)
);
item.data.playerData.forEach((player) => {
// 如果所有玩家列表为空 则初始化
if (!this.allPlayerList) {
this.allPlayerList = [];
}
// 若果当前用户第一次进入房间 则存储用户信息
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") {
cc.log("SERVER_updateStatus", item.data);
} else if (item.data.type == "SERVER_playerRoll") {
cc.log("SERVER_playerRoll", item.data);
} else if (item.data.type == "SERVER_playerRight") {
cc.log("SERVER_playerRight");
} else if (item.data.type == "SERVER_playerWrong") {
cc.log("SERVER_playerWrong");
}
});
});
}
}
import { NetworkHelper } from "./NetworkHelper";
import { asyncDelay } from "./util";
export class AI {
networkHelper: NetworkHelper;
playerData: any;
_status = {
Red: 0,
Blue: 0,
letter: "",
current: "Red",
};
constructor(networkHelper: NetworkHelper, playerData: any) {
this.networkHelper = networkHelper;
this.playerData = playerData;
}
async onFrameEvent(event) {
console.log("AI get event: " + JSON.stringify(event));
if (event.type == "SERVER_updateStatus") {
this._status = JSON.parse(JSON.stringify(event.status));
} else if (event.type == "SERVER_playerRoll") {
//玩家需要转盘,待转完之后 进行后续动作
this._status.letter = event.letter;
if (this.playerData.color == this._status.current) {
//TODO:正常8 调试加速 减少AI等待时间
await asyncDelay(4);
}
} else if (event.type == "SERVER_playerRight") {
this._status.letter = "";
this._status[event.color] = event.idx;
this.changeSide();
} else if (event.type == "SERVER_playerWrong") {
this._status.letter = "";
this.changeSide();
}
if (this.playerData.color == this._status.current) {
if (this._status.letter == "") {
//TODO:调试加速 2 Math.random() * 3 + 2
await asyncDelay(Math.random() * 3 + 2);
this.networkHelper.sendFrame({
type: "roll",
uuid: this.playerData.uuid,
});
} else {
//调试加速 2 Math.random() * 3 + 4
await asyncDelay(Math.random() * 1 + 10);
const idx = this.getNextRightIdx();
if (Math.random() < 0.75) {
this.networkHelper.sendFrame({
type: "right",
idx: idx,
uuid: this.playerData.uuid,
color: this.playerData.color,
});
} else {
this.networkHelper.sendFrame({
type: "wrong",
uuid: this.playerData.uuid,
color: this.playerData.color,
});
}
}
}
}
changeSide() {
if (this._status.current == "Red") {
this._status.current = "Blue";
} else {
this._status.current = "Red";
}
}
getNextRightIdx() {
const board = cc.find("Canvas/bg/chessBoard/boardItems");
const startIdx = this._status[this._status.current];
for (let i = startIdx + 1; i < board.children.length; i++) {
const targetNode = board.children[i];
const itemData = targetNode.getComponent("BoardGame2_ItemData");
if (itemData.letter.toLowerCase() == this._status.letter.toLowerCase()) {
return i;
}
}
return -1;
}
}
{
"ver": "1.0.8",
"uuid": "4af674d8-d8fb-404c-95bf-f6c712d953af",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const { ccclass, property } = cc._decorator;
@ccclass
export default class l2_boardgame2_tree_ItemData extends cc.Component {
@property
letter: string = '';
@property
idx: string = '';
@property
word: string = '';
@property
jump: string = ''
}
{
"ver": "1.0.8",
"uuid": "31b40a11-e4ad-497e-93cc-7a641a4e5d46",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -52,17 +52,35 @@ export class MyCocosSceneComponent extends cc.Component {
// 生命周期 start
start() {
if (window && (<any>window).courseware && (<any>window).courseware.getData) {
(<any>window).courseware.getData((data) => {
this.log('data:' + data);
this.data = data || this.getDefaultData();
this.data = JSON.parse(JSON.stringify(this.data));
this.preloadItem();
})
} else {
this.data = this.getDefaultData();
this.preloadItem();
let getData = this.getData.bind(this);
if (window && (<any>window).courseware) {
getData = (<any>window).courseware.getData;
}
getData((data) => {
console.log('data:', data);
this.data = data || this.getDefaultData();
this.data = JSON.parse(JSON.stringify(this.data))
this.preloadItem()
// courseInScreen
// scene.distroy() courseOutScreen
})
}
getData(func) {
if (window && (<any>window).courseware) {
(<any>window).courseware.getData(func, 'scene');
return;
}
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.getData(func);
return;
}
func(this.getDefaultData());
}
getDefaultData() {
......@@ -87,7 +105,7 @@ export class MyCocosSceneComponent extends cc.Component {
preload() {
const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList);
cc.assetManager.loadAny(preloadArr, null, null, (err, data) => {
cc.assetManager.preloadAny(preloadArr, null, null, (err, data) => {
if (window && window["air"]) {
// window["air"].onCourseInScreen = (next) => {
......@@ -105,17 +123,17 @@ export class MyCocosSceneComponent extends cc.Component {
});
}
log (str) {
log(str) {
const node = cc.find('middleLayer');
if(node){
if (node) {
node.getComponent('middleLayer').log(str);
}else{
} else {
cc.log(str);
}
}
onLoadEnd() {
}
......@@ -132,7 +150,7 @@ export class MyCocosSceneComponent extends cc.Component {
// ------------------------------------------------
getSprNode(resName) {
const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame;
......@@ -163,17 +181,23 @@ export class MyCocosSceneComponent extends cc.Component {
}
playAudioByUrl(audio_url, cb = null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
return new Promise((resolve, reject) => {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
resolve(audioId);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
});
} else {
resolve(0);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
cb();
}
});
}else{
cb && cb();
}
}
});
}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "cc864208-d315-4539-a726-ba0ea371226c",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "ca90bd07-7e6b-4942-b4f2-8f0c0304a843",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
export const defaultData = {
gameStartAudio:
"",
gameLoadingAudio:
"",
waitingWheel:
"",
waitingPiece:
"",
waitingTurn:
"",
recordWait: "http://staging-teach.cdn.ireadabc.com/31952573236dd316a8ee1672d1614a1c.mp3"
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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