예제 #1
0
    public static void Init(bool bforceUse = false)
    {
        Debug.Log("Begin Network Acc");
        Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.NetworkAccelerator_TurnOn, new CUIEventManager.OnUIEventHandler(NetworkAccelerator.OnEventTurnOn));

        Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.NetworkAccelerator_Ignore, new CUIEventManager.OnUIEventHandler(NetworkAccelerator.OnEventTurnIgore));

        NetworkAccelerator.s_enabledPrepare = true;
        if (!bforceUse)
        {
            if (!NetworkAccelerator.IsUseACC())
            {
                Debug.Log("NetAcc player close acc");
                return;
            }
        }
        else
        {
            NetworkAccelerator.SetUseACC(true);
        }
        NetworkAccelerator.s_enabled = true;
        Debug.Log("NetAcc key:" + NetworkAccelerator.key);
        Debug.Log("NetAcc enable & java begin");
        AndroidJavaObject GMContext = null;

        using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        {
            GMContext = androidJavaClass.GetStatic <AndroidJavaObject>("currentActivity");
        }
        AndroidJavaClass GMClass = new AndroidJavaClass("com.subao.gamemaster.GameMaster");

        if (GMClass != null)
        {
            GMContext.Call("runOnUiThread", new object[]
            {
                delegate
                {
                    int num = GMClass.CallStatic <int>("init", new object[]
                    {
                        GMContext,
                        1,
                        NetworkAccelerator.key,
                        "KingsGlory",
                        "libapollo.so",
                        13001
                    });
                    if (num >= 0)
                    {
                        Debug.Log("Initialize GameMaster Success!");
                        NetworkAccelerator.s_inited = true;
                        NetworkAccelerator.ChangeLogLevel(NetworkAccelerator.LOG_LEVEL_ERROR);
                    }
                    else
                    {
                        Debug.LogError("Initialize GameMaster Fail!, ret:" + num);
                    }
                }
            });
        }
    }