[Add] Resize board
This commit is contained in:
@@ -82,15 +82,16 @@ namespace Minesweeper.Presentation.Views
|
||||
}
|
||||
}
|
||||
|
||||
public void Render(BoardCellData cell, MinesweeperUiConfig config, float pixelsPerUnitMultiplier)
|
||||
public void Render(BoardCellData cell, MinesweeperUiConfig config, float pixelsPerUnitMultiplier, bool revealUnflaggedMines)
|
||||
{
|
||||
gameObject.name = $"bt_{cell.X}_{cell.Y}_{cell.DisplayValue}";
|
||||
isOpened = cell.IsOpened;
|
||||
var revealMine = revealUnflaggedMines && cell.IsMine && !cell.IsFlagged;
|
||||
|
||||
if (backgroundImage != null)
|
||||
{
|
||||
backgroundImage.pixelsPerUnitMultiplier = pixelsPerUnitMultiplier;
|
||||
backgroundImage.color = cell.IsOpened ? config.OpenedCellColor : config.ClosedCellColor;
|
||||
backgroundImage.color = cell.IsOpened || revealMine ? config.OpenedCellColor : config.ClosedCellColor;
|
||||
}
|
||||
|
||||
if (contentImage != null)
|
||||
@@ -98,7 +99,7 @@ namespace Minesweeper.Presentation.Views
|
||||
contentImage.pixelsPerUnitMultiplier = pixelsPerUnitMultiplier;
|
||||
}
|
||||
|
||||
RenderContent(cell, config);
|
||||
RenderContent(cell, config, revealMine);
|
||||
|
||||
if (button != null)
|
||||
{
|
||||
@@ -106,15 +107,16 @@ namespace Minesweeper.Presentation.Views
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderContent(BoardCellData cell, MinesweeperUiConfig config)
|
||||
private void RenderContent(BoardCellData cell, MinesweeperUiConfig config, bool revealMine)
|
||||
{
|
||||
var showFlag = cell.IsFlagged && !cell.IsOpened;
|
||||
var showMine = cell.IsOpened && cell.IsMine;
|
||||
var showMine = (cell.IsOpened && cell.IsMine) || revealMine;
|
||||
var showMineAsText = showMine && config.MineSprite == null;
|
||||
var showNumber = cell.IsOpened && !cell.IsMine && cell.NeighborMines > 0;
|
||||
|
||||
if (contentImage != null)
|
||||
{
|
||||
contentImage.gameObject.SetActive(showFlag || showMine);
|
||||
contentImage.gameObject.SetActive(showFlag || (showMine && !showMineAsText));
|
||||
if (showFlag)
|
||||
{
|
||||
contentImage.sprite = config.FlagSprite;
|
||||
@@ -129,8 +131,8 @@ namespace Minesweeper.Presentation.Views
|
||||
|
||||
if (label != null)
|
||||
{
|
||||
label.gameObject.SetActive(showNumber);
|
||||
label.text = showNumber ? cell.NeighborMines.ToString() : string.Empty;
|
||||
label.gameObject.SetActive(showNumber || showMineAsText);
|
||||
label.text = showMineAsText ? "M" : showNumber ? cell.NeighborMines.ToString() : string.Empty;
|
||||
label.color = config.GetNumberTextColor(cell.NeighborMines);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user