Пример #1
0
        /// <summary>
        ///  sharesdk登录认证平台后返回的数据
        /// </summary>
        /// <param name="reqID"></param>
        /// <param name="state"></param>
        /// <param name="type"></param>
        /// <param name="result"></param>
        void OnAuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
        {
            if (state == ResponseState.Success)
            {
                GameModel.GetInstance.ShowNetLoading();

                print("authorize success !" + "Platform :" + type);

                Hashtable res = ssdk.GetAuthInfo(type);

                print(MiniJSON.jsonEncode(res));

//				MessageHint.Show (MiniJSON.jsonEncode(res));
//				var openstr =;
                var openid = "null";
                                #if UNITY_ANDROID
                openid = MiniJSON.jsonEncode(res["userID"]);
                                #elif UNITY_IPHONE
                openid = MiniJSON.jsonEncode(res["uid"]);
                                #endif

//				MessageHint.Show (openid);
                var tmpOpenid = openid.Substring(1, openid.Length - 2);

                if (openid != "" && openid != "null")
                {
                    PlayerPrefs.SetString(GameModel.GetInstance.UserId, tmpOpenid);
                }

                var loginController = UIControllerManager.Instance.GetController <Client.UI.UILoginController> ();
                loginController.WeChatLogin(tmpOpenid);
            }
            else if (state == ResponseState.Fail)
            {
                GameModel.GetInstance.HideNetLoading();
                var str = "";
                                #if UNITY_ANDROID
                print("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]);
                str = "fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"].ToString();
                                #elif UNITY_IPHONE
                print("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]);
                str = "fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"].ToString();
                                #endif
                MessageHint.Show(MiniJSON.jsonEncode(str));
            }
            else if (state == ResponseState.Cancel)
            {
                GameModel.GetInstance.HideNetLoading();
                print("cancel !");
            }
            else
            {
                GameModel.GetInstance.HideNetLoading();
            }
        }
Пример #2
0
        private void Update()
        {
            try
            {
                var deltaTime = Time.deltaTime;
                _coreMain.Tick(deltaTime);
                if (null != _game)
                {
                    _game.Tick(deltaTime);
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e);
                Console.Error.WriteLine(e.StackTrace);
            }

            //安卓双击返回按钮退出游戏
            if (Application.platform == RuntimePlatform.Android)
            {
                if (Input.GetKeyUp(KeyCode.Escape))
                {
                    if (isQuitGamed == true)
                    {
                        Application.Quit();
                    }
                    else
                    {
                        isQuitGamed = true;
                        MessageHint.Show("双击返回按钮,退出游戏");
                    }
                }

                if (isQuitGamed == true)
                {
                    lefttime += Time.deltaTime;
                    if (lefttime >= exitTime)
                    {
                        lefttime    = 0;
                        isQuitGamed = false;
                    }
                }
            }
        }
Пример #3
0
 void ShareResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
 {
     if (state == ResponseState.Success)
     {
         print("share result :");
         print(MiniJSON.jsonEncode(result));
     }
     else if (state == ResponseState.Fail)
     {
         print("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]);
         var tmpst = "fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"] + "----666----";
         MessageHint.Show(MiniJSON.jsonEncode(result));
     }
     else if (state == ResponseState.Cancel)
     {
         print("cancel !");
         MessageHint.Show("取消的了登录了");
     }
 }
Пример #4
0
 /// <summary>
 /// 获取玩家信息后返回的数据,微信登录暂未使用这个接口,登录认证的时候已经获取了人物信息
 /// </summary>
 /// <param name="reqID"></param>
 /// <param name="state"></param>
 /// <param name="type"></param>
 /// <param name="result"></param>
 void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
 {
     if (state == ResponseState.Success)
     {
         print("get user info result :");
         print(MiniJSON.jsonEncode(result));
         MessageHint.Show(MiniJSON.jsonEncode(result));
         print("Get userInfo success !Platform :" + type);
     }
     else if (state == ResponseState.Fail)
     {
                         #if UNITY_ANDROID
         print("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]);
                         #elif UNITY_IPHONE
         print("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]);
                         #endif
     }
     else if (state == ResponseState.Cancel)
     {
         print("cancel !");
     }
 }
Пример #5
0
        /// <summary>
        /// 游戏能否获得胜利
        /// </summary>
        /// <returns></returns>
        public bool CanInnerSuccess()
        {
            var cansuccess = false;

            if (GameModel.GetInstance.isPlayNet == false)
            {
                if (null != PlayerManager.Instance)
                {
                    if (null != PlayerManager.Instance.HostPlayerInfo)
                    {
                        if (playerID != PlayerManager.Instance.HostPlayerInfo.playerID)
                        {
                            return(false);
                        }
                    }
                }
                //TargetIncome
                if (CurrentIncome >= TargetIncome && qualityScore >= targetQualityScore && timeScore >= targetTimeScore)
                {
                    if (bankIncome > 0)
                    {
                        var _controller = UIControllerManager.Instance.GetController <GameTipBoardWindowController> ();

                        var battlecontroller = UIControllerManager.Instance.GetController <UIBattleController> ();

                        if (battlecontroller.IsPackbackActive() == false)
                        {
                            _controller.gameTip = "您有未还银行贷款,不能胜利";
                            _controller.setVisible(true);
                        }
                        //MessageHint.Show ("您有未还银行贷款,不能胜利");
                        return(false);
                    }
                    else
                    {
                        cansuccess = true;
                    }
                }
            }
            else
            {
                if (netIsSuccess == 0)
                {
                    cansuccess   = true;
                    bankIncome   = 0;
                    creditIncome = 0;
                    _isSuccess   = true;
                    if (_isShowSuccessTip == true)
                    {
                        _isShowSuccessTip = false;
                        var tip = string.Format("恭喜{0}进入核心圈!", this.playerName);
                        MessageHint.Show(tip);
                    }
                    return(cansuccess);
                }
                else
                {
                    cansuccess = false;
                    if (netIsSuccess == 2)
                    {
                        var _controller      = UIControllerManager.Instance.GetController <GameTipBoardWindowController> ();
                        var battlecontroller = UIControllerManager.Instance.GetController <UIBattleController> ();
                        if (PlayerManager.Instance.IsHostPlayerTurn() == true)
                        {
                            if (PlayerManager.Instance.HostPlayerInfo.playerID == this.playerID)
                            {
                                if (battlecontroller.IsPackbackActive() == false)
                                {
                                    _controller.gameTip = "您有未还银行贷款,不能胜利";
                                    _controller.setVisible(true);
                                }
                            }
                        }
                        return(false);
                    }
                }
            }
            if (cansuccess)
            {
                GameTimerManager.Instance.SuceessTime();
            }
            return(cansuccess);
        }