Create All Needed Scripts

This commit is contained in:
2025-12-14 09:23:38 +08:00
parent 980b26dd5e
commit 6fe70bd113
53 changed files with 1988 additions and 195 deletions

View File

@@ -0,0 +1,27 @@
using Models.Interfaces;
using UnityEngine;
namespace Services {
public class GameBoard : IGameBoard {
private int height, width;
public int Height => this.height;
public int Width => this.width;
private 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 != null ? gameObject : null;
}
public void SetGemAt(Vector2Int pos, Gem gameObject) {
this.gemsGrid[pos.x, pos.y] = gameObject;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6a1125aa75474479a9ca0d8de4f6887c
timeCreated: 1765644440

View File

@@ -0,0 +1,26 @@
using Enums;
using UnityEngine;
namespace Services {
public class Gem {
private GemType type;
private Vector2Int position;
public GemType Type => this.type;
public Vector2Int Position => this.position;
private int scoreValue;
public int ScoreValue => this.scoreValue;
public bool isMatch = false;
public Gem(GemType type, Vector2Int position) {
this.type = type;
this.position = position;
}
public void SetPosition(Vector2Int position) {
this.position = position;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f3821a37fdec454f999de640213aa95e
timeCreated: 1765649448

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a806e20251e7471e8b7fd9d80c7d95a6
timeCreated: 1765649292

View File

@@ -0,0 +1,12 @@
using Services;
using UnityEngine;
namespace Models.Interfaces {
public interface IGameBoard {
int Width { get; }
int Height { get; }
Gem[,] GemsGrid { get; }
Gem GetGemAt(Vector2Int pos);
void SetGemAt(Vector2Int pos, Gem gameObject);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 83a1cf6a985d4d7092f2fc9044fbab8c
timeCreated: 1765632691