public PlayAppState() { this.camera = new Camera(0, 0, AppSettings.WindowWidth, AppSettings.WindowHeight); this.board = MapIO.LoadMap(MapName); this.SetEventResponses(); this.StartGame(); }
protected override void ExecuteEventResponse(string action, object content) { base.ExecuteEventResponse(action, content); switch (action) { case "deselect-tool": selectedTool = null; break; case "select-tool": selectedTool = (BaseTile)content; break; case "set-tile": SetTile((BaseTile)content); break; case "add-column": board.AddColumn(); EventManager.PushEvent( new UIEvent(new EventDetails(this.Name, EventType.ChangeWidth), board.Width)); break; case "remove-column": board.RemoveColumn(); EventManager.PushEvent( new UIEvent(new EventDetails(this.Name, EventType.ChangeWidth), board.Width)); break; case "add-row": board.AddRow(); EventManager.PushEvent( new UIEvent(new EventDetails(this.Name, EventType.ChangeHeight), board.Height)); break; case "remove-row": board.RemoveRow(); EventManager.PushEvent( new UIEvent(new EventDetails(this.Name, EventType.ChangeHeight), board.Height)); break; case "save-board": MapIO.SaveMap(board, mapName); EventManager.PushEvent( new UIEvent(new EventDetails(this.Name, EventType.MapSaved), null)); break; case "load-board": Board result = MapIO.LoadMap(this.selectedMap); this.board = result; this.mapName = board.Name; this.camera.Reset(); EventManager.PushEvent( new UIEvent(new EventDetails(this.Name, EventType.MapLoaded), null)); break; case "change-map-name": this.mapName = (string)content; break; case "reset-board": int width = Int32.Parse(AppSettings.DefaultBoardWidth); int height = Int32.Parse(AppSettings.DefaultBoardHeight); board = new Board(width, height); board.Generate(); EventManager.PushEvent( new UIEvent(new EventDetails(this.Name, EventType.ChangeHeight), board.Height)); EventManager.PushEvent( new UIEvent(new EventDetails(this.Name, EventType.ChangeWidth), board.Width)); break; case "scroll-up-file": ScrollUpMap(); break; case "scroll-down-file": ScrollDownMap(); break; case "select-file": this.selectedMap = ((TextboxListItem)content).Text; break; } }