示例#1
0
        public bool OnSelf(Coordinat coors)
        {
            foreach (var item in Cors)
            {
                if (coors.Equals(item))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#2
0
        private void AddApple(int quantity, AppleType type = AppleType.GrowSize)
        {
            var rand = new Random();

            for (int i = 0; i < quantity; i++)
            {
                var cors = new Coordinat(_field);

                while (_snake.OnSelf(cors))
                {
                    cors = new Coordinat(_field);
                }

                _apples.Add(new Apple(cors, type));
            }
        }
示例#3
0
        public Coordinat GetOffset()
        {
            var cors = new Coordinat();

            if (_oldDirection == Direction.Down)
            {
                cors.Y = 1;
            }
            else if (_oldDirection == Direction.Up)
            {
                cors.Y = -1;
            }
            else if (_oldDirection == Direction.Right)
            {
                cors.X = 1;
            }
            else if (_oldDirection == Direction.Left)
            {
                cors.X = -1;
            }

            return(cors);
        }
示例#4
0
 private void PrintSymbol(Coordinat coordinat, char symbol, ConsoleColor background = ConsoleColor.Black,
                          ConsoleColor font = ConsoleColor.White)
 => PrintSymbol(coordinat.X, coordinat.Y, symbol, background, font);
示例#5
0
 private void RemoveApple(Coordinat coordinat)
 {
     _apples.RemoveAll(a => a.Cors.Equals(coordinat));
 }
示例#6
0
 public Apple(Coordinat cors, AppleType type)
 {
     Type = type;
     Cors = cors;
 }