Files
match3-unity/Assets/Scripts/Services/LevelEntryPoint.cs
2025-12-18 03:49:05 +08:00

33 lines
999 B
C#

using Services.Interfaces;
using UnityEngine;
using VContainer.Unity;
namespace Services
{
public class LevelEntryPoint : IStartable
{
private readonly IGameBoardService gameBoardService;
private readonly IInputService inputService;
public LevelEntryPoint(IGameBoardService gameBoardService, IInputService inputService)
{
this.gameBoardService = gameBoardService;
this.inputService = inputService;
}
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);
}
}
}