/// <summary> /// Spawn of the entities in the grid /// </summary> private void SpawnEntities() { Random rand = new Random(); int num = 0; //Check if random is odd to spawn sheep in the desired position while (num % 2 == 0) { num = rand.Next(1, 8); } //Spawn the wolf in the random position grid[0, num] = new Wolf(0, num); //Spawn the sheep grid[7, 0] = new Sheep(7, 0, 1); grid[7, 2] = new Sheep(7, 2, 2); grid[7, 4] = new Sheep(7, 4, 3); grid[7, 6] = new Sheep(7, 6, 4); wolf = (Wolf)grid[0, num]; sheep1 = (Sheep)grid[7, 0]; sheep2 = (Sheep)grid[7, 2]; sheep3 = (Sheep)grid[7, 4]; sheep4 = (Sheep)grid[7, 6]; }
/// <summary> /// Choice of sheep for movement /// </summary> /// <param name="input"></param> private void SelectPlayingSheep(string input) { switch (input) { case "1": playingSheep = sheep1; break; case "2": playingSheep = sheep2; break; case "3": playingSheep = sheep3; break; case "4": playingSheep = sheep4; break; } }
/// <summary> /// Graphical character of the board and game pieces /// </summary> /// <param name="obj"></param> /// <returns></returns> public string SetSymbol(object obj) { string s = null; if (obj is Square) { s = "■"; } else if (obj is Sheep) { Console.ForegroundColor = ConsoleColor.White; Sheep sheep = (Sheep)obj; switch (sheep.Id) { case 1: s = "1"; break; case 2: s = "2"; break; case 3: s = "3"; break; case 4: s = "4"; break; } } else if (obj is Wolf) { Console.ForegroundColor = ConsoleColor.White; s = "W"; } return(s); }