public void CalculateCellSpriteValue(int x, int y, DungeonCellType compareCellType) { int value = HorizontalAndVerticleSpriteValue(x, y, compareCellType) + DiagonalSpriteValue(x, y, compareCellType); //int value = HorizontalAndVerticleSpriteValue4Bit(x, y, compareCellType); dungeonGrid[x, y].spriteValue = value; }
int DiagonalSpriteValue(int x, int y, DungeonCellType compareCellType) { bool nwCell = true; bool neCell = true; bool swCell = true; bool seCell = true; if (y == mapHeight - 1) { nwCell = true; neCell = true; } else { if (x == 0) { neCell = true; } else if (x == mapWidth - 1) { nwCell = true; } else { nwCell = dungeonGrid[x - 1, y + 1].cellType == compareCellType; neCell = dungeonGrid[x + 1, y + 1].cellType == compareCellType; } } if (y == 0) { swCell = true; seCell = true; } else { if (x == 0) { seCell = true; } else if (x == mapWidth - 1) { swCell = true; } else { swCell = dungeonGrid[x - 1, y - 1].cellType == compareCellType; seCell = dungeonGrid[x + 1, y - 1].cellType == compareCellType; } } int value = 2 * ConvertBoolToInt(nwCell) + 8 * ConvertBoolToInt(neCell) + 128 * ConvertBoolToInt(swCell) + 32 * ConvertBoolToInt(seCell); return(value); }
int HorizontalAndVerticleSpriteValue4Bit(int x, int y, DungeonCellType compareCellType) { bool upCell; bool leftCell; bool rightCell; bool downCell; if (y == mapHeight - 1) { upCell = false; } else { upCell = dungeonGrid[x, y + 1].cellType == compareCellType; } if (x == 0) { leftCell = false; } else { leftCell = dungeonGrid[x - 1, y].cellType == compareCellType; } if (x == mapWidth - 1) { rightCell = false; } else { rightCell = dungeonGrid[x + 1, y].cellType == compareCellType; } if (y == 0) { downCell = false; } else { downCell = dungeonGrid[x, y - 1].cellType == compareCellType; } int value = 1 * ConvertBoolToInt(upCell) + 2 * ConvertBoolToInt(leftCell) + 4 * ConvertBoolToInt(rightCell) + 8 * ConvertBoolToInt(downCell); return(value); }
public void SetCellType(DungeonCellType type) { _cellType = type; }
public DungeonCell(DungeonCellType type) { _cellType = type; _fillType = DungeonCellFillType.NON; }