public static void Main(string[] args) { WavPlayer.Init(WavProvider); WavPlayer.Play(); Keyboard = new WindowsKeyController(keyMap.ToDictionary(kvp => (int)kvp.Key, kvp => (int)kvp.Value)); Mouse = new WindowsMouseController(mouseMap.ToDictionary(kvp => (int)kvp.Key, kvp => (int)kvp.Value)); Builder = new GameBuilder(); Builder.GameEngine(new FixedTickEngine(TPS)) .GameView(new GameView2D(ScreenWidth, ScreenHeight, Scale, Scale, Color.DarkSlateGray)) .GameFrame(new GameFrame(new AvaloniaWindowBuilder(), 0, 0, ScreenWidth, ScreenHeight, Scale, Scale)) .Controller(Keyboard) .Controller(Mouse) .Build(); Engine = Builder.Engine; GameFrame frame = Builder.Frame; AvaloniaWindow window = frame.Window as AvaloniaWindow; Referee = new Referee(); Engine.TickEnd += Referee.Tick; Sprites(); Rules(); SetupLevels(); SetupTitleScreen(); Engine.TickEnd += (s, gs) => { if (Iframe > 0) { Iframe--; } if (Program.Keyboard[(int)Actions.ESCAPE].IsPress()) { Program.WavPlayer.Stop(); Program.WavProvider.RemoveAllMixerInputs(); StopMovingWindow(); SetupTitleScreen(); } if (Program.Keyboard[(int)Actions.DIAGS].IsPress()) { ShowDiags = !ShowDiags; } if (Program.Keyboard[(int)Actions.RESTART].IsPress()) { if ((Program.Referee.OutofControl || Program.Level == 7) && !Engine.Location.GetEntities <Banner>().Any()) { return; } if (Engine.Location.GetEntities <Banner>().FirstOrDefault()?.Text == "you win") { if (Level == -1) { for (int i = 0; i < 10; i++) { Referee.AddRule(Rule.GetNameRandomRule()); } } else { Level++; } } StopMovingWindow(); Program.WavPlayer.Stop(); Program.WavProvider.RemoveAllMixerInputs(); // Levels can call the reset with something different Referee.ResetTimer(); switch (Level) { case -1: SetupCrazyMode(); break; case 0: break; case 8: SetupCredits(); Level = 9; break; case 9: if (CreditsFinished) { SetupThanksForPlaying(); Level = 10; } break; case 10: SetupTitleScreen(); break; default: if (CreditsFinished) { StartingLevel = Level; Levels[Level - 1].SetupLevel(); } break; } if (Program.Diff == Difficulty.NORMAL && Level == 7) { Lives = 3; } else if (Program.Diff == Difficulty.EASY && Level == 7) { Lives = 4; } else { Lives = 1; } } }; Engine.Start(); while (true) { } }