コード例 #1
0
        public async void SendPicUpload(string _apiUrl, byte[] data, Action <string> _call)
        {
            UIComponent.Instance.Prompt();
            string url = $"{GlobalData.Instance.UploadURL}{_apiUrl}";

            Log.Debug($"SendPicUpload send url = {url} | data = {data} | data.Length = {data.Length}");

            NetHttpComponent            netHttp = ETModel.Game.Scene.GetComponent <NetHttpComponent>();
            Dictionary <string, string> dic     = new Dictionary <string, string>();

            dic.Add("did", SystemInfoUtil.getDeviceUniqueIdentifier());
            dic.Add("md5at", GameCache.Instance.strToken);

            Dictionary <string, string> form = new Dictionary <string, string>();

            form.Add("user_id", $"{GameCache.Instance.nUserId}");

            string res = await netHttp.PostUpload(url, dic, form, "file", data, "picture.png", "image/png");

            UIComponent.Instance.ClosePrompt();
            if (null != _call)
            {
                _call(res);
            }

            return;

            requests.Add(GameUtil.HttpsImagePost(url, data, (request, response) =>
            {
                RemoveRequest(request);
                switch (request.State)
                {
                case HTTPRequestStates.Finished:
                    if (response.IsSuccess)
                    {
                        _call(response.DataAsText);
                    }
                    break;

                case HTTPRequestStates.Error:
                    string exception = request.Exception != null
                                ? (request.Exception.Message + "\n" + request.Exception.StackTrace) : "No Exception";
                    Log.Debug($"Request Finished with Error!  {exception}");
                    UIComponent.Instance.Toast("网络错误");
                    break;

                case HTTPRequestStates.Aborted:
                    Log.Debug($"Request Aborted!");
                    UIComponent.Instance.Toast("网络错误");
                    break;

                case HTTPRequestStates.ConnectionTimedOut:
                    Log.Debug($"Connection Timed Out!");
                    UIComponent.Instance.Toast("网络超时");
                    break;

                case HTTPRequestStates.TimedOut:
                    Log.Debug($"Processing the request Timed Out!");
                    UIComponent.Instance.Toast("网络超时");
                    break;
                }
            }), (int)HTTPRequestStates.Initial);
        }
