Esempio n. 1
0
        public void EnemyEatFood(FoodPoint foodPoint, int id, Guid id_player)
        {
            var food = FoodPoints.FirstOrDefault(i => i.ID == id);

            FoodPoints.Remove(food);
            FoodPoints.Add(foodPoint);

            var player = EnemyPlayers.FirstOrDefault(i => i.ID == id_player);

            if (player != null)
            {
                player.Size++;
                player.Score++;
            }

            PlayerEvents.GetInstance().EnemyEatFood();
        }
Esempio n. 2
0
        public void SetGameField(int amountOfSnakesFood, int snakeLength)
        {
            Console.SetWindowSize(StaticInfo._maxFieldWidth, StaticInfo._maxFieldHeight);
            var random = new Random();
            var index  = 0;

            Console.ForegroundColor = StaticInfo._foodColor;

            while (index < amountOfSnakesFood)
            {
                var pointColumn = random.Next(StaticInfo._minFieldBorder, StaticInfo._maxFieldWidth - 5);
                var pointRow    = random.Next(StaticInfo._minFieldBorder, StaticInfo._maxFieldHeight - 5);

                FoodPoints.Add(new FoodPoint(pointRow, pointColumn));

                Console.SetCursorPosition(pointColumn, pointRow);
                Console.Write(StaticInfo._foodCharacter);
                ++index;
            }

            _counter = -1;
            IncrementCounter();
            CreateSnakeBody(snakeLength);
        }