| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import PIFS from "../../PIFS";
- import MatchView from "../../Views/MatchView";
- import { JCMGO } from "../Core/JCMGO"
- export default class SocketPlayer extends JCMGO.SocketClient {
- public static quicklyMatch = false;
- constructor() {
- super();
- // this.connect("ws://192.168.101.3:10086/JCMiniGameOnline?gameId=test");
- this.connect("wss://www.9527fun.cn/JCMiniGameOnline?gameId=电锯惊魂");
- }
- protected onLoad() {
- console.warn("onLoad");
- this.requestMatchRoom();
- }
- protected onReload() {
- console.warn("onReload");
- }
- protected onDestroy() {
- console.warn("onDestroy");
- }
- protected onMiss() {
- console.warn("onMiss");
- }
- protected onRoomAddPlayer(e: JCMGO.BroadcastEvent<JCMGO.RoomAddPlayerBst>): void {
- window.gameSystem.onRoomAddPlayer(e.data);
- }
- protected onRoomRemovePlayer(e: JCMGO.BroadcastEvent<JCMGO.RoomRemovePlayerBst>): void {
- window.gameSystem.onRoomRemovePlayer(e.data);
- }
- protected onRoomEndMatching(e: JCMGO.BroadcastEvent<JCMGO.RoomEndMatchingBst>): void {
- window.gameSystem.completeMatching(e.data);
- window.gm.scheduleOnce(this.startFrameSync.bind(this), SocketPlayer.quicklyMatch ? 0 : 2);
- }
- protected onFrameSyncStart(): void {
- window.gameSystem.startGame();
- }
- protected onRecvFrame(e: JCMGO.BroadcastEvent<JCMGO.Frame>): void {
- window.gameSystem.handleFrame(e.data);
- }
- private _hasRequestMatchRoom = false;
- /**请求匹配进入房间 */
- public requestMatchRoom() {
- if (!MatchView.isGameInited) return;
- if (!this.isValid) return;
- if (this._hasRequestMatchRoom) return;
- this._hasRequestMatchRoom = true;
- this.singlePersonRandomMatching({
- playerInfo: PIFS.myPlayerInfo,
- matchRoomConfig: {
- type: "4人自由战斗",
- maxMembers: 4,
- syncFrameRate: 30,
- maxMatchingTime: SocketPlayer.quicklyMatch ? 0 : 6000
- }
- });
- }
- }
|