コード例 #2
0
        public async void Awake()
        {
            ReferenceCollector rc = GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            nameTxt        = rc.Get <GameObject>("NameTxt").GetComponent <Text>();
            uIDTxt         = rc.Get <GameObject>("UIDTxt").GetComponent <Text>();
            realNameTxt    = rc.Get <GameObject>("RealNameTxt").GetComponent <Text>();
            noBindPhoneTxt = rc.Get <GameObject>("NoBindPhoneTxt").GetComponent <Text>();
            HuafeiNumTxt   = rc.Get <GameObject>("HuafeiNumTxt").GetComponent <Text>();
            AlPlayTxt      = rc.Get <GameObject>("AlPlayTxt").GetComponent <Text>();
            WinGameTxt     = rc.Get <GameObject>("WinGameTxt").GetComponent <Text>();
            SuccessRateTxt = rc.Get <GameObject>("SuccessRateTxt").GetComponent <Text>();
            MaxSuccessTxt  = rc.Get <GameObject>("MaxSuccessTxt").GetComponent <Text>();
            VipTimeTxt     = rc.Get <GameObject>("VipTimeTxt").GetComponent <Text>();

            returnBtn        = rc.Get <GameObject>("ReturnBtn").GetComponent <Button>();
            playerIcon       = rc.Get <GameObject>("PlayerIcon").GetComponent <Button>();
            changeNameBtn    = rc.Get <GameObject>("ChangeNameBtn").GetComponent <Button>();
            realNameBtn      = rc.Get <GameObject>("RealNameBtn").GetComponent <Button>();
            bindPhoneBtn     = rc.Get <GameObject>("BindPhoneBtn").GetComponent <Button>();
            ChangeAccountBtn = rc.Get <GameObject>("ChangeAccountBtn").GetComponent <Button>();
            DuihuanBtn       = rc.Get <GameObject>("DuihuanBtn").GetComponent <Button>();

            De         = rc.Get <GameObject>("De").GetComponent <Button>();
            GoldNumTxt = rc.Get <GameObject>("GoldNumTxt").GetComponent <Text>();
            WingNumTxt = rc.Get <GameObject>("WingNumTxt").GetComponent <Text>();
            AddBtn     = rc.Get <GameObject>("AddBtn").GetComponent <Button>();
            DuihuanBtn.onClick.Add(() =>
            {
                Game.Scene.GetComponent <UIComponent>().Create(UIType.UIUseHuaFei);
            });

            AddBtn.onClick.Add(() =>
            {
                Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIPlayerInfo);
                Game.Scene.GetComponent <UIComponent>().Create(UIType.UIShop);
            });

            PlayerFrame = rc.Get <GameObject>("PlayerFrame");

            bindPhoneBtn.onClick.Add(() =>
            {
                Game.Scene.GetComponent <UIComponent>().Create(UIType.UIBindPhone);
            });

            realNameBtn.onClick.Add(() =>
            {
                Game.Scene.GetComponent <UIComponent>().Create(UIType.UIRealName);
            });

            returnBtn.onClick.Add(() =>
            {
                Game.Scene.GetComponent <UIComponent>().Get(UIType.UIMain).GetComponent <UIMainComponent>().SetUIHideOrOpen(true);
                Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIPlayerInfo);
                if (Game.Scene.GetComponent <UIComponent>().Get(UIType.UIVIP) != null)
                {
                    if (Game.Scene.GetComponent <UIComponent>().Get(UIType.UIVIP).GameObject.activeInHierarchy)
                    {
                        Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIVIP);
                    }
                }
            });

            changeNameBtn.onClick.Add(() =>
            {
                Game.Scene.GetComponent <UIComponent>().Create(UIType.UIChangeName);
            });

            ChangeAccountBtn.onClick.Add(() =>
            {
                onClickChangeAccount();
            });

            De.onClick.Add(() =>
            {
                Game.Scene.GetComponent <UIComponent>().Create(UIType.UIVIP);
            });

            PlayerInfoComponent pc         = Game.Scene.GetComponent <PlayerInfoComponent>();
            PlayerInfo          playerInfo = pc.GetPlayerInfo();

            nameTxt.text   = playerInfo.Name;
            uIDTxt.text    = pc.uid.ToString();
            AlPlayTxt.text = $"已玩牌局:{ playerInfo.TotalGameCount}";
            string winRate = GameUtil.GetWinRate(playerInfo.TotalGameCount, playerInfo.WinGameCount).ToString();

            if (winRate.Equals(0))
            {
                SuccessRateTxt.text = $"胜       率:{0}%";
            }
            else
            {
                SuccessRateTxt.text = $"胜       率:{winRate}%";
            }
            MaxSuccessTxt.text = $"最大赢取:{playerInfo.MaxHua}";
            WinGameTxt.text    = $"获胜局数:{ playerInfo.WinGameCount}";

            if (playerInfo.IsRealName)
            {
                realNameTxt.text = "已实名";
            }
            if (!string.IsNullOrEmpty(playerInfo.Phone))
            {
                noBindPhoneTxt.text = "已绑定";
            }

            // 设置头像
            {
                HeadManager.setHeadSprite(playerIcon.GetComponent <Image>(), PlayerInfoComponent.Instance.GetPlayerInfo().Icon);
            }

            playerIcon.onClick.Add(() =>
            {
                CommonUtil.ShowUI(UIType.UIIcon);
            });

            Init();
        }
コード例 #3
0
        //        public async Task GetPlayerInfo()
