Exemplo n.º 1
0
 void OnDestroy()
 {
     NetConnection.Instance.disconnect();
     NetConnection.Instance.OnSocketError        -= SocketHandler;
     VersionManager.Instance.finishDownFileEvent -= OnFinishDownFileEvent;
     VersionManager.Instance.CopyEvent           -= OnCopyEvent;
     ConfigLoader.Instance.parseDataFin_         -= ParseDataFinish;
     CommonEvent.ExcuteAccountChange(CommonEvent.DefineAccountOperate.LOGOUT);
 }
Exemplo n.º 2
0
    virtual public void SetIprop(COM_PropValue[] props)
    {
        for (int i = 0; i < props.Length; ++i)
        {
            if (props[i].type_ == PropertyType.PT_Level)
            {
                isLevelUp_ = (int)props[i].value_ > GetIprop(PropertyType.PT_Level);

                if (isLevelUp_)
                {
                    ClientLog.Instance.Log(" InstID: " + instId_ + " is Level Up" + "   Player ID is : " + GamePlayer.Instance.InstId);
                }
            }
            else
            {
                isLevelUp_ = false;
            }
            properties_[(int)props[i].type_] = props[i].value_;
            if (isLevelUp_)
            {
                if (instId_ == GamePlayer.Instance.InstId)
                {
                    CommonEvent.ExcuteAccountChange(CommonEvent.DefineAccountOperate.LevelUp);
                }
                else if (GamePlayer.Instance.BattleBaby != null && GamePlayer.Instance.BattleBaby.InstId == instId_)
                {
                    if (GamePlayer.Instance.BabyLevelUpEvent != null)
                    {
                        GamePlayer.Instance.BabyLevelUpEvent(new int[] { instId_, (int)properties_[(int)props[i].type_] });
                    }
                }
            }
        }
        if (OnIPropUpdate != null)
        {
            OnIPropUpdate();
        }

        isPropDirty_ = true;
    }
Exemplo n.º 3
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);
    }