|
|
@ -1,6 +1,7 @@ |
|
|
|
import { _decorator, AssetManager, assetManager, Component, director, instantiate, JsonAsset, Node, Prefab, Scene, sys } from "cc"; |
|
|
|
import { _decorator, AssetManager, assetManager, Component, director, instantiate, JsonAsset, Node, Prefab, Scene } from "cc"; |
|
|
|
import { AudioManager, GameUtils, Httpwork, IsNullOrEmpty, LoaderBundle, LoaderManager, Logger, Message, Network, toLocalStorage } from "../20001/script/sdk/API"; |
|
|
|
import { LoginData, UserData } from "../20001/script/sdk/GameVO"; |
|
|
|
import { sys } from "cc"; |
|
|
|
const { ccclass, property } = _decorator; |
|
|
|
|
|
|
|
@ccclass('GameDebug') |
|
|
@ -12,15 +13,17 @@ export class GameDebug extends Component { |
|
|
|
@property |
|
|
|
pwd: string = "123456" |
|
|
|
@property |
|
|
|
agentID: string = "11" |
|
|
|
agentID: string = "1" |
|
|
|
@property |
|
|
|
PKG: string = "Q637767348" |
|
|
|
@property |
|
|
|
bundleName: string = "20001" |
|
|
|
|
|
|
|
private sdkPath: String = `http://35.154.10.209/rummy/web/dependent/sdk/sdk.json` |
|
|
|
private serverInfoURL: string = `http://${this.ipAddress}:8089/server-info` |
|
|
|
private _account: string; |
|
|
|
private _pwd: string; |
|
|
|
|
|
|
|
|
|
|
|
private static new_acc:string |
|
|
|
private static new_pwd:string |
|
|
|
|
|
|
|
paraseLocationParams() { |
|
|
|
if (sys.isBrowser && window.location.search) { |
|
|
@ -35,6 +38,8 @@ export class GameDebug extends Component { |
|
|
|
} |
|
|
|
|
|
|
|
protected onLoad(): void { |
|
|
|
GameDebug.new_acc=this.account |
|
|
|
GameDebug.new_pwd=this.pwd |
|
|
|
localStorage.setItem("gate", `ws://${this.ipAddress}:3553`) |
|
|
|
this.paraseLocationParams() |
|
|
|
this.LoadSDK() |
|
|
@ -43,13 +48,7 @@ export class GameDebug extends Component { |
|
|
|
} |
|
|
|
private initEvent() { |
|
|
|
Message.add("connected", this.onConnectServerSucc, this) |
|
|
|
Network.getInstance().registhandle(100, this.aaa.bind(this)) |
|
|
|
} |
|
|
|
aaa(data: any) { |
|
|
|
UserData.gold = data.asset; |
|
|
|
UserData.onChanaged(); |
|
|
|
} |
|
|
|
|
|
|
|
private init() { |
|
|
|
Httpwork.getInstance().post(this.serverInfoURL, { Code: this.PKG }, (value) => { |
|
|
|
if (value && value.code == 0) { |
|
|
@ -60,13 +59,14 @@ export class GameDebug extends Component { |
|
|
|
} |
|
|
|
private onConnectServerSucc() { |
|
|
|
//每次断线后都会重新走这里
|
|
|
|
if (localStorage.getItem(`acc`) != '') { |
|
|
|
this.account = '91' + localStorage.getItem(`acc`) |
|
|
|
} |
|
|
|
if (localStorage.getItem(`pwd`) != '') { |
|
|
|
this.pwd = localStorage.getItem(`pwd`) |
|
|
|
} |
|
|
|
this.accountLogin(this.account, this.pwd) |
|
|
|
// if (localStorage.getItem(`acc`) != null) {
|
|
|
|
// this.account = '91' + localStorage.getItem(`acc`)
|
|
|
|
// }
|
|
|
|
// if (localStorage.getItem(`pwd`) != null) {
|
|
|
|
// this.pwd = localStorage.getItem(`pwd`)
|
|
|
|
// }
|
|
|
|
let acc:string="91"+GameDebug.new_acc |
|
|
|
this.accountLogin(acc, GameDebug.new_pwd) |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -159,7 +159,7 @@ export class GameDebug extends Component { |
|
|
|
loginType: 1, |
|
|
|
account: account, |
|
|
|
password: password, |
|
|
|
agentId: this.agentID,//代理ID
|
|
|
|
agentId: 11,//代理ID
|
|
|
|
channelId: this.PKG,//渠道包ID
|
|
|
|
} |
|
|
|
Network.getInstance().send(999, param, (data) => { |
|
|
@ -168,6 +168,8 @@ export class GameDebug extends Component { |
|
|
|
// Toast.getInstance().showToast(I18Manager.getInstance().getString(`net.code.status.${data.code}`)+" - > "+data.code);
|
|
|
|
Logger.warn("账号登录错误 .... ") |
|
|
|
} else { |
|
|
|
localStorage.setItem("acc",this.account) |
|
|
|
localStorage.setItem("pwd",this.pwd) |
|
|
|
const arrdata = data.data; |
|
|
|
Object.assign(LoginData, arrdata) |
|
|
|
this.checkToken(LoginData.token); |
|
|
@ -207,11 +209,11 @@ export class GameDebug extends Component { |
|
|
|
} else { |
|
|
|
//可以用API里提供的 Message 做消息的传递,相当于事件
|
|
|
|
// Message.send(GameConst.GAME_SUB_MESSAGE, route, value) //GameConst 在API里 网络会传递2个参数回来路由和数据
|
|
|
|
LoaderManager.getInstance().loadBundle("20001", null, null, (loader: LoaderBundle) => { |
|
|
|
LoaderManager.getInstance().loadBundle(this.bundleName, null, null, (loader: LoaderBundle) => { |
|
|
|
if (loader) { |
|
|
|
this.isenterGame = true |
|
|
|
AudioManager.getInstance().setBundle(loader) |
|
|
|
director.loadScene("20001", (error: null | Error, scene?: Scene) => { |
|
|
|
director.loadScene(this.bundleName, (error: null | Error, scene?: Scene) => { |
|
|
|
// if(!error)director.runScene(scene)
|
|
|
|
console.log("==========load scene complete=========") |
|
|
|
}) |
|
|
|