Beispiel #1
0
        public bool SetFood(Serpent serpent)
        {
            if (!HasNormalCell(serpent))
            {
                return(false);
            }

            int    x, y;
            Random r = new Random();

            while (true)
            {
                x = r.Next(0, RowCount);
                y = r.Next(0, ColCount);
                Cell cell = GetCell(x, y);
                if (cell.IsNormal() && !serpent.InBody(cell))
                {
                    break;
                }
            }
            _cellFood      = _cells[x][y];
            _cellFood.Kind = CellKind.Food;
            RedrawMapCell(x, y);
            return(true);
        }
Beispiel #2
0
        public bool HasNormalCell(Serpent serpent)
        {
            int row, col;

            for (row = 0; row < RowCount; row++)
            {
                for (col = 0; col < ColCount; col++)
                {
                    Cell cell = GetCell(row, col);
                    if (cell.IsNormal() && !serpent.InBody(cell))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }