Fix Object Instantiating
This commit is contained in:
39
Assets/Scripts/Scopes/LevelLifetimeScope.cs
Normal file
39
Assets/Scripts/Scopes/LevelLifetimeScope.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Models;
|
||||
using Models.Interfaces;
|
||||
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;
|
||||
|
||||
protected override void Configure(IContainerBuilder builder)
|
||||
{
|
||||
builder.RegisterInstance(this.gameVariables);
|
||||
builder.RegisterInstance(this.gemsHolder);
|
||||
|
||||
builder.Register<IGameBoard>(c =>
|
||||
new GameBoard(this.gameVariables.width, this.gameVariables.height),
|
||||
Lifetime.Scoped);
|
||||
|
||||
builder.Register<IMatchService, MatchService>(Lifetime.Scoped);
|
||||
builder.Register<IScoreService, ScoreService>(Lifetime.Scoped);
|
||||
|
||||
builder.Register<IObjectPool<GemView>>(c =>
|
||||
new ObjectPoolService(this.gameVariables.gemsPrefabs, this.gemsHolder, this.gameVariables.width * this.gameVariables.height),
|
||||
Lifetime.Scoped);
|
||||
|
||||
builder.Register<IGameBoardService, GameBoardService>(Lifetime.Scoped);
|
||||
|
||||
builder.RegisterEntryPoint<LevelEntryPoint>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user