protected override void Initialize() { board = new GameBoard(new Rectangle(0, gameYOffset, windowWidth, windowHeight - gameYOffset), GraphicsDevice); score = 0; base.Initialize(); }
private void GenerateRandomObject(int type)//1... point; 2...standing enemy; 3... linear enemy { Random rand = new Random(); int xCoord; int yCoord; int pointValue; do { xCoord = rand.Next(1, GameBoard.GetLength(0)); yCoord = rand.Next(1, GameBoard.GetLength(1)); } while (xCoord != HeadOfSnake.X && yCoord != HeadOfSnake.Y && original_snake.Contains(new Point(xCoord, yCoord))); pointValue = rand.Next(5, 50); if (type == 1) { if (pointValue >= 5 && pointValue <= 10) { Console.ForegroundColor = ConsoleColor.Gray; } else if (pointValue >= 11 && pointValue <= 25) { Console.ForegroundColor = ConsoleColor.Cyan; } else if (pointValue >= 26 && pointValue <= 35) { Console.ForegroundColor = ConsoleColor.Blue; } else if (pointValue >= 36 && pointValue <= 50) { Console.ForegroundColor = ConsoleColor.DarkYellow; } Console.SetCursorPosition(xCoord, yCoord); Console.Write("x"); Console.ForegroundColor = ConsoleColor.White; if (GameBoard[xCoord, yCoord] != 1) { GameBoard[xCoord, yCoord] = pointValue; } } else if (type == 2) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.SetCursorPosition(xCoord, yCoord); Console.Write("¤"); Console.ForegroundColor = ConsoleColor.White; if (GameBoard[xCoord, yCoord] != 1) { GameBoard[xCoord, yCoord] = -1; } } else if (type == 3) { LinearEnemy[0] = 1; if (rand.Next(1, 3) == 1) { LinearEnemy[1] = 0; LinearEnemy[2] = GameBoard.GetLength(0); LinearEnemy[3] = yCoord; } else { LinearEnemy[1] = 1; LinearEnemy[2] = xCoord; LinearEnemy[3] = GameBoard.GetLength(1); } LinearEnemy[4] = 0; } }