public MultiPlayer(Level level, int randomSeed, StatsTracker stats, GameListener listener) { this.stats = stats; this.listener = listener; one = new SinglePlayer(PlayerIndex.One, level, new Random(randomSeed), false, this); two = new SinglePlayer(PlayerIndex.Two, level, new Random(randomSeed), false, this); }
public void AddNewRow(Level level, Random random) { rowOffset = (rowOffset + 1) % Constants.ROWS; int bottomRow = ((Constants.ROWS - 1) + rowOffset) % Constants.ROWS; for (int i = 0; i < Constants.COLUMNS; ++i) { entries[bottomRow, i].color = level.GetRandomColor(random); } }
public TokenGenerator(Board board, Level level, Random random) { this.board = board; this.level = level; this.random = random; this.nextToken = null; LoadNextToken(); }
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 void OnFinished(PlayerIndex player, Level level) { Sound.StopMusic(); if (level != null) { int randomSeed = (new Random()).Next(); if (singlePlayer) { model = new SinglePlayer(PlayerIndex.One, level, new Random(randomSeed), true, this); } else { model = new MultiPlayer(level, randomSeed, stats, this); } state = State.PLAYING; Sound.StartMusic(); } else { state = State.SUB_MENU; } }
public void Setup(Level level, Random random) { level.SetupBoard(this, random); MarkMatches(); ClearMatches(); }
public void OnFinished(PlayerIndex player, Level level) { listener.OnFinished(player, level); }
public LevelMenuItem(int number, Level level, MenuAction action) { this.number = number; this.level = level; this.action = action; }
public void AddLevel(int number, Level level, LevelMenuItem.MenuAction action) { items.Add(new LevelMenuItem(number, level, action)); }