Created
November 10, 2023 05:04
-
-
Save trungnhm1998/d0afba1b4d9b9c5157ef055fc99ea936 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using CryptoQuest.Battle.UI.Logs; | |
using UnityEngine; | |
using UnityEngine.Localization; | |
using UnityEngine.ResourceManagement.AsyncOperations; | |
namespace CryptoQuest.Battle.Presenter.Commands | |
{ | |
public class PresentLogCommand : IPresentCommand | |
{ | |
private readonly LocalizedString _message; | |
private readonly LogPresenter _presenter; | |
private string _loadedMessage; | |
private AsyncOperationHandle<string> _handle; | |
public PresentLogCommand(LogPresenter presenter, LocalizedString message) | |
{ | |
_presenter = presenter; | |
_message = message; | |
} | |
public IEnumerator Load() | |
{ | |
_handle = _message.GetLocalizedStringAsync(); | |
yield return _handle; | |
_loadedMessage = _handle.Result; | |
} | |
public IEnumerator Present() | |
{ | |
if (_handle.IsValid() && _handle.IsDone == false) | |
yield return _handle; | |
_loadedMessage = _handle.Result; | |
_presenter.Append(_loadedMessage); | |
yield return new WaitForSeconds(_presenter.DelayBetweenLines); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment