Files
match3-unity/Assets/Scripts/Services/LevelEntryPoint.cs

39 lines
1.3 KiB
C#

using Presenter;
using Services.Interfaces;
using UnityEngine;
using VContainer.Unity;
using Views;
namespace Services
{
public class LevelEntryPoint : IStartable
{
private readonly IObjectPool<GemView> gemViewPool;
private readonly IGameBoardService gameBoardService;
private readonly IInputService inputService;
private readonly AudioPresenter audioPresenter;
public LevelEntryPoint(IObjectPool<GemView> gemViewPool, IGameBoardService gameBoardService, IInputService inputService, AudioPresenter audioPresenter)
{
this.gemViewPool = gemViewPool;
this.gameBoardService = gameBoardService;
this.inputService = inputService;
this.audioPresenter = audioPresenter;
}
public void Start()
{
this.gameBoardService.Setup();
this.inputService.OnSwapRequested += HandleSwapRequest;
this.inputService.OnSwitchRequested += HandleSwitchRequest;
}
private void HandleSwapRequest(Vector2Int from, Vector2Int to) {
this.gameBoardService.TrySwap(from, to);
}
private void HandleSwitchRequest(Vector2Int position) {
this.gameBoardService.TrySwitch(position);
}
}
}