Beispiel #1
0
    public static string GetIPv6(string mHost, string mPort)
    {
#if UNITY_IPHONE && !UNITY_EDITOR
        string mIPv6 = XyskIOSAPI.GetIPv6(mHost, mPort);
        return(mIPv6);
#else
        return(mHost + "&&ipv4");
#endif
    }
Beispiel #2
0
 public string GetVersionNum()
 {
             #if UNITY_ANDROID && !UNITY_EDITOR
     return(XyskAndroidAPI.getPackageVersion());
     #elif UNITY_IOS
     return(XyskIOSAPI.GetVersion());
     #endif
     return("1.1.1");
 }
Beispiel #3
0
    void LaunchLoginInfo()
    {
        if (GlobalValue.IsDebugMode)
        {
            GameManager.Instance.loginInfo_             = new COM_LoginInfo();
            GameManager.Instance.loginInfo_.username_   = userName_;
            GameManager.Instance.loginInfo_.password_   = "";
            GameManager.Instance.loginInfo_.version_    = Configure.VersionNumber;
            GameManager.Instance._Account               = GameManager.Instance.loginInfo_.username_;
            GameManager.Instance.loginInfo_.sessionkey_ = Configure.Sessionkey;
#if (UNITY_IOS || UNITY_IPHONE) && !UNITY_EDITOR
            GameManager.Instance.loginInfo_.idfa_ = XyskIOSAPI.GetIDFA();
#elif UNITY_ANDROID
            GameManager.Instance.loginInfo_.mac_ = XyskAndroidAPI.getMacAndroid();
#endif
        }
    }
Beispiel #4
0
    float GetBatteryLevel()
    {
        try
        {
#if UNITY_ANDROID
            float Capacity = XyskAndroidAPI.GetButtery();
            return(Capacity / 100f);
#elif UNITY_IOS || UNITY_IPHONE
            float Capacity = XyskIOSAPI.GetButtery();
            return(Capacity);
#else
            return(-1);
#endif
        }
        catch (Exception e)
        {
            ClientLog.Instance.Log("Failed to read battery power; " + e.Message);
        }
        return(-1);
    }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        //玩家是否手动设置了画质
        string userSet = PlayerPrefs.GetString("UserSetQualityLevel");

        GameManager.Instance.QualityLv = PlayerPrefs.GetInt("QualityLevel", GameManager.Instance.QualityLv);
        if (string.IsNullOrEmpty(userSet))
        {
            //如果玩家没设置过并且是0 则设置为3 中等画质
            if (GameManager.Instance.QualityLv == 0)
            {
                GameManager.Instance.QualityLv = 3;
            }
        }
        QualitySettings.SetQualityLevel(GameManager.Instance.QualityLv);

        inst = this;
        DontDestroyOnLoad(uiRoot);
        DontDestroyOnLoad(ui3DCamera);
        DontDestroyOnLoad(this);

        GameManager.Instance.JudgeIsPad();
#if UNITY_IOS || UNITY_IPHONE
        XyskIOSAPI.SetNotBackup();
#endif

        uiCamera_ = uiRoot.GetComponentInChildren <UICamera>().camera;

        Application.targetFrameRate = 30;
        Application.runInBackground = true;
        Screen.sleepTimeout         = SleepTimeout.NeverSleep;
        // catch global log
        Application.RegisterLogCallback(logReport);

        VersionManager.Instance.finishDownFileEvent += new RequestEventHandler <int>(OnFinishDownFileEvent);
        VersionManager.Instance.CopyEvent           += new RequestEventHandler <int>(OnCopyEvent);

        NetConnection.Instance.discard();

        version      = GameManager.Instance.GetVersionNum();
        platformPath = GameManager.Instance.PlatformToString();
        if (string.IsNullOrEmpty(version))
        {
            //版本获取不到,请下载最新游戏包
            return;
        }
        //拼合cdn地址
        //GlobalValue.cdnservhost = string.Format("{0}{1}/{2}", GlobalValue.cdnservhost, version, platformPath);

        PlayerDepLoader.Instance.OnPlayerLoaded += PlayerAsseMgr.LoadRefAssetsFin;
        EffectDepLoader.Instance.OnEffectLoaded += EffectAssetMgr.LoadRefAssetsFin;

//        AssetLoader.LoadAssetBundle("commonAssets", AssetLoader.EAssetType.ASSET_UI, (AssetBundle bundle, ParamData data) =>
//        {
//            //PopText.Instance.Init();
//            //NpcHeadChat.Instance.Init();
//            //UIManager.Instance.InitIconCell();
//            //GuideManager.Instance.creator.InitArrow();
//            //AssetLoader.LoadAssetBundle("PlayerShader", AssetLoader.EAssetType.ASSET_PLAYER, null, null);
//            //StartCoroutine(PullResFolderName());
//            mayPullResFolderName = true;
//			TransferRate._Inst.Send("Load CommonAssets End");
//        }, null, Configure.assetsPathstreaming);
        mayPullResFolderName = true;
        mayShowSysNotice     = true;

        //cinemaPre_ = Resources.Load<GameObject>("Cinema");

        //Caching.CleanCache();
    }
