/// <summary> /// Intiliases the game, takes the cellBehaviours in the cellsList and arranges them in a 2d array for easier referencing when running the game of life. /// </summary> private void InitialiseGame() { float sqrtf = Mathf.Sqrt(DataHolder.instance.cellsParentTransform.childCount); int sqrt = (int)sqrtf; if (sqrtf != sqrt) { Debug.LogError("cell number isnt correct, has to be a perfect square"); return; } cellsHolder = new CellsHolder(); cellsHolder.cells = new CellBehaviour[sqrt][]; int idx = 0; int idx2 = 0; cellsHolder.cells[0] = new CellBehaviour[sqrt]; CellBehaviour cellBehaviour; for (int i = 0; i < DataHolder.instance.cellsParentTransform.childCount; i++, idx++) { if (idx == sqrt) { idx = 0; idx2++; cellsHolder.cells[idx2] = new CellBehaviour[sqrt]; } cellBehaviour = DataHolder.instance.cellsParentTransform.GetChild(i).GetComponent <CellBehaviour>(); cellBehaviour.i = idx2; cellBehaviour.j = idx; cellsHolder.cells[idx2][idx] = cellBehaviour; } DataHolder.instance.cellsHolder = cellsHolder; }
/// <summary> /// Initialising the game, spawns n x n grid for the game of life to run (WIP) /// </summary> /// <param name="n"></param> private void InitialiseGame(int n) { Camera.main.orthographicSize = (n / 2) * 1.3f; float initPosY = (n - 1) / 2; float initPosX = -initPosY; Vector2 pos = new Vector2(initPosX, initPosY); cellsHolder = new CellsHolder(); cellsHolder.cells = new CellBehaviour[n][]; GameObject cell; Debug.Log("initPos = " + pos); for (int i = 0; i < n; i++) { cellsHolder.cells[i] = new CellBehaviour[n]; for (int j = 0; j < n; j++) { cell = Instantiate(cellnXn, pos, Quaternion.identity, cellsHoldernXnTransform); Debug.Log("pos = " + pos + " i = " + i + " j = " + j); pos.x += 1; cellsHolder.cells[i][j] = cell.GetComponent <CellBehaviour>(); } pos.x = initPosX; pos.y--; } }
void Start() { cellsHolder = CellsHolder.GetCellsHolder(); players = new List <Player>(); chips = new List <Chip>(); InitializeField(); mode = GameMode.FigureMoving; }
void Start() { cellsHolder = CellsHolder.GetCellsHolder(); if (Mathf.RoundToInt(transform.rotation.eulerAngles.y) == 180 || Mathf.RoundToInt(transform.rotation.eulerAngles.y) == 0) { isLine = true; number = GameController.ZToI(transform.position.z); direction = -Mathf.RoundToInt(transform.position.x); } else if (Mathf.RoundToInt(transform.rotation.eulerAngles.y) == 90 || Mathf.RoundToInt(transform.rotation.eulerAngles.y) == 270) { isLine = false; number = GameController.XToJ(transform.position.x); direction = -Mathf.RoundToInt(transform.position.z); } }
void Start() { currentCamera = GetComponent <Camera>(); gameController = GameController.GetGameController(); cellsHolder = CellsHolder.GetCellsHolder(); }