public void SetUpWithGamePiece(Tile piece) { this.piece = piece; foreach (Coordinate pair in piece.squareInfo.Keys) { GameObject obj = Resources.Load("Prefabs/GameCell") as GameObject; GameObject instantiatedObj = GameObject.Instantiate(obj); instantiatedObj.transform.SetParent(transform); instantiatedObj.transform.localPosition = new Vector2(GameCellBehavior.TILE_SIZE * pair.row, GameCellBehavior.TILE_SIZE * pair.column); instantiatedObj.transform.localScale = Vector3.one; GameCellBehavior cellBehavior = instantiatedObj.GetComponent <GameCellBehavior>(); cellBehavior.InitializeWithGameCell(piece.squareInfo[pair]); } }
public void Initialize(GameBoardSquare square) { this.boardSquare = square; GameCell topCell = square.TopCell; if (topCell != null) { GameObject obj = Resources.Load("Prefabs/GameCell") as GameObject; GameObject instantiatedObj = GameObject.Instantiate(obj); instantiatedObj.transform.SetParent(transform); instantiatedObj.transform.localPosition = Vector2.zero; instantiatedObj.transform.localScale = Vector2.one; GameCellBehavior cellBehavior = instantiatedObj.GetComponent <GameCellBehavior>(); cellBehavior.InitializeWithGameCell(topCell); this.AddGameCell(cellBehavior); } }