示例#1
0
        public void EatCell(SnakeCell snakeCell)
        {
            if (snakeCell.EatSnake)
            {
                return;
            }

            snakeCell.EatSnake = true;
            Cells.Add(snakeCell);

            var arooundOrdered = snakeCell.AroundCells.OrderBy(col => col.Value).ToList();

            foreach (var cell in arooundOrdered)
            {
                if (Cells.Count == 7)
                {
                    break;
                }

                if (cell.Value < snakeCell.Value || cell.EatSnake)
                {
                    continue;
                }

                EatCell(cell);
            }

            if (Cells.Count >= 7)
            {
                return;
            }

            snakeCell.EatSnake = false;
            Cells.Remove(snakeCell);
        }
示例#2
0
 public void BuildMapCell()
 {
     MapCells.Clear();
     for (var i = 0; i < Map.Count; i++)
     {
         for (var j = 0; j < Map[i].Length; j++)
         {
             var cell = new SnakeCell(this)
             {
                 Line = i, Colunm = j, Value = Convert.ToInt16(Map[i][j])
             };
             MapCells.Add(cell);
         }
     }
 }