Beispiel #6
0
    private void OnPrassVoice(GameObject sender, bool isPrass)
    {
#if UNITY_ANDROID
        if (!XyskAndroidAPI.hasMicrophoneAuth() && isPrass)
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning);
            return;
        }
#elif UNITY_IOS
        if (!XyskIOSAPI.HasMicrophoneAuth() && isPrass)
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning);
            return;
        }
#endif
        if (Microphone.devices.Length == 0)
        {
            ClientLog.Instance.Log("No Record Device!");
            return;
        }

        if (isPrass)
        {
            isCanel       = false;
            ischaoshi     = false;
            PrassTime     = Time.realtimeSinceStartup;
            istargetPrass = true;
            ChatSystem.StartRecord();
            yuyinTips.SetActive(true);
        }
        else
        {
            istargetPrass = false;
            yuyinTips.SetActive(false);
            if (ischaoshi)
            {
                return;
            }
            float tm = Time.realtimeSinceStartup - PrassTime;
            ChatSystem.StopRecord();
            if (tm < 1)
            {
                PopText.Instance.Show(LanguageManager.instance.GetValue("chatVeTime"));
            }
            else
            {
                if (isCanel)
                {
                    return;
                }
                if (ChatSystem.AsyncGetCallBack == null)
                {
                    ChatSystem.AsyncGetCallBack = delegate(byte[] datas)
                    {
                        audioChat_            = new COM_Chat();
                        audioChat_.audio_     = datas;
                        audioChat_.isAudio_   = true;
                        audioChat_.audioTime_ = (int)tm;
                        //int le = Mathf.RoundToInt(ChatSystem.GetClipLength(audioChat_.audio_));
                        ChatSystem.SendToServer(_SendChatKind, "", "", audioChat_.audio_, audioChat_.audioTime_);
                        ClientLog.Instance.Log("audioChat_.audio_=====" + audioChat_.audio_.Length);
                        audioChat_ = null;
                    };
                    ChatSystem.AsyncGet();
                }
            }
        }
    }
Beispiel #7
0
    private void OnPrassVoice(GameObject sender, bool isPrass)
    {
#if UNITY_ANDROID
        if (!XyskAndroidAPI.hasMicrophoneAuth())
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning);
            return;
        }
#elif UNITY_IOS
        if (!XyskIOSAPI.HasMicrophoneAuth() && isPrass)
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning);
            return;
        }
#endif
        if (Microphone.devices.Length == 0)
        {
            ClientLog.Instance.Log("No Record Device!");
            return;
        }
        if (isPrass)
        {
            isCanel       = false;
            ischaoshi     = false;
            PrassTime     = Time.realtimeSinceStartup;
            istargetPrass = true;
            ChatSystem.StartRecord();
            yuyinTips.SetActive(true);
        }
        else
        {
            istargetPrass = false;
            yuyinTips.SetActive(false);
            chat_com = new COM_Chat();
            if (ischaoshi)
            {
                return;
            }
            float tm = Time.realtimeSinceStartup - PrassTime;
            if (tm < 1)
            {
                PopText.Instance.Show(LanguageManager.instance.GetValue("chatVeTime"));
            }
            else
            {
                if (isCanel)
                {
                    return;
                }
                ChatSystem.StopRecord();
                if (ChatSystem.AsyncGetCallBack == null)
                {
                    ChatSystem.AsyncGetCallBack = delegate(byte[] datas)
                    {
                        chat_com.audio_ = datas;
                        NetConnection.Instance.queryOnlinePlayerbyName(_selectFriend.name_);
                    };
                    ChatSystem.AsyncGet();
                }
                //ChatSystem.GetClip(ref chat_com.audio_);
                //NetConnection.Instance.queryOnlinePlayerbyName (_selectFriend.name_);

                //ChatSystem.SendToServer(_SendChatKind,"","",chat_com.audio_);
            }
        }
    }
