Create All Needed Scripts
This commit is contained in:
27
Assets/Scripts/Models/GameBoard.cs
Normal file
27
Assets/Scripts/Models/GameBoard.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Models/GameBoard.cs.meta
Normal file
3
Assets/Scripts/Models/GameBoard.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a1125aa75474479a9ca0d8de4f6887c
|
||||
timeCreated: 1765644440
|
||||
26
Assets/Scripts/Models/Gem.cs
Normal file
26
Assets/Scripts/Models/Gem.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Models/Gem.cs.meta
Normal file
3
Assets/Scripts/Models/Gem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3821a37fdec454f999de640213aa95e
|
||||
timeCreated: 1765649448
|
||||
3
Assets/Scripts/Models/Interfaces.meta
Normal file
3
Assets/Scripts/Models/Interfaces.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a806e20251e7471e8b7fd9d80c7d95a6
|
||||
timeCreated: 1765649292
|
||||
12
Assets/Scripts/Models/Interfaces/IGameBoard.cs
Normal file
12
Assets/Scripts/Models/Interfaces/IGameBoard.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Models/Interfaces/IGameBoard.cs.meta
Normal file
3
Assets/Scripts/Models/Interfaces/IGameBoard.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83a1cf6a985d4d7092f2fc9044fbab8c
|
||||
timeCreated: 1765632691
|
||||
Reference in New Issue
Block a user