/// <summary> /// Run logic for this state - including input /// </summary> /// <param name="GameTime">Snapshot of timing</param> public override void Update(GameTime GameTime) { // Get the current state, get the last state, and any new buttons are acted upon var currentState = Keyboard.GetState(); foreach (var i in currentState.GetPressedKeys()) { if (LastState.IsKeyUp(i)) { KeyPressed(i); } } LastState = currentState; // Do turn, if player next move is set if (G.Player.NextMove != Player.Instruction.NOT_SET) { G.DoTurn(); } if (G.GameOver) { StateStack.Add(new AtlasWarriors.LoseState(G)); } }
/// <summary> /// Run logic for this state - including input /// </summary> /// <param name="GameTime">Snapshot of timing</param> public override void Update(GameTime GameTime) { // Get the current state, get the last state, and any new buttons are acted upon var currentState = Keyboard.GetState(); foreach (var i in currentState.GetPressedKeys()) { if (LastState.IsKeyUp(i)) { KeyPressed(i); } } LastState = currentState; // Get touch state var touchState = TouchPanel.GetState(); // Iterate through. Move the dude if in the 9 spaces. foreach (var touch in touchState) { if (touch.State == TouchLocationState.Pressed) { ProcessTouch(touch.Position); } } // Do turn, if player next move is set if (G.Player.NextMove != Player.Instruction.NOT_SET) { G.DoTurn(); } }
static void Main(string[] args) { Tolk.TrySAPI(true); Tolk.Load(); //Console.WriteLine("Querying for the active screen reader driver..."); //string name = Tolk.DetectScreenReader(); //if (name != null) { // Console.WriteLine("The active screen reader driver is: {0}", name); //} //else { // Console.WriteLine("None of the supported screen readers is running"); //} //if (Tolk.HasSpeech()) { // Console.WriteLine("This screen reader driver supports speech"); //} //if (Tolk.HasBraille()) { // Console.WriteLine("This screen reader driver supports braille"); //} //Console.WriteLine("Let's output some text..."); //if (!Tolk.Output("Hello, World!")) { // Console.WriteLine("Failed to output text"); //} //Console.WriteLine("Finalizing Tolk..."); //Tolk.Unload(); //Console.WriteLine("Done!"); var G = new AtlasWarriorsGame.Game(); bool quit = false; displayMode = DisplayMode.ROOM; bool skipDraw = false; while (!quit) { // If not skipping draw, draw map. If so - reset skipDraw to draw map next time. if (!skipDraw) { if (displayMode != DisplayMode.REFRESH_ONLY) { DrawMap(G.CurrentDungeon); } } else { skipDraw = false; } Console.Write($"\nHP {G.Player.CurrentHealth} ({G.Player.MaxHealth})"); Console.Write("\n>"); var input = Console.ReadKey(); switch (input.Key) { case ConsoleKey.H: case ConsoleKey.LeftArrow: case ConsoleKey.NumPad4: G.Player.NextMove = Player.Instruction.MOVE_W; break; case ConsoleKey.K: case ConsoleKey.UpArrow: case ConsoleKey.NumPad8: G.Player.NextMove = Player.Instruction.MOVE_N; break; case ConsoleKey.L: case ConsoleKey.RightArrow: case ConsoleKey.NumPad6: G.Player.NextMove = Player.Instruction.MOVE_E; break; case ConsoleKey.J: case ConsoleKey.DownArrow: case ConsoleKey.NumPad2: G.Player.NextMove = Player.Instruction.MOVE_S; break; case ConsoleKey.Y: case ConsoleKey.NumPad7: G.Player.NextMove = Player.Instruction.MOVE_NW; break; case ConsoleKey.U: case ConsoleKey.NumPad9: G.Player.NextMove = Player.Instruction.MOVE_NE; break; case ConsoleKey.B: case ConsoleKey.NumPad1: G.Player.NextMove = Player.Instruction.MOVE_SW; break; case ConsoleKey.N: case ConsoleKey.NumPad3: G.Player.NextMove = Player.Instruction.MOVE_SE; break; // Non move options // Refresh screen case ConsoleKey.Spacebar: DrawMap(G.CurrentDungeon, true); skipDraw = true; break; // Change draw mode - F1, F2, F3 case ConsoleKey.F1: displayMode = DisplayMode.ALL; Console.Write("Display mode set to show all"); break; case ConsoleKey.F2: displayMode = DisplayMode.ROOM; Console.Write("Display mode set to show current visible area only"); break; case ConsoleKey.F3: displayMode = DisplayMode.REFRESH_ONLY; Console.Write("Display mode set to only show on refresh (Space)"); break; } G.DoTurn(); } }
static void Main(string[] args) { Tolk.TrySAPI(true); Tolk.Load(); string introText = @"Atlas Warriors - Screen Reader Edition Lachlan Kingsford Welcome to Atlas Warriors. This screen reader edition provides screen-reader specific functionality: F1: Screen mode - whole map F2: Screen mode - current room only F3: Screen mode - no refresh Space: Draw whole screen Move with Vim keys, arrows or numeric keypad. Push any key to continue"; Console.WriteLine(introText); Tolk.Output(introText); Console.ReadKey(); var G = new AtlasWarriorsGame.Game(); bool quit = false; displayMode = DisplayMode.ROOM; bool skipDraw = false; while (!quit) { // Interrupt reader at start of turn Tolk.Output("", true); // If not skipping draw, draw map. If so - reset skipDraw to draw map next time. if (!skipDraw) { if (displayMode != DisplayMode.REFRESH_ONLY) { DrawMap(G.CurrentDungeon); } } else { skipDraw = false; } Console.Write($"\nHP {G.Player.CurrentHealth} ({G.Player.MaxHealth})"); Tolk.Output($"{G.Player.CurrentHealth} of {G.Player.MaxHealth}"); Console.Write("\n>"); var input = Console.ReadKey(); switch (input.Key) { case ConsoleKey.H: case ConsoleKey.LeftArrow: case ConsoleKey.NumPad4: G.Player.NextMove = Player.Instruction.MOVE_W; break; case ConsoleKey.K: case ConsoleKey.UpArrow: case ConsoleKey.NumPad8: G.Player.NextMove = Player.Instruction.MOVE_N; break; case ConsoleKey.L: case ConsoleKey.RightArrow: case ConsoleKey.NumPad6: G.Player.NextMove = Player.Instruction.MOVE_E; break; case ConsoleKey.J: case ConsoleKey.DownArrow: case ConsoleKey.NumPad2: G.Player.NextMove = Player.Instruction.MOVE_S; break; case ConsoleKey.Y: case ConsoleKey.NumPad7: G.Player.NextMove = Player.Instruction.MOVE_NW; break; case ConsoleKey.U: case ConsoleKey.NumPad9: G.Player.NextMove = Player.Instruction.MOVE_NE; break; case ConsoleKey.B: case ConsoleKey.NumPad1: G.Player.NextMove = Player.Instruction.MOVE_SW; break; case ConsoleKey.N: case ConsoleKey.NumPad3: G.Player.NextMove = Player.Instruction.MOVE_SE; break; // Non move options // Refresh screen case ConsoleKey.Spacebar: DrawMap(G.CurrentDungeon, true); skipDraw = true; break; // Change draw mode - F1, F2, F3 case ConsoleKey.F1: displayMode = DisplayMode.ALL; Console.Write("Display mode set to show all"); break; case ConsoleKey.F2: displayMode = DisplayMode.ROOM; Console.Write("Display mode set to show current visible area only"); break; case ConsoleKey.F3: displayMode = DisplayMode.REFRESH_ONLY; Console.Write("Display mode set to only show on refresh (Space)"); break; } G.DoTurn(); if (G.GameOver) { Console.WriteLine(G.EndGameTitle); Tolk.Output(G.EndGameTitle, true); Console.WriteLine(G.EndGameText); Tolk.Output(G.EndGameText, false); Console.WriteLine("(Press any key to quit)"); Tolk.Output("Press any key to quit"); Console.ReadKey(); quit = true; } } }