void ToggleSetting(GameSetting setting) { if (!setting.CanBeChangedInGame && IsInGame) { Dynamic.PlayErrorSound(); return; } setting.ToggleValue(); if (IsInGame) { save.SetSettings(settings); } else { GameSettingsLoader.WriteSettingsToFile(settings); } var selectedMenu = ((object)Dynamic._selectedMenuCollection).AsDynamic(); var menuEntry = new MenuEntry(((IList)selectedMenu.Entries)[selectedMenu.SelectedIndex]); if (!setting.CanBeChangedInGame && IsInGame) { menuEntry.BaseDrawColor = MenuEntry.UnAvailableColor; } setting.UpdateMenuEntry(menuEntry); }
internal static SettingCollection GetSettings(this GameSave gameSave) { var json = gameSave.GetSaveString(SaveFileSettingKey); return(string.IsNullOrEmpty(json) ? new SettingCollection() : GameSettingsLoader.FromJson(json)); }
public Log(GCM gcm) { this.gcm = gcm; SetSettings(GameSettingsLoader.LoadSettingsFromFile()); Add(this); }
public void ShouldReturnBottomHorizontalLine() { var board = GameSettingsLoader.Load( @" .▲. XXX "); var type = WallAnalyzer.GetWallType(board.Walls, (1, 1), board.Width, board.Height); type.Should().Be(WallType.HorizontalLine); }
public void TheBoardCanBeLoadedFromATextFile() { var filename = "SimpleTestBoard.txt"; var gameBoard = GameSettingsLoader.LoadFromFile(filename); gameBoard.Should().BeEquivalentTo(new { Walls = new CellLocation[] { (0, 0), (1, 0), (2, 0), (0, 1), (2, 1), (0, 2), (1, 2) },
public void ShouldReturnRightVerticalLine() { var board = GameSettingsLoader.Load( @" ..X ..X .▲X "); var type = WallAnalyzer.GetWallType(board.Walls, (2, 1), board.Width, board.Height); type.Should().Be(WallType.VerticalLine); }
public void ShouldAnalyzeTopRightCornerAsTopRightArc() { var board = GameSettingsLoader.Load( @" XX ▲X "); var type = WallAnalyzer.GetWallType(board.Walls, (1, 0), board.Width, board.Height); type.Should().Be(WallType.TopRightArc); }
public void ShouldAnalyzeTopLeftEdgeAsTopLeftArc() { var board = GameSettingsLoader.Load( @" ... .XX ▲X "); var type = WallAnalyzer.GetWallType(board.Walls, (1, 1), board.Width, board.Height); type.Should().Be(WallType.TopLeftArc); }
public void ShouldAnalyzeRightHorizontalLineEdgeAsHorizontalLine() { var board = GameSettingsLoader.Load( @" XX ▲ "); var type = WallAnalyzer.GetWallType(board.Walls, (1, 1), board.Width, board.Height); type.Should().Be(WallType.HorizontalLine); }
public void ShouldAnalyzeVerticalLine4AsVerticalLine() { var board = GameSettingsLoader.Load( @" XX. XX. XX▲"); var type = WallAnalyzer.GetWallType(board.Walls, (1, 1), board.Width, board.Height); type.Should().Be(WallType.VerticalLine); }
public void ShouldAnalyzeBottomRightCorner1AsBottomRightArc() { var board = GameSettingsLoader.Load( @" ▲XX XXX XXX "); var type = WallAnalyzer.GetWallType(board.Walls, (1, 1), board.Width, board.Height); type.Should().Be(WallType.BottomRightArc); }
public void ShouldAnalyzeBottomLeftEdgeAsBottomLeftArc() { var board = GameSettingsLoader.Load( @" .X .XX .▲."); var type = WallAnalyzer.GetWallType(board.Walls, (1, 1), board.Width, board.Height); type.Should().Be(WallType.BottomLeftArc); }
void OnOkayEntrySelected(PlayerIndex playerIndex) { var hexString = GetHexString(); if (!Seed.TryParse(hexString, out var seed)) { ShowErrorDescription("Invalid seed id, it is not a valid hexidecimal value."); return; } if (!forceSeed && !Randomizer.IsBeatable(seed, FillingMethod.Random)) { ShowErrorDescription("Invalid seed id, it cannot be beaten."); return; } difficultyMenu.SetSeedAndFillingMethod(seed, FillingMethod.Random, GameSettingsLoader.LoadSettingsFromFile()); Dynamic.OnCancel(playerIndex); }
public override void Initialize(ItemLocationMap itemLocationMap, GCM gameContentManager) { gcm = gameContentManager; if (!IsUsedAsGameSettingsMenu) { return; } Dynamic._menuTitle = "Game Settings"; var gameplayScreen = ScreenManager.FirstOrDefault <GameplayScreen>(); save = gameplayScreen?.Save; settings = IsInGame ? gameplayScreen.Settings : GameSettingsLoader.LoadSettingsFromFile(); ResetMenu(); }
void OnDefaultsSelected(GameSettingCategoryInfo[] menusToClear, bool isSubmenu) { // Clear the root menu if (!IsInGame && !isSubmenu) { settings = new SettingCollection(); } else { foreach (var category in menusToClear) { foreach (var settingsFunc in category.SettingsPerCategory) { var setting = settingsFunc(settings); if (IsInGame && !setting.CanBeChangedInGame) { continue; } setting.SetDefault(); } } } if (IsInGame) { save.SetSettings(settings); } else { GameSettingsLoader.WriteSettingsToFile(settings); } ResetMenu(); if (isSubmenu) { Dynamic.GoToPreviousMenuCollection(); } }
static async Task Main(string[] args) { var game = new Game.Game(new GameClock(), GameSettingsLoader.LoadFromFile("board.txt")); _allCoins = game.Coins; while (true) { var keys = GetAllKeysPressed(); if (keys.Contains(ConsoleKey.Escape)) { break; } var directions = keys.Select(x => x switch { ConsoleKey.UpArrow => Direction.Up, ConsoleKey.DownArrow => Direction.Down, ConsoleKey.LeftArrow => Direction.Left, ConsoleKey.RightArrow => Direction.Right, _ => (Direction?)null }).Where(x => x != null).ToList();
public static void LogException(Exception exception) { using (var file = new StreamWriter(GetFileName())) { try { file.WriteLine("Context:"); file.WriteLine( $"Timespinner Version: {TimeSpinnerGame.Constants.GameVersion}, TsRandomizer Version: {Assembly.GetExecutingAssembly().GetName().Version}"); file.WriteLine($"Level: {LevelId}, Room: {RoomId}, Seed: {Seed}"); file.WriteLine(); WriteException(exception, file); file.WriteLine("Settings:"); if (Settings != null) { file.WriteLine($"{GameSettingsLoader.ToJson(Settings, true)}"); } else { file.WriteLine($"{Settings}"); } } catch (Exception e) { try { file.WriteLine("Writing ExceptionLog Failure:"); WriteException(e, file); } catch { } } } }
public SettingCollection GetSettings() => GameSettingsLoader.LoadSettingsFromSlotData(slotData);
internal static void SetSettings(this GameSave gameSave, SettingCollection settings) { ExceptionLogger.SetSettingsContext(settings); gameSave.SetValue(SaveFileSettingKey, GameSettingsLoader.ToJson(settings, false)); }