コード例 #1
0
        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);
        }
コード例 #2
0
        internal static SettingCollection GetSettings(this GameSave gameSave)
        {
            var json = gameSave.GetSaveString(SaveFileSettingKey);

            return(string.IsNullOrEmpty(json)
                                ? new SettingCollection()
                                : GameSettingsLoader.FromJson(json));
        }
コード例 #3
0
ファイル: Log.cs プロジェクト: JarnoWesthof/TsRandomizer
        public Log(GCM gcm)
        {
            this.gcm = gcm;

            SetSettings(GameSettingsLoader.LoadSettingsFromFile());

            Add(this);
        }
コード例 #4
0
ファイル: WallAnalyzerTests.cs プロジェクト: punker76/PacMan
        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);
        }
コード例 #5
0
        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) },
コード例 #6
0
ファイル: WallAnalyzerTests.cs プロジェクト: punker76/PacMan
        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);
        }
コード例 #7
0
ファイル: WallAnalyzerTests.cs プロジェクト: punker76/PacMan
        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);
        }
コード例 #8
0
ファイル: WallAnalyzerTests.cs プロジェクト: punker76/PacMan
        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);
        }
コード例 #9
0
ファイル: WallAnalyzerTests.cs プロジェクト: punker76/PacMan
        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);
        }
コード例 #10
0
ファイル: WallAnalyzerTests.cs プロジェクト: punker76/PacMan
        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);
        }
コード例 #11
0
ファイル: WallAnalyzerTests.cs プロジェクト: punker76/PacMan
        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);
        }
コード例 #12
0
ファイル: WallAnalyzerTests.cs プロジェクト: punker76/PacMan
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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();
        }
コード例 #15
0
        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();
            }
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: punker76/PacMan
        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();
コード例 #17
0
        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
                    {
                    }
                }
            }
        }
コード例 #18
0
 public SettingCollection GetSettings() =>
 GameSettingsLoader.LoadSettingsFromSlotData(slotData);
コード例 #19
0
 internal static void SetSettings(this GameSave gameSave, SettingCollection settings)
 {
     ExceptionLogger.SetSettingsContext(settings);
     gameSave.SetValue(SaveFileSettingKey, GameSettingsLoader.ToJson(settings, false));
 }