public void StartTalk(TalkCloudBase cloud, TalkData talkData) { if (!_isTalking) { _talkCloud = cloud; _talkCloud.Init(talkData.PagesCount); _talkCloud.OnCloudShown += OnCloudShown; _talkCloud.OnCloudHidden += OnCloudHidden; _talkData = talkData; _currentPage = _talkData.GetPage(_firstPage); _talkCloud.SetPage(_currentPage, _firstPage); if (_talkData) { _isTalking = true; _pageIndex = default; _isLastPage = default; _canShowNextPage = default; _writerControl.Init(_currentPage, _talkCloud.TextControl); _talkCloud.OnShowCloud(); _talkCallback?.Invoke(TalkEvent.Started); } else { Debug.LogError($"Talk Data is null"); } } }
//Call it when a talk is running and the language is changed to update the cloud talk with the new text. /// <summary>Call when the language is changed.</summary> public void SetTalkOnLanguageChanged(TalkInfo info) { if (_scriptableContainer) { if (_talkData) { _talkData = _scriptableContainer.Container.GetTalkAsset(info); _writerControl.Writer.OnLanguageChanged(_talkData.GetPage(_pageIndex)); } } else { Debug.LogError("Container reference wasn't added."); } }
/// <summary>Advance to the next page if all the text was writen.</summary> /// <returns>True if advanced to the next page.</returns> public bool NextPage() { if (_isTalking) { if (!_isLastPage) { if (_canShowNextPage) { _canShowNextPage = false; _pageIndex++; _talkCallback?.Invoke(TalkEvent.PageChanged); _currentPage = _talkData.GetPage(_pageIndex); _talkCloud.SetPage(_currentPage, _pageIndex); _writerControl.Init(_currentPage, _talkCloud.TextControl); _writerControl.Writer.WritePage(_currentPage); return(true); } else { //Do something random, while waiting to change to next page. } } else { _writerControl.Writer.OnExitTalk(); _talkCloud.CloseCloud(); } } else { Debug.LogError("Trying to advance to a next page without starting the conversation."); } return(false); }
private void SetTextPageIndex(int textPageIndex, TalkData talkData) { _data._pageIndex = textPageIndex; _data._currentTextPage = talkData.GetPage(_data._pageIndex); }