示例#1
0
        public void OnEnter(ChatBoxState newState)
        {
            ChatBoxState oldState = m_ChatBoxState.GetChatBoxState();

            switch (newState)
            {
            case ChatBoxState.StaticState:
            {
                m_ChatBoxState = new ChatBoxStaticScene(this);
            }
            break;

            case ChatBoxState.StaticStateFullScreen:
            {
                m_ChatBoxState = new ChatBoxStaticSceneFullScreen(this);
            }
            break;

            case ChatBoxState.WarLoadingState:
            {
                m_ChatBoxState = new ChatBoxWarLoading(this);
            }
            break;

            case ChatBoxState.WarState:
            {
                m_ChatBoxState = new ChatBoxWarScene(this);
            }
            break;

            case ChatBoxState.RoomState:
            {
                m_ChatBoxState = new ChatBoxMatchRoom(this);
            }
            break;

            case ChatBoxState.StaticStatePopup:
            {
                m_ChatBoxState = new ChatBoxStaticScenePopup(this);
            }
            break;

            default:
            {
                Debug.LogWarning(String.Format("Error ChatBoxState,{0}", newState));
            }
            break;
            }

            m_ChatBoxState.OnEnter(oldState);
        }
示例#2
0
        public override bool Init(IUIWnd wnd)
        {
            base.Init(wnd);

            // 从脚本配置中获取各个频道名字,缓存起来,与频道宏定义做个映射,方便读取
            string[] channelName = { "SystemChannelName",
                                     "WorldChannelName",
                                     "MatchroomChannelName",
                                     "TeammateChannelName",
                                     "WarSceneChannelName",
                                     "PrivateChannelName",
                                     "KinChannelName",
                                     "ClanChannelName",
                                     "NearbyChannelName",
                                     "ZoneChannelName",
                                     "CampChannelName", };
            for (EMChatChannelType type = EMChatChannelType.CHAT_CHANNEL_SYSTEM; type < EMChatChannelType.CHAT_CHANNEL_MAX; ++type)
            {
                m_dicChannnelName[type] = ULocalizationService.Instance.Get("UIView", "ChatBox", channelName[(int)type]);
            }



            canDrag = false;

            //如果游戏限制输入法,则初始化相关界面
            if (ImeManager.ForbidIme)
            {
                List <string> imeList = ImeManager.GetImeNameList();
                if (imeList != null)
                {
                    foreach (var temp in imeList)
                    {
                        imeDropdown.options.Add(new Dropdown.OptionData()
                        {
                            text = temp
                        });
                    }
                }
                imeDropdown.value = 0;
                chineseIcon.gameObject.SetActive(false);
                enIcon.gameObject.SetActive(true);
            }
            else//否则隐藏
            {
                imeDropdown.interactable = false;
                chineseIcon.gameObject.SetActive(false);
                enIcon.gameObject.SetActive(false);
            }

            inputField.onEndEdit.AddListener(delegate { OnEndEdit(); });

            resizer.SetWndView(this);

            minimumIcon.SetChatWndView(this);
            minimunCanvasGroup       = minimumIcon.GetComponent <CanvasGroup>();
            channelMaskItemPrefabRes = AssetBundleManager.GetAssets(AssetType.Asset_Prefab, "UI/Prefabs/Chat/ChatChannelGroupItem");

            m_DiyChannelMask = ChatSettingConfig.Instance.GetChatSettingIntValue(ChatSettingIndex.DiyChannelMask);

            m_DiyChannelGroup.setWndView(this);
            m_DiyChannelGroup.Init();

            emoticonPanel.SetChatWndView(this);
            emoticonPanel.Init();
            emoticonBtn.onClick.AddListener(delegate { emoticonPanel.SwitchEmotionPanelActiveState(); });

            // 设置消息显示定时器
            TimerManager.SetTimer(this, (int)EChatTimer.EChatTimer_ShowChatMsg, 0.5f);
#if FUNCTION_AUTO_ADD_CHAT_OPEN
            TimerManager.SetTimer(this, (int)EChatTimer.EChatTimer_AddChatMsg, 1f);
#endif

            // 计算聊天框位置
            m_DownPos = GetTransform().anchoredPosition;
            m_UpPos   = new Vector3(m_DownPos.x, m_DownPos.y + 300, m_DownPos.z);

            // 初始化大小
            m_InitSize = new Vector2(GetTransform().sizeDelta.x, GetTransform().sizeDelta.y);


            m_isMin = false;

            inputField.onFocusChange.AddListener(OnFocus);

            fpsHintInitPosition = fpsSwitchHint.GetComponent <RectTransform>().anchoredPosition;


            m_PopupWndStatus = new Dictionary <int, bool>();

            m_fullWndStatus = new Dictionary <int, bool>();
            //m_ModalKey = 0;

            m_ChatBoxState = new ChatBoxBase(this);

            return(true);
        }