private void EatCurrentFood(ushort FoodBoardValue, Point position)//apple count { Food CurrentFoodFake = FoodService.NewFood(FoodBoardValue, position); toGrow += CurrentFoodFake.Snack; ScoreToAdd += CurrentFoodFake.Snack * 100; }
public void SpawnFood()//place ment of the apples { foodTimer.Stop(); //remove food if (CurrentFood != null) { if (Board[CurrentFood.Position.X, CurrentFood.Position.Y] == FoodService.GetBoardValue(CurrentFood.Id)) { Board[CurrentFood.Position.X, CurrentFood.Position.Y] = 0; drawArea.DrawSquare(CurrentFood.Position, "Background"); } CurrentFood = null; } //pick position Point randomPosition; do { randomPosition = new Point(random.Next(1, BoardSizeX - 2), random.Next(1, BoardSizeY - 2)); } while (Board[randomPosition.X, randomPosition.Y] != 0); //we need an empty tile //spawn food, place it on board, draw it CurrentFood = FoodService.NewFood(FoodService.RandomId(), randomPosition); Board[CurrentFood.Position.X, CurrentFood.Position.Y] = FoodService.GetBoardValue(CurrentFood.Id); drawArea.DrawFood(CurrentFood); }