Example #1
0
    /// <summary>
    /// 创建信息item
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public DialogueBoxWeChatMessageItem CreationDialogueBoxWeChatMessageItem(ChapterDialogueTextDefine data)
    {
        RectTransform itemTra = GameObject.Instantiate(_messageItem.gameObject, _contentRect).GetComponent <RectTransform>();
        DialogueBoxWeChatMessageItem dialogueBoxWeChatMessageItem = new DialogueBoxWeChatMessageItem();

        dialogueBoxWeChatMessageItem.Initial(itemTra, IsProtagonist(data.NameID), data, ClickIcon, ImageClick);
        LayoutRebuilder.ForceRebuildLayoutImmediate(_contentRect);
        return(dialogueBoxWeChatMessageItem);
    }
Example #2
0
    /// <summary>
    /// 展示聊天数据
    /// </summary>
    /// <param name="data"></param>
    public override async UniTask Show(ChapterDialogueTextDefine data)
    {
        await base.Show(data);

        DialogueBoxWeChatMessageItem item = CreationDialogueBoxWeChatMessageItem(data);

        _dialogueBoxWeChatMessageItems.Add(item);
        await UniTask.Delay(TimeSpan.FromMilliseconds(300));

        _roleSpeakRearAction?.Invoke(data);
        //_scrollRect.verticalScrollbar.value = 0;
        await BottomOut();

        if (data.IsClick)
        {
            _isClikc = false;
        }
        //Debug.Log("关闭旧对话");
        await UniTask.WaitUntil(() => _isClikc);

        if (data.NextDialogId == 0 && (data.DialogIdList == null || data.DialogIdList.Count <= 0))
        {
            Debug.Log("对话结束");
            if (_isOut)
            {
                OpenOutBtn(true);
            }
            else
            {
                _endAction?.Invoke();
            }
        }
        else
        {
            List <ChapterDialogueTextDefine> datas = new List <ChapterDialogueTextDefine>();

            if (data.NextDialogId != 0)
            {
                datas.Add(ChapterTool.GetChapterData(data.NextDialogId));
            }
            else if (data.DialogIdList != null && data.DialogIdList.Count >= 0)
            {
                for (int i = 0; i < data.DialogIdList.Count; i++)
                {
                    ChapterDialogueTextDefine dataDefine = ChapterTool.GetChapterData(data.DialogIdList[i]);
                    datas.Add(dataDefine);
                }
            }
            await UniTask.Delay(TimeSpan.FromMilliseconds(_replyInterval));

            ConnectTheNextLine(datas);
        }
    }