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

            return(false);
        }
Example #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));
            }
        }
Example #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);
        }
Example #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);
Example #5
0
 private void RemoveApple(Coordinat coordinat)
 {
     _apples.RemoveAll(a => a.Cors.Equals(coordinat));
 }
Example #6
0
 public Apple(Coordinat cors, AppleType type)
 {
     Type = type;
     Cors = cors;
 }