/// <summary> /// 默认展示第一句 /// </summary> public override void Show() { base.Show(); OpenOutBtn(false); List <ChapterDialogueTextDefine> datas = new List <ChapterDialogueTextDefine>(); if (_dialogueData._Data.NextDialogId == 0 && (_dialogueData._Data.DialogIdList != null && _dialogueData._Data.DialogIdList.Count > 0)) { for (int i = 0; i < _dialogueData._Data.DialogIdList.Count; i++) { datas.Add(ChapterTool.GetChapterData(_dialogueData._Data.DialogIdList[i])); } } else { datas.Add(_dialogueData._Data); } if (IsProtagonist(_dialogueData._Data.NameID)) { CreationBtn(datas); } else { Show(_dialogueData._Data); } }
/// <summary> /// 点击背景 /// </summary> public override async UniTask ClickBtn() { base.ClickBtn(); if (_isPrinTing) { if (!_cancellationTokenSource.Token.IsCancellationRequested) { _cancellationTokenSource.Cancel(); } _showText.text = ChapterTool.GetDialogueString(_dialogueData._Data); ShowEnd(); } else { if (_isEnd) { _endAction?.Invoke(); } else { SetDialogType(_dialogueData._Data); string dialogueNameData = ChapterTool.GetChapterFunctionString(_dialogueData._Data.NameID); await ShowStr(ChapterTool.GetDialogueString(_dialogueData._Data), dialogueNameData); } } }
/// <summary> /// 人物说话前回调(环顾四周) /// </summary> /// <param name="data"></param> public async void SpeakBeforeAction(ChapterDialogueTextDefine data) { if (data.ID == 12000035) { await ChapterTool.FadeInFadeOut(_bgs[0], 0, fadeOut); } }
/// <summary> /// 刷新底部栏高度 /// </summary> /// <param name="type"></param> public async UniTask RefreshBottom(int type) { RectTransform tageRect = null; switch (type) { case 0: tageRect = _btnBoxRect; break; case 1: tageRect = _ImagBoxRect; break; case 2: Debug.Log("还原底部栏"); break; } float height = 0; if (tageRect != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(tageRect); Debug.Log("底部按钮内容栏高:" + tageRect.sizeDelta); await UniTask.DelayFrame(1); height = _controlStripRect.sizeDelta.y + tageRect.sizeDelta.y; } else { height = _controlStripRect.sizeDelta.y; } RefreshContentRectSize(height); await ChapterTool.ChangeUiSize(_bottomRect, new Vector2(_bottomRect.sizeDelta.x, height), 50f, 0.01f, null, () => { Debug.Log("尺寸更改完毕"); }); }
/// <summary> /// 获取番外对话文本内容 /// </summary> /// <param name="data"></param> /// <returns></returns> public static string GetOADDialogueString(OADDialogueTextDefine data) { string str = ""; switch (StaticData.linguisticType) { case LinguisticType.Simplified: str = data.SimplifiedChinese; break; case LinguisticType.Complex: str = data.TraditionalChinese; break; case LinguisticType.English: str = data.English; break; default: str = data.SimplifiedChinese; break; } str = string.Format(str, StaticData.playerInfoData.userInfo.Name); string strTwo = ChapterTool.SetLineFeed(str, data.StringNumber); return(strTwo); }
//显示选项按钮 void ShowOption() { Option.gameObject.SetActive(true); option1.transform.Find("Text").GetComponent <Text>().text = ChapterTool.GetDialogueString(12000026); option2.transform.Find("Text").GetComponent <Text>().text = ChapterTool.GetDialogueString(12000027); option1.onClick.AddListener(() => { //增加好感 ImpulseHelper.OptionAddFavorable(12000026); Option.gameObject.SetActive(false); _dialogueFive.SetStartDialogueId(12000026); _dialogueFive.Initial(() => { _dialogueFive.Close(); NextStep(); }, SpeakAeforeAction_Five); _dialogueFive.Show(); }); option2.onClick.AddListener(() => { Option.gameObject.SetActive(false); _dialogueFive.SetStartDialogueId(12000027); _dialogueFive.Initial(() => { _dialogueFive.Close(); NextStep(); }, SpeakAeforeAction_Five); _dialogueFive.Show(); }); }
async void ShowOneScene() { await ChapterTool.MoveUi(_oneScene.Find("bg") as RectTransform, new Vector2(-843f, 0f), 0.1f, 0.1f, null, () => { ClickBtn(); }); }
/// <summary> /// 创建章节 /// </summary> /// <param name="chapterID"></param> /// <returns></returns> private static async System.Threading.Tasks.Task CreateChapter(int chapterID, bool isManor = false) { CSEntranceSection cSEntranceSection = new CSEntranceSection() { SectionId = chapterID }; ProtocalManager.Instance().SendCSEntranceSection(cSEntranceSection, (SCEmptyEntranceSection sCEmptyEntranceSection) => { Debug.Log("进入" + chapterID + "章记录成功"); }, (ErrorInfo e) => { Debug.LogError(e.ErrorMessage); }); if (!isManor) { await CreateChapterTitle(chapterID); } //消除红点 ReduceRedDot(chapterID, true); //播放章节背景音乐 GameSoundPlayer.Instance.PlayBgMusic(MusicHelper.BgMusicChapter); ChapterTool.LoadChapterManager(chapterID - StaticData.configExcel.Section[0].SectionId); //进入章节后移除章节列表 重章节里回来后再出列表 UIComponent.RemoveUI(UIType.UIChapter); }
async void ShowTwoScene() { await ChapterTool.FadeInFadeOut(_oneScene.GetComponent <CanvasGroup>(), 0, 0.3f, null, () => { caricaturePlayerController.Initial(OnclickNextBtn, CaricatureChanged); }); }
public void UpdateList(int unlockMaxChapterID, int passMaxChapterID) {//i[0]为默认章节 Clear(); for (int i = 0; i < _mainCount; i++) {//判断每个章节是否已经解锁 ChapterItem ci = Instantiate(item).GetComponent <ChapterItem>(); chapterItems.Add(ci); //敬请期待 if (i == _mainCount - 1) { SetParent(ci.gameObject.transform, scrollRect.content); //SetParent(ci.gameObject.transform, loop.content); ci.Set(998, $"敬请期待", $"敬请期待", null, false, false, false, false, 9999, UnlockChapter); return; } var section = StaticData.configExcel.GetSectionBySectionId(StaticData.configExcel.Section[0].SectionId + i); //是否显示为解锁状态 配置表里的章节id与服务器记录的最大解锁章节id 比较 bool isUnlock = section.SectionId <= unlockMaxChapterID || section.SectionGrade <= StaticData.GetPlayerLevelByExp() ? true : false; //已解锁章节ID必定 >= 已通过章节ID //是否观看完毕 配置表里的章节id与服务器记录的最大已观看章节id 比较 bool isWatchOver = section.SectionId <= passMaxChapterID ? true : false; bool isBeforeUnlock = section.SectionId - 1 <= unlockMaxChapterID ? true : false; bool isBeforeWatchOver = section.SectionId <= passMaxChapterID + 1 || section.SectionId == StaticData.configExcel.Section[0].SectionId ? true : false; //设置Item基础属性 ci.Set(section.SectionId, ChapterTool.GetChapterFunctionString(section.SectionNumber), ChapterTool.GetChapterFunctionString(section.SectionNameId), section.Icon, isUnlock, isWatchOver, isBeforeUnlock, isBeforeWatchOver, section.SectionGrade, UnlockChapter); SetParent(ci.gameObject.transform, scrollRect.content); ci.name = $"Chapter{i}"; } }
void ReadOverThisChapter() { nextText.text = ChapterTool.GetChapterFunctionString(10000000);//下一章 nextBtn.gameObject.SetActive(true); ChapterModuleManager._Instance.ClickEndChapterBtn(nextBtn, NextStep); //条漫阅读结束后即刻请求保存读完 ChapterModuleManager._Instance.RequestPassChapter(); }
private async void Close() { await ChapterTool.FadeInFadeOut(_thisCanvasGroup, 0, 0.1f, null, () => { gameObject.SetActive(false); _endAction?.Invoke(); }); }
//和司机聊天 async void ChatDriver() { await ChapterTool.OpenDialogueBoxWeChat(15000105, 10000001, 10000058, () => { Debug.Log("微信聊天完毕!进入下一部分"); NextStep(); }); }
async void ShowThreeScene() { await ChapterTool.FadeInFadeOut(_twoScene.GetComponent <CanvasGroup>(), 0, 0.1f, null, () => { _twoScene.GetComponent <CanvasGroup>().blocksRaycasts = false; ClickBtn(); }); }
/// <summary> /// 步骤切换 /// </summary> /// <param name="index"></param> public async void StepCut(int index) { switch (index) { case 0: await ChapterTool.MoveUi(_oneRect, new Vector2(1320.1f, 0), 0.1f, 0.1f, null, () => { _phoneBtn.enabled = true; _phoneBtn.gameObject.SetActive(true); }); break; } }
/// <summary> /// 关闭人物对话框 /// </summary> /// <returns></returns> public async UniTask CloseShowText() { if (_boxBgRect.gameObject.activeSelf) { await ChapterTool.ChangeUiScale(_boxBgRect, Vector3.zero, 0.1f, 10, null, () => { _roleDialogueBoxCloseAction?.Invoke(_dialogueData._Data); _boxBgRect.gameObject.SetActive(false); }); } }
void ShowInfo() { QRCode_name_text.text = ChapterTool.GetChapterFunctionString(10000005); QRCode_region_text.text = ChapterTool.GetChapterFunctionString(10000537); name_text.text = ChapterTool.GetChapterFunctionString(10000005); region_text.text = ChapterTool.GetChapterFunctionString(10000537); set_text.text = ChapterTool.GetChapterFunctionString(10000538); friend_text.text = ChapterTool.GetChapterFunctionString(10000539); more_text.text = ChapterTool.GetChapterFunctionString(10000540); addFriend_text.text = ChapterTool.GetChapterFunctionString(10000536); }
/// <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); } }
/// <summary> /// 刷新内容栏尺寸 /// </summary> public async void RefreshContentRectSize(float bottomRectHeight) { float a = 1242f * Screen.height / Screen.width; //最大高度 float maxheight = a;// _thisRect.rect.height; float height = maxheight - _topRect.sizeDelta.y - bottomRectHeight; await ChapterTool.ChangeUiSize(_chatWindowRect, new Vector2(_chatWindowRect.sizeDelta.x, height), 100f, 0.01f, null, () => { _scrollRect.verticalScrollbar.value = 0; }); }
//显示场景4的两张条漫 void ShowFourScene() { fourCaricature.Initial(() => { //显示下一章按钮 nextChapterText.text = ChapterTool.GetChapterFunctionString(10000000);//下一章 nextChapterBtn.gameObject.SetActive(true); ChapterModuleManager._Instance.ClickEndChapterBtn(nextChapterBtn, NextStep); //请求这一章读完 ChapterModuleManager._Instance.RequestPassChapter(); }, null); }
//打开聊天页面 async System.Threading.Tasks.Task OpenChatView() {//注册按钮事件 //打开聊天 await ChapterTool.OpenDialogueBoxWeChat(10000008, 10000001, 10000002, () => { Debug.Log("微信聊天完毕!"); walk_image.gameObject.SetActive(false); //ShowVerticalCartoon(); ClickBtn(); }); }
//显示场景2的两张条漫 void ShowTwoScene() { ChapterTool.FadeInFadeOut(_oneScene.GetComponent <CanvasGroup>(), 0, 0.1f, null, () => { _oneScene.GetComponent <CanvasGroup>().blocksRaycasts = false; }); twoCaricature.Initial(() => { //OpenClickBtn(true); ShowThreeScene(); }, playMonitor); }
/// <summary> /// 创建章节标题 /// </summary> /// <param name="chapterID"></param> /// <returns></returns> public static async System.Threading.Tasks.Task CreateChapterTitle(int chapterID) { var title = await UIComponent.CreateUIAsync(UIType.ChapterTitle, true); title.transform.SetRectTransformStretchAllWithParent(UIRoot.instance.GetUIRootCanvasTop().transform); ChapterTitle chapterTitle = title.GetComponent <ChapterTitle>(); var section = StaticData.configExcel.GetSectionBySectionId(chapterID); string titleStr = ChapterTool.GetChapterFunctionString(section.SectionTitle[0]); string titleContent = ChapterTool.GetChapterFunctionString(section.SectionTitle[1]); chapterTitle.Play(titleStr, titleContent); }
/// <summary> /// 展示对话 /// </summary> /// <param name="data"></param> public async void Show(ChapterFunctionTextDefine data) { await UniTask.WaitUntil(() => !_roleSpeakAeforeAwait); _showText.text = ChapterTool.GetChapterFunctionString(data.ID); _boxBgRect.gameObject.SetActive(true); RefreshGroup(); await ChapterTool.ChangeUiScale(_boxBgRect, Vector3.one, 0.1f, 10); _roleSpeakRearTwoAction?.Invoke(_dialogueData._FunctionData); }
//显示场景3 async void ShowThree() { await ChapterTool.FadeInFadeOut(_twoScene.GetComponent <CanvasGroup>(), 0, 1f, null, () => { dialogueBox_three.Initial(() => { dialogueBox_three.Close(); ClickBtn(); Debug.Log("对话完毕"); }, ThreeSpeakBeforeAction, null); dialogueBox_three.Show(); }); }
async void ShowTwoScene() { await ChapterTool.FadeInFadeOut(_oneScene.GetComponent <CanvasGroup>(), 0, 0.1f, null, () => { _oneScene.GetComponent <CanvasGroup>().blocksRaycasts = false; dialogueBoxBubble_two.Initial(() => { dialogueBoxBubble_two.Close(); ClickBtn(); }, BeforeTwoDialogue, AfterTwoDialogue, null, BoxCloseBefore); dialogueBoxBubble_two.Show(); }); }
public async override void MoveEnd() { await ChapterTool.MoveUi(bg, new Vector2(-517.5f, 0f), 0.1f, 0.1f, null, () => { DialogueBox_two.Initial(() => { DialogueBox_two.Close(); }, DialogueBeforeAction); DialogueBox_two.Show(); }); base.MoveEnd(); }
//显示侧面3人 async void ShowThreeScene() { await ChapterTool.FadeInFadeOut(_twoScene.GetComponent <CanvasGroup>(), 0, 1f, null, () => { _dialogueThree.Initial(() => { Debug.Log("对话完毕"); ClickBtn(); _dialogueThree.Close(); }, SpeakBeforeAction_Three, SpeakAfterAction_Three); }); _dialogueThree.Show(); }
async void MoveThreeScene() { RectTransform bg = _threeScene.Find("Image_1") as RectTransform; await ChapterTool.MoveUi(bg, new Vector2(-929.71f, 0), 0.1f, 0.1f, null, () => { threeubbleComponent.Initial(() => { ClickBtn(); threeubbleComponent.Close(); }); }); threeubbleComponent.Show(); }
//显示3人走路 async void ShowTwoScene() { await ChapterTool.FadeInFadeOut(_oneScene.GetComponent <CanvasGroup>(), 0, 0.1f, null, () => { _dialogueTwo.Initial(() => { Debug.Log("对话完毕"); ClickBtn(); _dialogueTwo.Close(); }, SpeakAeforeAction_Two, null, SpeakCloseAction_Two); }); _dialogueTwo.Show(); }