-
Notifications
You must be signed in to change notification settings - Fork 11
Sample FruitsMerge #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| { | ||
| await UniTask.Yield(); | ||
| if (cancellationToken.IsCancellationRequested) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider throwing an operation cancelled exception simply passing CT into yield
| /// RootLifetimeScope sets up the DI container for the game application, configuring essential components such as | ||
| /// the entry point (Bootstrap), controllers, and services. This setup ensures efficient dependency management and lifecycle handling during gameplay. | ||
| /// </summary> | ||
| public class RootLifetimeScope : LifetimeScope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider not to use LifetimeScope cause it's tied to unity engine lifecycle. Try to keep control code centric.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| protected override async UniTask OnFlowAsync(CancellationToken cancellationToken) | ||
| { | ||
| _view = await _factory.CreateAsync(_data.ResourceId, cancellationToken); | ||
| cancellationToken.ThrowIfCancellationRequested(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can safely remove all cancellationToken.ThrowIfCancellationRequested(), cause asynchronous operations you're using will throw an exception anyway
| /// Upon creation, each board is positioned randomly within a specified range and visually represented using asset | ||
| /// data obtained from FruitVisualisationProvider. | ||
| /// </summary> | ||
| public class FruitBoardFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems we need IFruitBoardFactory interface to follow Dependency inversion principle
| { | ||
| private const string ShowAnimationName = "AfterLevelScreen_Show"; | ||
|
|
||
| public Button RestartButton => _restartButton; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Controllers will be cleaner if we won't expose buttons and other ui components. We can expose button clicked event instead of button
| /// <summary> | ||
| /// AfterLevelScreenView is a MonoBehaviour, manages the view component displayed after completing a game level. | ||
| /// </summary> | ||
| public class AfterLevelScreenView : MonoBehaviour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need interfaces for views? If we need to test controllers, then yes
|
|
||
| protected override async UniTask OnFlowAsync(CancellationToken cancellationToken) | ||
| { | ||
| var prefab = await _resourcesProvider.LoadAsync<AfterLevelScreenView>("AfterLevelScreen", cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move the view creation flow to some factory?
|
|
||
| private async UniTask FlowAsync() | ||
| { | ||
| while (!CancellationToken.IsCancellationRequested) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to pass a cancellation token as a parameter
|
|
||
| public async UniTask InitializeAsync(CancellationToken cancellationToken) | ||
| { | ||
| GameConfiguration = await _resourcesProvider.LoadAsync<GameConfiguration>("GameConfiguration", cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the model a domain model? Seems it should not access _resourcesProvider. It is better to load the game configuration outside of the model (Controller) and pass it as a parameter
| private readonly ResourcesProvider _resourcesProvider; | ||
| private readonly IGameEventsRequestsModel _eventRequestsModel; | ||
|
|
||
| private FruitData[] _fruitsCollected; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor. _fruitsCollected is a good name for event. For field _collectedFruits will be better
WHAT Create sample for ControllersTree package