public TokenPiece(Board board, int row, int column, Cell cell) { this.board = board; this.row = row; this.column = column; this.cell = cell; }
public SkullToken(Board board, int row, int column) { piece = new TokenPiece[1]; Cell cell = new Cell(); cell.color = CellColor.SKULL; piece[0] = new TokenPiece(board, row, column, cell); }
public BombToken(Board board, int row, int column) { piece = new TokenPiece[1]; Cell cell = new Cell(); cell.color = CellColor.BOMB; piece[0] = new TokenPiece(board, row, column, cell); }
public TokenGenerator(Board board, Level level, Random random) { this.board = board; this.level = level; this.random = random; this.nextToken = null; LoadNextToken(); }
public Token GetRandomToken(Board board, CellColor color1, CellColor color2, Random random) { if (sums.Count == 0) { throw new Exception("Tried to get a random token from the empty set."); } double number = random.NextDouble() * sums[sums.Count - 1].sum; for (int i = 0; i < sums.Count - 1; ++i) { if (number < sums[i].sum) { return sums[i].factory(board, color1, color2); } } return sums[sums.Count - 1].factory(board, color1, color2); }
public TwoPieceToken(Board board, int row, int column, CellColor color1, CellColor color2) { piece = new TokenPiece[2]; Cell cell1 = new Cell(); Cell cell2 = new Cell(); cell1.color = color1; cell2.color = color2; cell1.direction = Cell.Direction.RIGHT; cell2.direction = Cell.Direction.LEFT; piece[0] = new TokenPiece(board, row, column, cell1); piece[1] = new TokenPiece(board, row, column + 1, cell2); orientation = 0; }
public SinglePlayer(PlayerIndex player, Level level, Random random, bool singlePlayer, GameListener listener) { this.player = player; this.level = level; this.random = random; this.singlePlayer = singlePlayer; this.listener = listener; this.paused = false; this.otherPaused = false; nextTokenReadiness = 0.0f; board = new Board(); tokenGenerator = new TokenGenerator(board, level, random); dumps = new CellColor[Constants.COLUMNS]; matches = new List<CellColor>(); state = State.SETTING_UP_BOARD; pauseMenu = new Menu(singlePlayer || (player == PlayerIndex.One), singlePlayer || (player == PlayerIndex.Two), delegate() { paused = false; listener.OnPaused(player, paused); }); pauseMenu.Add("Continue", delegate() { paused = false; listener.OnPaused(player, paused); }); pauseMenu.Add("Exit", delegate() { paused = false; otherPaused = false; listener.OnPaused(player, false); listener.OnFinished(player, null); }); wonMenu = new Menu(singlePlayer || (player == PlayerIndex.One), singlePlayer || (player == PlayerIndex.Two), delegate() { }); wonMenu.Add("Continue", delegate() { listener.OnFinished(player, null); }); wonMenu.Add("Retry", delegate() { listener.OnFinished(player, level); }); wonMenu.Add("Exit", delegate() { listener.OnFinished(player, null); }); failedMenu = new Menu(singlePlayer || (player == PlayerIndex.One), singlePlayer || (player == PlayerIndex.Two), delegate() { }); failedMenu.Add("Retry", delegate() { listener.OnFinished(player, level); }); failedMenu.Add("Exit", delegate() { listener.OnFinished(player, null); }); }
public ThreePieceElbowToken(Board board, int row, int column, CellColor color1, CellColor color2, CellColor color3) { piece = new TokenPiece[3]; Cell cell1 = new Cell(); Cell cell2 = new Cell(); Cell cell3 = new Cell(); cell1.color = color1; cell2.color = color2; cell3.color = color3; cell1.direction = Cell.Direction.RIGHT; cell2.direction = Cell.Direction.LEFT | Cell.Direction.DOWN; cell3.direction = Cell.Direction.UP; piece[0] = new TokenPiece(board, row, column, cell1); piece[1] = new TokenPiece(board, row, column + 1, cell2); piece[2] = new TokenPiece(board, row + 1, column + 1, cell3); orientation = 0; }
public FourPieceZToken(Board board, int row, int column, CellColor color1, CellColor color2, CellColor color3, CellColor color4) { piece = new TokenPiece[4]; Cell cell1 = new Cell(); Cell cell2 = new Cell(); Cell cell3 = new Cell(); Cell cell4 = new Cell(); cell1.color = color1; cell2.color = color2; cell3.color = color3; cell4.color = color4; cell1.direction = Cell.Direction.RIGHT; cell2.direction = Cell.Direction.LEFT | Cell.Direction.DOWN; cell3.direction = Cell.Direction.UP | Cell.Direction.RIGHT; cell4.direction = Cell.Direction.LEFT; piece[0] = new TokenPiece(board, row, column, cell1); piece[1] = new TokenPiece(board, row, column + 1, cell2); piece[2] = new TokenPiece(board, row + 1, column + 1, cell3); piece[3] = new TokenPiece(board, row + 1, column + 2, cell4); orientation = 0; }
public void SetupBoard(Board board, Random random) { List<Cell> cells = PatternParser.ParseExpression(pattern, random); int start = Constants.ROWS * Constants.COLUMNS - cells.Count; if (start < 0) { start = 0; } int offset = 0; for (int row = 0; row < Constants.ROWS; row++) { for (int column = 0; column < Constants.COLUMNS; column++) { board.GetCell(row, column).Clear(); if (offset >= start) { CellColor color = cells[offset - start].color; if (color != CellColor.BLACK) { board.GetCell(row, column).color = color; board.GetCell(row, column).locked = cells[offset - start].locked; } } ++offset; } } }
public Token GetRandomToken(Board board, Random random) { CellColor color1 = GetRandomColor(random); CellColor color2 = GetRandomColor(random); return tokens.GetRandomToken(board, color1, color2, random); }