示例#1
0
 public static void ReleaseInstance()
 {
     if (_instance != null)
     {
         Destroy(_instance.gameObject);
     }
     _instance = null;
 }
示例#2
0
 public static JsManager GetInstance()
 {
     if (_instance == null)
     {
         var obj = new GameObject("JsManager");
         DontDestroyOnLoad(obj);
         _instance = obj.AddComponent <JsManager>();
     }
     return(_instance);
 }
示例#3
0
    public async UniTaskVoid Start()
    {
        await InitModules();

        SignInPanel.Create().Forget();
        LangSelector.Create();

#if GMS
        FB.Init(OnInitComplete);
#endif

#if HMS
        AdPlaceholder.SetActive(!HMSAdsKitManager.Instance.IsBannerAdLoaded);
        HMSAdsKitManager.Instance.OnBannerLoadEvent += () => AdPlaceholder.SetActive(false);
#endif

#if UNITY_WEBGL
        if (JsManager.IsFigSdkInit() == 0)
        {
            Debug.Log("seems like you're in the demo not fig");
            //TestClientStart.Create();
            return;
        }

        Debug.Log("user data: " + JsManager.GetUserData());
        var fbigUserData = JsonUtility.FromJson <FbigUserData>(JsManager.GetUserData());
        Debug.Log("user data loaeds: " + JsonUtility.ToJson(fbigUserData));

        if (fbigUserData.EnteredBefore == 0)
        {
            ConnectToServer(fbigToken: fbigUserData.Token, fbigUserData.Name, fbigUserData.PictureUrl);
        }
        else
        {
            ConnectToServer(fbigToken: fbigUserData.Token);
        }

        Repository.I.TopFriends = JsonUtility.FromJson <List <FbigFriend> >(JsManager.GetFriends())
                                  .Select(f => new MinUserInfo {
            Id = f.Id, Name = f.Name, PictureUrl = f.PictureUrl
        })
                                  .ToArray();

        Debug.Log("friends are: " + JsManager.GetFriends());
        Debug.Log("friends loaded: " + JsonUtility.ToJson(Repository.I.TopFriends));

        JsManager.StartFbigGame();
        //you can think it would make more sence to start when conntected, but there could be network issue and require reconnect for example
        //the decision is not final anyway
#endif
    }
示例#4
0
        private static IntPtr Constructor(IntPtr isolate, IntPtr info, int paramLen, long data)
        {
            try
            {
                {
                    {
                        var result = new JsManager();


                        return(Puerts.Utils.GetObjectPtr((int)data, typeof(JsManager), result));
                    }
                }
            }
            catch (Exception e)
            {
                Puerts.PuertsDLL.ThrowException(isolate, "c# exception:" + e.Message + ",stack:" + e.StackTrace);
            }
            return(IntPtr.Zero);
        }
示例#5
0
    // Use this for initialization
    void Start()
    {
        #region Assigning Missing Components
        if (gameManager == null)
        {
            gameManager = GameObject.Find("GameManager");
        }

        if (jsManager == null)
        {
            jsManager = gameManager.GetComponent <JsManager>();
        }

        if (jsInput == null)
        {
            jsInput = GameObject.Find("JsInputText").GetComponent <Text>();
        }

        if (jsOutput == null)
        {
            jsOutput = GameObject.Find("JsOutputText").GetComponent <Text>();
        }
        #endregion
    }
示例#6
0
 private void Awake()
 {
     instance = this;
 }
示例#7
0
 void Start()
 {
     JsManager.ReleaseInstance();
     JsManager.GetInstance().JsEnv.Eval("require('./main')");
 }