//        {
//            tokenSource = new CancellationTokenSource();
//            try
//            {
//                Gamer gamer = this.GetParent<Gamer>();
//                Log.Debug("请求gamer信息:" + gamer.UserID);
//                G2C_PlayerInfo playerInfo = (G2C_PlayerInfo)await SessionComponent.Instance.Session.Call(new C2G_PlayerInfo() { uid = gamer.UserID }, tokenSource.Token);
//                gamer.PlayerInfo = playerInfo.PlayerInfo;
//            }
//            catch (Exception e)
//            {
//                Log.Error(e);
//                tokenSource.Cancel();
//            }
//        }

        /// <summary>
        /// 设置准备界面
        /// </summary>
        /// <param name="gameObject"></param>
        public void SetHeadPanel(GameObject gameObject, int index)
        {
            try
            {
                if (gameObject == null)
                {
                    return;
                }

                Index = index;
                Gamer gamer = this.GetParent <Gamer>();
                this.readyHead = gameObject.Get <GameObject>("Image").GetComponent <Image>();
                this.readyName = gameObject.Get <GameObject>("Name").GetComponent <Text>();
                this.readyText = gameObject.Get <GameObject>("Text").GetComponent <Text>();
                this.vip       = gameObject.Get <GameObject>("vip");
                PlayerInfo playerInfo = gamer.PlayerInfo;

                if (readyName == null)
                {
                    return;
                }
                readyName.text = playerInfo.Name + "";
                HeadManager.setHeadSprite(readyHead, playerInfo.Icon);

                if (gamer.IsReady)
                {
                    gameObject.transform.Find("Text").GetComponent <Text>().text = "已准备";
                }
                else
                {
                    readyText.text = "";
                }

                if (GameUtil.isVIP(playerInfo))
                {
                    vip.transform.localScale = Vector3.one;
                }
                else
                {
                    vip.transform.localScale = Vector3.zero;
                }

                #region 准备界面信息框
                // if(Index != 0)
                {
                    this.headReadyInfo = gameObject.Get <GameObject>("HeadInfo");
                    Image kickOffImage     = this.headReadyInfo.Get <GameObject>("KickOffImage").GetComponent <Image>();
                    Text  uidReadyText     = this.headReadyInfo.Get <GameObject>("Uid").GetComponent <Text>();
                    Text  shenglvReadyText = this.headReadyInfo.Get <GameObject>("Shenglv").GetComponent <Text>();
                    Text  jinbiReadyText   = this.headReadyInfo.Get <GameObject>("Jinbi").GetComponent <Text>();
                    this.headReadyInfo.SetActive(false);
                    this.headReadyInfo.GetComponentInParent <Button>().onClick.RemoveAllListeners();
                    this.headReadyInfo.GetComponentInParent <Button>().onClick.Add(() =>
                    {
                        if (this.headReadyInfo.activeSelf)
                        {
                            this.headReadyInfo.SetActive(false);
                        }
                        else
                        {
                            this.headReadyInfo.SetActive(true);
                        }
                    });
                    uidReadyText.text = playerInfo.Name;


                    UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);
                    this.uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();
                    if (UIRoomComponent.IsFriendRoom)
                    {
                        shenglvReadyText.text = $"积 分:<color=#FFF089FF>{playerInfo.Score}</color>";
                    }
                    else
                    {
                        shenglvReadyText.text = $"金 币:<color=#FFF089FF>{playerInfo.GoldNum}</color>";
                    }

                    float i;
                    if (playerInfo.TotalGameCount == 0)
                    {
                        i = 0;
                    }
                    else
                    {
                        i = GameUtil.GetWinRate(playerInfo.TotalGameCount, playerInfo.WinGameCount);
                    }
                    jinbiReadyText.text = $"胜 率:<color=#FFF089FF>{i}%</color>";

                    //踢人

                    if (uiRoomComponent.masterUserId != 0 && uiRoomComponent.masterUserId == PlayerInfoComponent.Instance.uid && Index != 0)
                    {
                        kickOffImage.gameObject.SetActive(true);
                    }
                    else
                    {
                        kickOffImage.gameObject.SetActive(false);
                    }

                    kickOffImage.gameObject.GetComponent <Button>().onClick.Add(() =>
                    {
                        SessionComponent.Instance.Session.Send(new Actor_GamerKickOff()
                        {
                            KickedUserId = gamer.UserID
                        });
                    });
                }



                #endregion
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #4
0
ファイル: UIItemComponent.cs プロジェクト: fynbntl/NjmjNew
        public void Awake()
        {
            rc       = GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();
            icon     = rc.Get <GameObject>("Icon").GetComponent <Image>();
            nameTxt  = rc.Get <GameObject>("NameTxt").GetComponent <Text>();
            priceTxt = rc.Get <GameObject>("PriceTxt").GetComponent <Text>();
            buyBtn   = rc.Get <GameObject>("BuyBtn").GetComponent <Button>();

            CommonUtil.SetTextFont(this.GetParent <UI>().GameObject);

            buyBtn.onClick.Add(async() =>
            {
                if (shopInfo.CurrencyType == 2)
                {
                    //用元宝购买
                    long yuan = PlayerInfoComponent.Instance.GetPlayerInfo().WingNum;
                    if (GameUtil.isVIP())
                    {
                        ShowBuy(yuan, shopInfo.VipPrice, "元宝");
                    }
                    else
                    {
                        ShowBuy(yuan, shopInfo.Price, "元宝");
                    }
                }
                else if (shopInfo.CurrencyType == 1)
                {
                    //用元宝购买
                    long gold = PlayerInfoComponent.Instance.GetPlayerInfo().GoldNum;
                    if (GameUtil.isVIP())
                    {
                        ShowBuy(gold, shopInfo.VipPrice, "金币");
                    }
                    else
                    {
                        ShowBuy(gold, shopInfo.Price, "金币");
                    }
                }
                else
                {
                    if (!PlayerInfoComponent.Instance.GetPlayerInfo().IsRealName&& !OtherData.getIsShiedRealName())
                    {
                        ToastScript.createToast("请先完成实名认证!");
                        Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIShop);
                        Game.Scene.GetComponent <UIComponent>().Create(UIType.UIRealName);
                        return;
                    }

                    {
                        UINetLoadingComponent.showNetLoading();
                        G2C_IsCanRecharge g2cIsCanRecharge = (G2C_IsCanRecharge)await SessionComponent.Instance.Session.Call(new C2G_IsCanRecharge {
                            UId = PlayerInfoComponent.Instance.uid
                        });
                        UINetLoadingComponent.closeNetLoading();

                        if (g2cIsCanRecharge.Error != ErrorCode.ERR_Success)
                        {
                            ToastScript.createToast(g2cIsCanRecharge.Message);

                            return;
                        }
                        else
                        {
                            //ToastScript.createToast("可以充值");
                        }
                    }

                    //接购买SDK
                    //ToastScript.createToast("暂时未开放人民币购买");
                    //可以购买
                    if (!ChannelHelper.IsThirdChannel())
                    {
                        Game.Scene.GetComponent <UIComponent>().Get(UIType.UIShop).GetComponent <UIShopComponent>().Pay(shopInfo);
                    }
                    else
                    {
                        PlatformHelper.pay(PlatformHelper.GetChannelName(), "AndroidCallBack", "GetPayResult", SetRequest(shopInfo).ToJson());
                    }
                }
            });
        }
