/// <summary> /// Constructor, with required parts to run /// </summary> public MapViewElement(AtlasWarriorsGame.Game Game, GraphicsDevice Device, ContentManager Content) { this.Game = Game; this.Content = Content; this.Device = Device; // Initialise bits for drawing MapFont = Content.Load <SpriteFont>("GameMapState/MapFont"); // W tends to be widest - hence, if not monospace - will still be OK TileWidth = MapFont.MeasureString("W").X; // f tends to be tallest - hence, if not monospace - will still be OK TileHeight = MapFont.MeasureString("f").Y; // Populate sprite list using (var spriteFileReader = new System.IO.StreamReader(Game.GetAssetStream("sprites_mgui.json"))) { var spriteFileText = spriteFileReader.ReadToEnd(); Sprites = JsonConvert.DeserializeObject <Dictionary <String, ConsoleCell> > (spriteFileText); } // Initialise last dungeon to initial dungeon LastTurnDungeon = Game.CurrentDungeon; ResetRenderTargetAndConsole(); }
/// <summary> /// Create a game interface from a given game /// </summary> /// <param name="Game">Game object that is being played</param> public GameMapState(AtlasWarriorsGame.Game Game) { this.G = Game; MapView = new MgUiCommon.MapViewElement(Game, AppGraphicsDevice, AppContentManager); LogFont = AppContentManager.Load <SpriteFont>("GameMapState/LogFont"); StatFont = AppContentManager.Load <SpriteFont>("GameMapState/StatFont"); }
/// <summary> /// Create a game interface from a given game /// </summary> /// <param name="game">Game object that is being played</param> /// <param name="metrics">Display metrics of mobile</param> public GameMapState(AtlasWarriorsGame.Game game, DisplayMetrics metrics) { this.G = game; LogFont = AppContentManager.Load <SpriteFont>("GameMapState/LogFont"); MapView = new MgUiCommon.MapViewElement(game, AppGraphicsDevice, AppContentManager); StatFont = AppContentManager.Load <SpriteFont>("GameMapState/StatFont"); Dpi = metrics.Xdpi; }
/// <summary> /// Constructor, with required parts to run /// </summary> public MapViewElement(AtlasWarriorsGame.Game Game, GraphicsDevice Device, ContentManager Content) { this.Game = Game; this.Content = Content; this.Device = Device; // Initialise bits for drawing MapFont = Content.Load <SpriteFont>("GameMapState/MapFont"); // W tends to be widest - hence, if not monospace - will still be OK TileWidth = MapFont.MeasureString("W").X; // f tends to be tallest - hence, if not monospace - will still be OK TileHeight = MapFont.MeasureString("f").Y; // Initialise last dungeon to initial dungeon LastTurnDungeon = Game.CurrentDungeon; ResetRenderTargetAndConsole(); }
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; } } }