| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using JCEngineCore;
- using UnityEngine.SceneManagement;
- public class UserPlayer : JCEntity
- {
- public static UserPlayer ins;
- public UserPlayer() {
- ins = this;
- }
- public static void ConnectServer() {
- if (ins != null) return;
- if (HomeMgr.ins) HomeMgr.ins.ShowAuthLoginMask(true);
- JCEngine.boot(CommonConfig.businessServerWsURI, new UserPlayer());
- }
- public override void onLoad() {
- Debug.Log("UserPlayer onLoad()");
- authToken();
- }
- public override void onReload() {
- Debug.Log("UserPlayer onReload()");
- }
- public override void onDestroy() {
- Debug.Log("UserPlayer onDestroy()");
- }
- public override void onMiss() {
- Debug.Log("UserPlayer onMiss()");
- }
- //向服务端发送的请求
- public void authToken() {
- string p0 = PlayerPrefs.GetString("IdAndToken", "");
- // #if UNITY_EDITOR
- // if (string.IsNullOrEmpty(p0)) {
- // p0 = "10&185fa8f92dfe4a55bf35e7ff604c519b";
- // }
- // #endif
- call("authToken", p0);
- }
- //被服务端调用的函数
- public void onAuthRes(bool res) {
- Debug.Log("onAuthRes," + res);
- if (res) {
- UserComp.ins.getUserInfo(delegate(UserInfo userInfo) {
- LoginMgr.myUserInfo = userInfo;
- if (HomeView.ins) {
- HomeView.ins.RenderMyAvatarSprite();
- HomeView.ins.RenderNameOrGender();
- HomeView.ins.RenderDeviceNames();
- }
- if (HomeMgr.ins) {
- HomeMgr.ins.ShowAuthLoginMask(false);
- }
- });
- } else {
- PlayerPrefs.DeleteKey("IdAndToken");
- SceneManager.LoadScene("Login", LoadSceneMode.Single);
- }
- }
- }
|