void HidePiece() { PieceComponent[] pieces = CurrentPiece.GetPieces(); for (int i = 0; i < pieces.Length; i++) { int finalX = Round(pieces[i].GetX()) + CurrentPiece.GetPositionX(); int finalY = Round(pieces[i].GetY()) + CurrentPiece.GetPositionY(); int finalZ = Round(pieces[i].GetZ()) + CurrentPiece.GetPositionZ(); if (GridX > finalX && finalX >= 0 && GridY > finalY && finalY >= 0 && GridZ > finalZ && finalZ >= 0) { TileLogic CurrentTileController = TileLiterals[finalX, finalY, finalZ].GetComponent(typeof(TileLogic)) as TileLogic; CurrentTileController.Hide(); } else { Debug.Log("Failed to remove at position: (" + finalX.ToString() + "," + finalY.ToString() + "," + finalZ.ToString() + ")"); } } }
/// <summary> /// Completely refreshes the rendering of the game board and sets NeedsUpdate to false. /// </summary> void UpdateBoard() { HidePiece(); for (int x = 0; x < GridX; x++) { for (int y = 0; y < GridY; y++) { for (int z = 0; z < GridZ; z++) { TileLogic CurrentTileController = TileLiterals[x, y, z].GetComponent(typeof(TileLogic)) as TileLogic; if (GameState[x, y, z]) { CurrentTileController.Show(); } else { CurrentTileController.Hide(); } } } } DrawPiece(); NeedsUpdate = false; }