Exemple #1
0
        public Board(int l, int w)
        {
            bLength = l;
            bWidth = w;
            currID = 1;
            board = new SeedCell[l, w];
            for (int i = 0; i < l; i++)
                for (int j = 0; j < w; j++)
                    board[i, j] = new SeedCell(i, j);

            //timer = new System.Windows.Forms.Timer();
            //timer.Tick += timer_Tick;
            Console.CursorVisible = false;
            rnd = new Random();
        }
Exemple #2
0
 // Распространение волны за один такт
 public void SpawnWave(SeedCell[,] board)
 {
     if (!isNew && spawnDirection != Direction.Exausted)
     {
         switch (spawnDirection)
         {
             case Direction.Exausted:
                 return;
             case Direction.Main:
                 Spawn(board, Direction.Main);
                 Spawn(board, Direction.Up);
                 Spawn(board, Direction.Down);
                 break;
             default:
                 Spawn(board, this.spawnDirection);
                 break;
         }
         spawnDirection = Direction.Exausted;
     }
 }
Exemple #3
0
        // Механизм распространения фронта в зависимости от направление d
        private void Spawn(SeedCell[,] board, Direction d)
        {
            int x = X;
            int y = Y;
            if (d == Direction.Main)
                x++;
            else if (d == Direction.Up)
                y--;
            else
                y++;

            try
            {
                if (this > board[x, y])
                    board[x, y].Update(waveColor, waveID, d);
            }
            catch (IndexOutOfRangeException) { }
        }