Files
match3-unity/Assets/Scripts/Models/GameBoard.cs
2025-12-17 00:55:30 +08:00

27 lines
801 B
C#

using Models.Interfaces;
using UnityEngine;
namespace Services {
public class GameBoard : IGameBoard {
private readonly int height, width;
public int Height => this.height;
public int Width => this.width;
private readonly Gem[,] gemsGrid;
public Gem[,] GemsGrid => this.gemsGrid;
public GameBoard(int width, int height) {
this.height = height;
this.width = width;
this.gemsGrid = new Gem[width, height];
}
public Gem GetGemAt(Vector2Int pos) {
Gem gameObject = this.gemsGrid[pos.x, pos.y];
return gameObject;
}
public void SetGemAt(Vector2Int pos, Gem gameObject) {
this.gemsGrid[pos.x, pos.y] = gameObject;
}
}
}