コード例 #5
0
ファイル: UIBagComponent.cs プロジェクト: fynbntl/NjmjNew
        public async void UseItem(Bag item)
        {
            try
            {
                switch (item.ItemId)
                {
                // 喇叭
                case 105:
                {
                    Game.Scene.GetComponent <UIComponent>().Create(UIType.UIUseLaBa);
                }
                break;

                case 112:
                {
                    GameUtil.GetComponentByType <UIMainComponent>(UIType.UIMain).ShowFriendRoom();
                    if (GameUtil.GetComponentByType <UICreateFriendRoomComponent>(UIType.UICreateFriendRoom) == null)
                    {
                        Game.Scene.GetComponent <UIComponent>().Create(UIType.UICreateFriendRoom);
                    }
                    Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIBag);
                }
                break;

                default:
                {
                    UINetLoadingComponent.showNetLoading();
                    G2C_UseItem g2cBag = (G2C_UseItem)await SessionComponent.Instance.Session.Call(new C2G_UseItem()
                        {
                            UId = PlayerInfoComponent.Instance.uid, ItemId = (int)item.ItemId
                        });

                    UINetLoadingComponent.closeNetLoading();

                    if (g2cBag.result == 1)
                    {
                        GetBagInfoList();
                        useBg.SetActive(false);

                        switch (item.ItemId)
                        {
                        // 表情包
                        case 104:
                        {
                            PlayerInfoComponent.Instance.GetPlayerInfo().EmogiTime = g2cBag.time;
                            ToastScript.createToast("使用成功");
                        }
                        break;

                        // VIP体验卡
                        case 107:
                        case 108:
                        case 109:
                        {
                            PlayerInfoComponent.Instance.GetPlayerInfo().VipTime = g2cBag.time;
                            ToastScript.createToast("使用成功");
                        }
                        break;

                        // 话费礼包
                        case 111:
                        {
                            GameUtil.changeDataWithStr(g2cBag.reward);
                            float huafei = CommonUtil.splitStr_End(g2cBag.reward, ':') / 100.0f;
                            ToastScript.createToast("恭喜获得" + huafei + "元话费");
                        }
                        break;
                        }

                        GameUtil.changeData(item.ItemId, -1);
                    }
                    else
                    {
                        ToastScript.createToast(g2cBag.Message);
                    }
                }
                break;
                }
            }
            catch (Exception ex)
            {
                Log.Debug("------------------" + ex.ToString());
            }
        }