Example #1
0
 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);
 }
Example #2
0
 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);
     }
 }
Example #3
0
 public TokenGenerator(Board board, Level level, Random random)
 {
     this.board = board;
     this.level = level;
     this.random = random;
     this.nextToken = null;
     LoadNextToken();
 }
Example #4
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);
            });
        }
Example #5
0
 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;
     }
 }
Example #6
0
 public void Setup(Level level, Random random)
 {
     level.SetupBoard(this, random);
     MarkMatches();
     ClearMatches();
 }
Example #7
0
 public void OnFinished(PlayerIndex player, Level level)
 {
     listener.OnFinished(player, level);
 }
Example #8
0
 public LevelMenuItem(int number, Level level, MenuAction action)
 {
     this.number = number;
     this.level = level;
     this.action = action;
 }
Example #9
0
 public void AddLevel(int number, Level level, LevelMenuItem.MenuAction action)
 {
     items.Add(new LevelMenuItem(number, level, action));
 }