Пример #1
0
        public CrawlResult Crawl(Point food)
        {
            KeyListener();

            Point head = Body[0];
            Point tail = Body[Body.Count - 1];

            Body.Remove(head);

            Point neck = new Point(head.X, head.Y, head.Symbol, ConsoleColor.White);

            Body.Insert(0, neck);

            head.Shift(Direction);
            neck.Draw();

            if (Body.Exists(p => p.isSamePosition(head)))
            {
                Die();
                return(CrawlResult.DEATH);
            }
            else if (head.isSamePosition(food))
            {
                Body.Insert(0, head);
                return(CrawlResult.FOOD);
            }
            else
            {
                tail.Undraw();
                Body.Insert(0, head);
                Body.Remove(tail);
                return(CrawlResult.SAFE);
            }
        }