Beispiel #8
0
    void UserExternalCall(string msg)
    {
        Dictionary <string, string> dic = GameUtil.stringToDictionary(msg);
        int    code   = Convert.ToInt32(dic["code"]);
        string result = dic["msg"];

        ClientLog.Instance.Log("UserExternalCall( code: " +  +code + "  result: " + result + ")");
        switch (code)
        {
        case (int)UserActionResultCode.kInitSuccess:        //初始化SDK成功回调
            if (string.IsNullOrEmpty(GlobalValue.channelID))
            {
                GlobalValue.channelID = game.Game.getInstance().getChannelId();
            }
//            string custom = game.Game.getInstance().getCustomParam();
//            if(!string.IsNullOrEmpty(custom))
//            {
//                string[] centerAndcdnAddr = custom.Split(new char[]{';'}, StringSplitOptions.RemoveEmptyEntries);
//                if(centerAndcdnAddr.Length == 2)
//                {
//                    GlobalValue.centerservhost = centerAndcdnAddr[0];
//					GlobalValue.cdnservhost = string.Format("{0}/{1}/", centerAndcdnAddr[1], XyskAndroidAPI.getPackageVersion());
//					Debug.Log(GlobalValue.cdnservhost);
//                }
//            }

            if (GlobalValue.IsDebugMode)
            {
                CommonEvent.OnAppPause          -= OnAppPause;
                CommonEvent.OnAppResume         -= OnAppResume;
                CommonEvent.OnAccountChange     -= OnAccountChange;            //Login regist logout
                CommonEvent.OnQuestFinish       -= OnQuestFinish;
                CommonEvent.OnQuestFail         -= OnQuestFail;
                CommonEvent.OnQuestStart        -= OnQuestStart;
                CommonEvent.OnException         -= OnException;
                CommonEvent.OnPurchase          -= OnPurchase;
                CommonEvent.OnUseItem           -= OnUseItem;
                CommonEvent.OnRewardVirtualCash -= OnRewardVirtualCash;
            }
            _SdkInitSuccess = true;
            TransferRate._Inst.Send("Init SDK End Success");
            break;

        case (int)UserActionResultCode.kInitFail:        //初始化SDK失败回调
            ApplicationEntry.Instance.PostSocketErr(1234);
            TransferRate._Inst.Send("Init SDK End Failed");
            break;

        case (int)UserActionResultCode.kLoginSuccess:        //登陆成功回调
            GameManager.Instance.loginInfo_           = new COM_LoginInfo();
            GameManager.Instance.loginInfo_.username_ = GameUser.getInstance().getPluginId() + "=" + GameUser.getInstance().getUserID();
            // GameManager.Instance.loginInfo_.username_ = GameUser.getInstance().getUserID();
            GameManager.Instance.loginInfo_.password_   = Application.platform.ToString();
            GameManager.Instance.loginInfo_.version_    = Configure.VersionNumber;
            GameManager.Instance._Account               = GameManager.Instance.loginInfo_.username_;
            GameManager.Instance.loginInfo_.sessionkey_ = Configure.Sessionkey;
#if UNITY_IOS || UNITY_IPHONE
            GameManager.Instance.loginInfo_.idfa_ = XyskIOSAPI.GetIDFA();
#elif UNITY_ANDROID
            GameManager.Instance.loginInfo_.mac_ = XyskAndroidAPI.getMacAndroid();
#endif
            game.GameParam param = new game.GameParam((int)game.ToolBarPlace.kToolBarMidRight);
            if (game.GameUser.getInstance().isFunctionSupported("showToolBar"))
            {
                game.GameUser.getInstance().callFuncWithParam("showToolBar", param);
            }

            CommonEvent.ExcuteAccountChange(CommonEvent.DefineAccountOperate.REGISTER);
            TransferRate._Inst.Send("Login SDK End Success");
            break;

        case (int)UserActionResultCode.kLoginNetworkError: //登陆网络出错回调
        case (int)UserActionResultCode.kLoginFail:         //登陆失败回调
            ApplicationEntry.Instance.PostSocketErr(2345);
            TransferRate._Inst.Send("Login SDK End Failed");
            break;

        case (int)UserActionResultCode.kLoginCancel://登陆取消回调
            break;

        case (int)UserActionResultCode.kLogoutSuccess:        //登出成功回调
            if (StageMgr.Loading)
            {
                StageMgr.OnSceneLoaded += SceneLoaded;
            }
            else if (!string.IsNullOrEmpty(StageMgr.Scene_name) && !StageMgr.Scene_name.Equals(GlobalValue.StageName_ReLoginScene))
            {
                ApplicationEntry.Instance.PostSocketErr(2333);
            }
            break;

        case (int)UserActionResultCode.kLogoutFail:        //登出失败回调
            break;

        case (int)UserActionResultCode.kPlatformEnter:        //平台中心进入回调
            break;

        case (int)UserActionResultCode.kPlatformBack:        //平台中心退出回调
            break;

        case (int)UserActionResultCode.kPausePage:        //暂停界面回调
            break;

        case (int)UserActionResultCode.kExitPage:        //退出游戏回调
            CommonEvent.ExcuteAccountChange(CommonEvent.DefineAccountOperate.LOGOUT);
            Application.Quit();
            break;

        case (int)UserActionResultCode.kAntiAddictionQuery:        //防沉迷查询回调
            break;

        case (int)UserActionResultCode.kRealNameRegister:        //实名注册回调
            break;

        case (int)UserActionResultCode.kAccountSwitchSuccess:        //切换账号成功回调
            if (StageMgr.Loading)
            {
                StageMgr.OnSceneLoaded += SceneLoaded;
            }
            else if (!string.IsNullOrEmpty(StageMgr.Scene_name) && !StageMgr.Scene_name.Equals(GlobalValue.StageName_ReLoginScene))
            {
                ApplicationEntry.Instance.PostSocketErr(2333);
            }
            else
            {
                game.GameUser.getInstance().login();
            }
            break;

        case (int)UserActionResultCode.kAccountSwitchFail:        //切换账号成功回调
            GameUser.getInstance().login();
            break;

        default:
            break;
        }
        CommonEvent.ExcuteUserExternal(code);
    }