private void Edit_SetNextTile(int _colour) { m_editLayout.SetColour(m_cursorX, m_cursorY, _colour); m_layoutChanged = true; // forces the solver to restart when entering solve mode UpdateTileVisuals(m_cursorX, m_cursorY, _colour, false); Edit_MoveCursorToNextTile(); }
} // Update private void UpdateTileVisuals(int _x, int _y, int _tileColour, bool _highlightRemovedTiles) { // If _highlightRemovedTiles is true then we add a 'removed tile' prefab for any spaces that are now empty // but weren't at the last time this was called. Otherwise, empty spaces have no prefab. int index = _x + _y * Constants.EditableWidth; int prevColour = m_visibleLayout.GetColour(_x, _y); bool tileHasChanged = (prevColour != _tileColour) || // contents of tile has changed ((_tileColour == 0) && (_highlightRemovedTiles || (m_tiles[index] != null))); // tile remains empty but we're possibly toggling whether to highlight it or not if (tileHasChanged) { m_visibleLayout.SetColour(_x, _y, _tileColour); if (m_tiles[index] != null) { GameObject.Destroy(m_tiles[index].gameObject); } if ((_tileColour > 0) || (_highlightRemovedTiles && (prevColour != 0))) { GameObject prefab = (_tileColour > 0) ? m_tilePrefabs[_tileColour - 1] : m_removedTilePrefab; m_tiles[index] = GameObject.Instantiate(prefab).transform; m_tiles[index].parent = m_groundTiles[index]; m_tiles[index].localPosition = Vector3.zero; m_tiles[index].localRotation = Quaternion.identity; } else { m_tiles[index] = null; } } }