Exemple #1
0
        public void Start()
        {
            ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            View        = rc.Get <GameObject>("View").GetComponent <Button>();
            AccountGrid = rc.Get <GameObject>("AccountGrid");
            TimeTxt     = rc.Get <GameObject>("TimeTxt").GetComponent <Text>();
            DateTxt     = rc.Get <GameObject>("DateTxt").GetComponent <Text>();
            RoomIdTxt   = rc.Get <GameObject>("RoomIdTxt").GetComponent <Text>();
            ScoreTxt    = rc.Get <GameObject>("ScoreTxt").GetComponent <Text>();
            Result      = rc.Get <GameObject>("Result").GetComponent <Image>();

            item = CommonUtil.getGameObjByBundle(UIType.UIFriendRoomTxt);

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

            View.onClick.Add(() =>
            {
                Game.Scene.GetComponent <UIComponent>().Create(UIType.UIFriendRoomDetail);
                if (GameUtil.GetComponentByType <UIFriendRoomDetailComponent>(UIType.UIFriendRoomDetail) != null)
                {
                    GameUtil.GetComponentByType <UIFriendRoomDetailComponent>(UIType.UIFriendRoomDetail).SetInfo(info);
                }
            });
        }
        public void OnClick(int id)
        {
            GameUtil.GetComponentByType <UIActivityComponent>(UIType.UIActivity).SetSelect(id);
            if (activityDic.ContainsKey(id))
            {
                SetActive(id);
            }
            else
            {
                //根据不同的活动ID显示不同的活动面板
                string     panelName = "UIActivity_" + id;
                GameObject obj       = CommonUtil.getGameObjByBundle(panelName);

                GameObject activity = GameObject.Instantiate(obj, Game.Scene.GetComponent <UIComponent>().Get(UIType.UIActivity).GetComponent <UIActivityComponent>().GetActivityParent());

                //activity.transform.GetComponent<RectTransform>().setan
                UI ui = ComponentFactory.Create <UI, GameObject>(activity);
                if (id == 101)
                {
                    ui.AddComponent <UIActivity101Component>();
                }
                if (id == 102)
                {
                    ui.AddComponent <UIFriendActivityComponent>();
                }

                if (!activityDic.ContainsKey(id))
                {
                    activityDic.Add(id, activity);
                }
            }
        }
Exemple #3
0
 public override void Dispose()
 {
     base.Dispose();
     juTypeToggles.Clear();
     juUIList.Clear();
     huaTypeToggles.Clear();
     huaUIList.Clear();
     typeToggles.Clear();
     typeUIList.Clear();
     if (GameUtil.GetComponentByType <UIMainComponent>(UIType.UIMain) != null)
     {
         GameUtil.GetComponentByType <UIMainComponent>(UIType.UIMain).StopFriendReq();
     }
 }
Exemple #4
0
        public async void reqHeartBeat()
        {
            try
            {
                G2C_HeartBeat g2cHeartBeat = (G2C_HeartBeat)await SessionComponent.Instance.Session.Call(new C2G_HeartBeat { });
            }
            catch (Exception ex)
            {
                if (!isStopHeartBeat)
                {
                    stopHeartBeat();

                    //Game.Scene.GetComponent<UIComponent>().Create(UIType.UINetError);

                    if (GameUtil.GetComponentByType <UIMainComponent>(UIType.UIMain) != null)
                    {
                        GameUtil.GetComponentByType <UIMainComponent>(UIType.UIMain).StopFriendReq();
                    }

                    UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel("提示", "与服务器断开连接,请重新登录。");
                    script.setOnClickOkEvent(() =>
                    {
#if GM
                        Game.Scene.GetComponent <UIComponent>().RemoveAll();
                        Game.Scene.GetComponent <UIComponent>().Create(UIType.UIGMLogin);
#else
                        Game.Scene.GetComponent <UIComponent>().RemoveAll();
                        Game.Scene.GetComponent <UIComponent>().Create(UIType.UILogin);
#endif
                    });

                    script.setOnClickCloseEvent(() =>
                    {
#if GM
                        Game.Scene.GetComponent <UIComponent>().RemoveAll();
                        Game.Scene.GetComponent <UIComponent>().Create(UIType.UIGMLogin);
#else
                        Game.Scene.GetComponent <UIComponent>().RemoveAll();
                        Game.Scene.GetComponent <UIComponent>().Create(UIType.UILogin);
#endif
                    });
                }
            }
        }
Exemple #5
0
        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());
            }
        }