Files
match3-unity/Assets/Scripts/Scopes/LevelLifetimeScope.cs

52 lines
1.8 KiB
C#

using Models.Interfaces;
using Presenter;
using ScriptableObjects;
using Services;
using Services.Interfaces;
using UnityEngine;
using VContainer;
using VContainer.Unity;
using Views;
namespace Scopes
{
public class LevelLifetimeScope : LifetimeScope
{
[SerializeField] private GameVariables gameVariables;
[SerializeField] private Transform gemsHolder;
[SerializeField] private Transform backgroundHolder;
protected override void Configure(IContainerBuilder builder)
{
//Register variables
builder.RegisterInstance(this.gameVariables);
builder.RegisterInstance(this.gemsHolder);
//Register component
builder.RegisterComponentInHierarchy<ScoreView>();
builder.Register<IGameBoard>(_ =>
new GameBoard(this.gameVariables.width, this.gameVariables.height),
Lifetime.Scoped);
//Register Services
builder.Register<IMatchService, MatchService>(Lifetime.Scoped);
builder.Register<IScoreService, ScoreService>(Lifetime.Scoped);
builder.Register<IBombService, BombService>(Lifetime.Scoped);
//Register Pool
builder.Register<IObjectPool<GemView>>(_ =>
new ObjectPoolService(this.gameVariables.gemsPrefabs, this.gemsHolder),
Lifetime.Scoped);
//Presenters
builder.Register<AudioPresenter>(Lifetime.Scoped);
builder.Register<ScorePresenter>(Lifetime.Scoped);
builder.Register<IGameBoardService, GameBoardService>(Lifetime.Scoped).AsImplementedInterfaces();
//Entry Point
builder.RegisterEntryPoint<LevelEntryPoint>();
}
}
}