public int Explore() { Console.WriteLine("You are looking around for something to kill!!"); int ran = RandomGenerator.GetRandomNumber(5); if (newMap.getCurrentPosition() == 2) //changed { Console.WriteLine("A monster!!! Prepare for battle!!"); context.SetState(context.GetBattleState()); } if (ran == 1) { Console.WriteLine("You find a golden jewel behind a tree!!"); return(2); } return(0); }
public void move() { Console.WriteLine("enter way that you want to move(e,w,s,n) "); ConsoleKeyInfo key; key = Console.ReadKey(); Console.WriteLine(); try { if (!((key.Key == ConsoleKey.E) || (key.Key == ConsoleKey.W) || (key.Key == ConsoleKey.S) || (key.Key == ConsoleKey.N))) { throw new IncorrectValueException(); } if (rpgMap.getCurrentState() == rpgMap.GetBattleState()) // c { throw new CannotMoveException(); } // if end } catch (IncorrectValueException ex) { Console.WriteLine("try again!!!"); key = Console.ReadKey(); } catch (CannotMoveException ex) { Console.WriteLine("You can't move there is a monster! Only A(attack)\n"); key = Console.ReadKey(); } try { switch (key.Key) { case ConsoleKey.E: playerFomalColPoint = playerColumnPoint; //c playerFomalRowPotin = playerRowPoint; //c map[playerRowPoint, playerColumnPoint] = PATH; playerColumnPoint++; map[playerRowPoint, playerColumnPoint] = PLAYER; break; case ConsoleKey.W: playerFomalColPoint = playerColumnPoint; //c playerFomalRowPotin = playerRowPoint; //c map[playerRowPoint, playerColumnPoint] = PATH; playerColumnPoint--; map[playerRowPoint, playerColumnPoint] = PLAYER; break; case ConsoleKey.S: playerFomalColPoint = playerColumnPoint; //c playerFomalRowPotin = playerRowPoint; //c map[playerRowPoint, playerColumnPoint] = PATH; playerRowPoint++; map[playerRowPoint, playerColumnPoint] = PLAYER; break; case ConsoleKey.N: playerFomalColPoint = playerColumnPoint; //c playerFomalRowPotin = playerRowPoint; //c map[playerRowPoint, playerColumnPoint] = PATH; playerRowPoint--; map[playerRowPoint, playerColumnPoint] = PLAYER; break; default: break; } } catch (IndexOutOfRangeException ex) { Console.WriteLine("You are out of map try again!!!"); playerRowPoint = playerFomalRowPotin; //c playerColumnPoint = playerFomalColPoint; //c } }