Ejemplo n.º 1
0
    /// <summary>
    /// 分享URL到微信
    /// </summary>
    /// <param name="bTimeline"></param>
    public static void ShareURLToWechat(string urlstr, string descpstr, bool bTimeline = true)
    {
        if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
        {
            return;
        }

#if UNITY_ANDROID
        if (AlipayWeChatPay.IsWxAppInstalled())
        {
            AlipayWeChatPay.WeChat_ShareURL(urlstr, descpstr, bTimeline);
        }
        else
        {
            //还末安装微信失败处理
            CRollTextUI.Instance.AddVerticalRollText(1010);
        }
#endif

#if UNITY_IOS
        if (WechatPlatfrom_IOS.WeChat_IsWXAppInstalled())
        {
            WechatPlatfrom_IOS.WeChat_ShareURL(urlstr, descpstr, bTimeline);
        }
        else
        {
            //还末安装微信失败处理
            CRollTextUI.Instance.AddVerticalRollText(1010);
        }
#endif
    }
Ejemplo n.º 2
0
    //更新手机基本信息
    IEnumerator UpdataBasicInfoData()
    {
        while (true)
        {
            float batteryLevel = 0.0f;
#if UNITY_ANDROID && !UNITY_EDITOR
            batteryLevel  = AlipayWeChatPay.GetAndroidActivity().Call <int>("GetBatteryLevel");
            batteryLevel /= 100.0f;
#endif

#if UNITY_IOS && !UNITY_EDITOR
            batteryLevel = WechatPlatfrom_IOS.GetBatteryLevel();
#endif
            //电池电量
            if (BatteryIcon)
            {
                BatteryIcon.fillAmount = batteryLevel;
            }

            //时间
            if (TimeText)
            {
                TimeText.text = System.DateTime.Now.Hour.ToString("D2") + ":"
                                + System.DateTime.Now.Minute.ToString("D2")
                                + (ShowSecond ? (":" + System.DateTime.Now.Second.ToString("D2")) : "");
            }
            yield return(new WaitForSeconds(ShowSecond ? 1f : 5f));
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 分享当前屏幕截图区域到微信
    /// </summary>
    /// <param name="bTimeline"></param>
    public static void ShareImageRectToWechat(Canvas cans, RectTransform rect, bool bTimeline = true)
    {
        if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
        {
            return;
        }

#if UNITY_ANDROID
        if (AlipayWeChatPay.IsWxAppInstalled())
        {
            AlipayWeChatPay.WeChat_ShareRectImage(cans, rect, bTimeline);
        }
        else
        {
            //还末安装微信失败处理
            CRollTextUI.Instance.AddVerticalRollText(1010);
        }
#endif

#if UNITY_IOS
        if (WechatPlatfrom_IOS.WeChat_IsWXAppInstalled())
        {
            WechatPlatfrom_IOS.WeChat_ShareRectImage(cans, rect, bTimeline);
        }
        else
        {
            //还末安装微信失败处理
            CRollTextUI.Instance.AddVerticalRollText(1010);
        }
#endif
    }
Ejemplo n.º 4
0
    //玩家支付订单信息处理
    private bool PlayerTradeAppPayInfo(uint msgType, UMessage umsg)
    {
        uint   playerid     = umsg.ReadUInt();
        byte   payplatform  = umsg.ReadByte();
        string paytradeInfo = umsg.ReadString();

        Debug.Log("玩家:" + playerid + "订单:" + paytradeInfo);

        //订单信息过来后就可以关闭购买等待框了
        BuyEnd();

        if (payplatform == (byte)PayPlatform.AliPay)
        {
#if UNITY_ANDROID
            AlipayWeChatPay.RequestAliPay(paytradeInfo, false);
#elif UNITY_IOS
            WechatPlatfrom_IOS.MayunJieZhang_IOS(paytradeInfo);
#endif
        }
        else if (payplatform == (byte)PayPlatform.Wechat)
        {
            string noncestr = umsg.ReadString();
#if UNITY_ANDROID
            if (AlipayWeChatPay.IsWxAppInstalled())
            {
                AlipayWeChatPay.ReqWxPay(paytradeInfo, noncestr);
            }
            else
            {
                //还末安装微信失败处理
                // BuyEnd();
                CCustomDialog.OpenCustomConfirmUI(1010);
            }
#elif UNITY_IOS
            if (WechatPlatfrom_IOS.WeChat_IsWXAppInstalled())
            {
                WechatPlatfrom_IOS.WXLgoinJieZhang_IOS(paytradeInfo, noncestr);
            }
            else
            {
                //还末安装微信失败处理
                //BuyEnd();
                CCustomDialog.OpenCustomConfirmUI(1010);
            }
#endif
        }
        else if (payplatform == (byte)PayPlatform.vvPay_Wechat || payplatform == (byte)PayPlatform.vvPay_Alipay)
        {
            Application.OpenURL(paytradeInfo);
        }

        return(true);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 登陆成功处理
    /// </summary>
    /// <param name="_msgType"></param>
    /// <param name="_ms"></param>
    /// <returns></returns>
    bool LoginSuccess(uint _msgType, UMessage _ms)
    {
        PlayerData playerdata        = GameMain.hall_.GetPlayerData();
        uint       lastLoginPlayerId = playerdata.GetPlayerID();

        playerdata.ReadPlayerData(_ms, ref CRankUI.Instance.m_fLeftCoinRankTime);
        //检测是否切换角色了
        if (lastLoginPlayerId != 0 && lastLoginPlayerId != playerdata.GetPlayerID())
        {
        }

        GameMain.hall_.IntelentType = Application.internetReachability;
        WriteAccountConfig();

        //GameMain.hall_.SendGetCoinRankData();

        //m_bIsSendMobileNum = false;
        CCustomDialog.CloseCustomWaitUI();
        GameMain.hall_.AfterLogin();


#if ScFish
        GameMain.hall_.OnClickRoomIconBtn((byte)GameKind_Enum.GameKind_Fishing, 1);
        return(true);
#endif


        //GameMain.hall_.LoadHallResource();
        if (playerdata.nGameMode_Before >= 0)
        {
            Debug.Log("断线重连GameId:" + playerdata.nGameKind_Before + ",GameMode:" + playerdata.nGameMode_Before);
            string        strSign           = string.Empty;
            GameKind_Enum CurbeforeGameKind = (GameKind_Enum)playerdata.nGameKind_Before;
            if (playerdata.nGameMode_Before == 0)
            {
                CurbeforeGameKind = (GameKind_Enum)(Mathf.Log(playerdata.nGameKind_Before, 2));
                for (GameKind_Enum gameKind = GameKind_Enum.GameKind_CarPort; gameKind < GameKind_Enum.GameKind_Max; ++gameKind)
                {
                    if (gameKind != GameKind_Enum.GameKind_LandLords && gameKind != GameKind_Enum.GameKind_Mahjong &&
                        gameKind != GameKind_Enum.GameKind_GuanDan && gameKind != GameKind_Enum.GameKind_YcMahjong &&
                        gameKind != GameKind_Enum.GameKind_CzMahjong && gameKind != GameKind_Enum.GameKind_GouJi &&
                        gameKind != GameKind_Enum.GameKind_HongZhong && gameKind != GameKind_Enum.GameKind_Answer &&
                        gameKind != GameKind_Enum.GameKind_Chess)
                    {
                        if (GameKind.HasFlag((int)gameKind, (int)playerdata.nGameKind_Before))
                        {
                            GameData gamedata = CCsvDataManager.Instance.GameDataMgr.GetGameData((byte)CurbeforeGameKind);
                            if (gamedata != null)
                            {
                                strSign += gamedata.GameName;
                            }
                            else
                            {
                                strSign += "未知游戏";
                            }
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(strSign))
            {
                CCustomDialog.OpenCustomWaitUI(2014, strSign);
            }
            else
            {
                if (GameMain.hall_.contestui_)
                {
                    GameMain.hall_.contestui_.SetActive(false);
                }
                GameMain.hall_.ReconnectLoadGame(CurbeforeGameKind, (GameTye_Enum)playerdata.nGameMode_Before);
            }
        }
        else
        {
            if (Application.platform == RuntimePlatform.Android)
            {
#if UNITY_ANDROID && !UNITY_EDITOR
                AlipayWeChatPay.GetAndroidActivity().Call("GetGameRoomID");
#endif
            }
        }

        GameMain.hall_.ReconnectGameServer();

        UMessage activemsg = new UMessage((uint)GameCity.EMSG_ENUM.CrazyCityMsg_GETTODAYREDBAGINFO);
        activemsg.Add(GameMain.hall_.GetPlayerId());
        NetWorkClient.GetInstance().SendMsg(activemsg);

        BagDataManager.GetBagDataInstance();
        if (GameMain.hall_.GetPlayerData().itemNumber > 0)
        {
            UMessage bagmsg = new UMessage((uint)GameCity.EMSG_ENUM.CrazyCityMsg_REQUESTPLAYERPACKETINFO);
            bagmsg.Add(GameMain.hall_.GetPlayerId());
            NetWorkClient.GetInstance().SendMsg(bagmsg);
        }

        PlayerInfoUI.Instance.Ask4PlayerTotalData();

        return(true);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 手机登陆
    /// </summary>
    void OnBtn_PhoneLogin(EventTriggerType eventtype, object button, PointerEventData eventData)
    {
        if (eventtype == EventTriggerType.PointerClick)
        {
            CustomAudio.GetInstance().PlayCustomAudio(1002);
            if (CanvasObj == null)
            {
                CanvasObj = GameObject.Find("Canvas/Root");
            }



#if UNITY_IOS && !UNITY_EDITOR
            if (WechatPlatfrom_IOS.WeChat_IsWXAppInstalled())
            {
                WechatPlatfrom_IOS.WeChat_AuthLogin();
            }
            else
            {
                //还末安装微信失败处理
                CRollTextUI.Instance.AddVerticalRollText(1010);
            }
#elif UNITY_ANDROID && !UNITY_EDITOR
            if (AlipayWeChatPay.IsWxAppInstalled())
            {
                AlipayWeChatPay.ReqWxLoginAuth();
            }
            else
            {
                //还末安装微信失败处理
                CRollTextUI.Instance.AddVerticalRollText(1010);
            }
#elif UNITY_EDITOR || UNITY_STANDALONE_WIN
            //WeChatAuthLogin();
            RequestLogin();
#endif
            return;

            CanvasObj.transform.Find("Login").Find("Panel_Login").gameObject.SetActive(false);

            GameObject PhonePanel = CanvasObj.transform.Find("Login").Find("Panel_PhoneLogin").gameObject;

            //返回按钮
            GameObject btnreturn = PhonePanel.transform.Find("Button_Return").gameObject;
            btnreturn.GetComponent <Image>().raycastTarget = true;
            btnreturn.GetComponent <Button>().interactable = true;

            //获取验证码按钮
            GameObject codeBtn = PhonePanel.transform.Find("Button_GetCode").gameObject;
            codeBtn.GetComponent <Image>().raycastTarget = true;
            codeBtn.GetComponent <Button>().interactable = true;
            Text strCode = codeBtn.transform.Find("Text_GetCode").gameObject.GetComponent <Text>();
            strCode.text = "获取验证码";

            //登陆按钮
            GameObject loginBtn = PhonePanel.transform.Find("Button_FinishLogin").gameObject;
            loginBtn.GetComponent <Image>().raycastTarget = true;
            loginBtn.GetComponent <Button>().interactable = true;

            PhonePanel.transform.Find("InputField_PhoneNum").gameObject.GetComponent <InputField>().text = "";
            PhonePanel.transform.Find("InputField_Code").gameObject.GetComponent <InputField>().text     = "";

            PhonePanel.SetActive(true);

            XPointEvent.AutoAddListener(codeBtn, OnBtn_GetCode, null);
            XPointEvent.AutoAddListener(loginBtn, OnBtn_StartPhoneLogin, null);
            XPointEvent.AutoAddListener(btnreturn, OnBtn_ReturnChooseType, null);
        }
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        //防止在start中初始化下载资源登陆场景还没有显示
        if (eLuancherState == LUANCHERSTATE.LuancherState_StartVerify && Time.time > 0.5f)
        {
            Debug.Log("LuancherState_StartVerify process:");
            if (CheckAppRunPermission() == true)
            {
                CheckVersionUpdate();
                //eLuancherState = LUANCHERSTATE.LuancherState_Over;
            }
            else
            {
                DownloadProcessUpdatetextObj.GetComponent <Text>().text = "请授予程序运行必要的权限...";
                DownloadProcessUpdatetextObj.SetActive(true);
                eLuancherState = LUANCHERSTATE.LuancherState_Over;
            }
        }

        //else if(eLuancherState == LUANCHERSTATE.LuancherState_UnZip)
        //{
        //    if (DownloadProcessBarImg.fillAmount == 0.01f)
        //    {
        //        FirstRunAppUnzipAssetbundle();
        //    }
        //    DownloadProcessBarImg.fillAmount += 0.005f;
        //    Debug.Log("unzip process:" + DownloadProcessBarImg.fillAmount);
        //}

        //资源更新下载状态
        else if (eLuancherState == LUANCHERSTATE.LuancherState_Downloading)
        {
            if (DownLoadProcessMgr.Instance.IsDownLoadOver)
            {
                DownloadProcessUpdatetextObj.GetComponent <Text>().text = "正在校验资源...";
                DownloadProcessUpdatetextObj.SetActive(true);
                eLuancherState = LUANCHERSTATE.LuancherState_VerifyMD5;
            }
            else
            {
                if (HttpDownloadMgr.Instance.bDownloadError)
                {
                    DownloadProcessUpdatetextObj.GetComponent <Text>().text = "网络出现异常,正在重试...";
                    DownloadProcessUpdatetextObj.SetActive(true);
                }
                else
                {
                    DownloadProcessBarImg.fillAmount = DownLoadProcessMgr.Instance.GetDownloadProcess();
                    uint percent = DownLoadProcessMgr.Instance.GetDownloadPercent();
                    //Debug.Log("percent:" + percent);
                    DownloadProcessPercentObj.GetComponent <Text>().text = percent.ToString() + "%";

                    //这里有优化空间的,不需要每帧去更新总大小
                    string downlenstr = DownLoadProcessMgr.Instance.GetDownloadFileCurLength().ToString();
                    DownloadProcessTotalLengthObj.GetComponent <Text>().text = downlenstr + "/" + DownLoadProcessMgr.Instance.GetDownloadFileTotalLength().ToString() + "KB";
                    DownloadProcessPercentObj.SetActive(true);
                    DownloadProcessTotalLengthObj.SetActive(true);
                    DownloadProcessUpdatetextObj.GetComponent <Text>().text = "更新资源,请稍候...";
                    DownloadProcessUpdatetextObj.SetActive(true);
                }
            }
        }

        //下载完成调起安装
        else if (eLuancherState == LUANCHERSTATE.LuancherState_InstallAPK)
        {
#if UNITY_ANDROID
#if UKGAME_SDK
            CUKGameSDK.GetUKGameActivity().Call("InstallApk", GameDefine.DownloadApkSavePath + GameDefine.ApkFileName);
#else
            AlipayWeChatPay.GetAndroidActivity().Call("InstallApk", GameDefine.DownloadApkSavePath + GameDefine.ApkFileName);
#endif
#endif
            eLuancherState = LUANCHERSTATE.LuancherState_Over;
        }

        //资源资源进行MD5校验(防止网络异常下载的资源文件内容有错)
        else if (eLuancherState == LUANCHERSTATE.LuancherState_VerifyMD5)
        {
            if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
            {
                eLuancherState = LUANCHERSTATE.LuancherState_StartGame;
            }
            else
            {
                ResourceMD5Verify();
            }
        }

        //启动游戏
        else if (eLuancherState == LUANCHERSTATE.LuancherState_StartGame)
        {
            GameMain.Instance.InitApplication(m_SvrResVerStr, m_ServerIP, m_ServerPort);
            eLuancherState = LUANCHERSTATE.LuancherState_Over;
        }
    }