-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCell_Setup.cs
More file actions
31 lines (28 loc) · 975 Bytes
/
Cell_Setup.cs
File metadata and controls
31 lines (28 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cell_Setup : MonoBehaviour
{
public static Cell[,] cellArray;
[SerializeField] private int rows = 6;
[SerializeField] private int collumns = 4;
[SerializeField] private Cell cellPrefab;
private void Awake()
{
cellArray = new Cell[rows, collumns];
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < collumns; col++)
{
float yPos = row;
float xPos = col;
Cell newCell = Instantiate(cellPrefab, new Vector3(xPos, yPos), cellPrefab.transform.rotation);
newCell.isEmpty = true;
newCell.transform.SetParent(gameObject.transform);
newCell.row = row;
newCell.col = col;
cellArray[row, col] = newCell;
}
}
}
}