private void InitBoxGrid() { Debug.Log("InitBoxGrid()"); // Give size of boxes card.GetComponent <RectTransform>().sizeDelta = new Vector2(_boxSize, _boxSize); for (int i = 0; i < grid; i++) { // Reset the gap on the x axis every new column if (grid == 5) { _gapX = _boxOffset * (grid + 1); } else if (grid == 4) { _gapX = _boxOffset * (grid - 1); } else { _gapX = _boxOffset * grid; } for (int j = 0; j < grid; j++) { _box = Instantiate(card, new Vector3(_gapX, _boxGridHeight, 0), Quaternion.identity) as GameObject; _box.transform.SetParent(cardBorder.transform, false); _box.name = _colCount + "" + _rowCount; _boxScript = _box.GetComponent <TagBoxMp>(); _boxScript.boxColNum = _colCount; _boxScript.boxRowNum = _rowCount; // Update gap on X axis after evey box _gapX += _boxSize + _boxOffset * 2; _rowCount++; } _boxGridHeight += _boxSize + _boxOffset; _colCount++; _rowCount = 0; } if (grid == 5) { _gapX = _boxSize / 3 - _boxOffset; } else if (grid == 4) { _gapX = _boxOffset * (grid - 1); } else { _gapX = _boxOffset * grid; } _boxGridHeight = 50; _cardBorderTopGap = _boxGridHeight; }
public void MarkBox(int playerIndex, int boxColNum, int boxRowNum) { if (playerIndex == _playerIndex) { isMyTurn = false; return; } _box = GameObject.Find(boxColNum + "" + boxRowNum); _boxScript = _box.GetComponent <TagBoxMp>(); _boxScript.UseBox(playerIndex); ChangePlayer(); isMyTurn = true; IsGameOver(); }