public void Tick() { if (Visible) { return; } //memory.SetText("Memory " + (int) (System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64 / 1024f) + " KB"); //memory.SetText("Public Memory " + (int)(GC.GetTotalMemory(false) / 1024f) + " KB"); visibility.SetText(CameraVisibility.TilesVisible() + " Tiles visible"); if (Window.GlobalTick % 10 != 0) { return; } var tps = PerfInfo.AverageTPS(); tick.SetColor(getColor(tps, Settings.UpdatesPerSecond)); tick.SetText("Tick " + tps.ToString("F1") + " @ " + PerfInfo.TMS.ToString("00") + " ms"); var frameCount = Settings.FrameLimiter == 0 ? ScreenInfo.ScreenRefreshRate : Settings.FrameLimiter; var fps = PerfInfo.AverageFPS(); render.SetColor(getColor(fps, frameCount)); render.SetText("Render " + fps.ToString("F1") + " @ " + PerfInfo.FMS.ToString("00") + " ms"); }
public override void Tick() { const int movement = 12; base.Tick(); var toRemove = new List <UITextLine>(); foreach (var line in lines) { line.Position -= new CPos(0, movement, 0); if (line.Position.Y <= Top - lineHeight / 2) { toRemove.Add(line); } } foreach (var line in toRemove) { lines.Remove(line); } currentHeight += movement; if (currentHeight >= 0 && currentLine < lineData.Length) { var newLine = new UITextLine(FontManager.Default, TextOffset.MIDDLE) { Position = new CPos(0, Bottom + lineHeight / 2, 0) }; newLine.SetText(lineData[currentLine++]); lines.Add(newLine); currentHeight -= lineHeight; } if (lines.Count == 0) { wsImageTick++; var color = Math.Min((float)wsImageTick / (Settings.UpdatesPerSecond * 10) + Math.Min(wsImageTick / 100f, 0.1f), 1f); wsImage.Color = new Color(color, color, color, color); var scale = Math.Min((float)Math.Log10(wsImageTick + 100) / 3f, 1f); wsImage.Scale = scale; if (wsImageTick == 900) { var text = new UITextLine(FontManager.Default, TextOffset.MIDDLE) { Color = Color.Green, Position = new CPos(0, 2048, 0) }; text.SetText("Press any key to continue"); Add(text); } } }
public Screen(string title, int darkness = 128) { Title = new UITextLine(FontManager.Header, TextOffset.MIDDLE) { Scale = 1.2f }; Title.SetText(title); this.darkness = new Color(0, 0, 0, darkness); }
void updateInformation() { var stats = game.Stats; if (stats.Lifes == stats.MaxLifes) { information.SetColor(Color.Green); information.SetText("Max life limit reached!"); } else { information.SetColor(Color.White); information.SetText($"Current: {stats.Lifes}/{stats.MaxLifes}"); } var nextPrice = stats.NextLifePrice(); price.SetColor(nextPrice > stats.Money ? Color.Red : Color.Green); price.SetText($"Current Price: {nextPrice}"); }
public CreatePieceScreen() : base("Create Piece") { Title.Position = new CPos(0, -4096, 0); Add(new Button("Cancel", "wooden", () => { ActiveScreen = false; }) { Position = new CPos(4096, 6144, 0) }); Add(new Button("Create", "wooden", create) { Position = new CPos(-4096, 6144, 0) }); var size = new UITextLine(FontManager.Default, TextOffset.MIDDLE) { Position = new CPos(0, -1024, 0) }; size.SetText("Size of Piece"); Add(size); sizeX = new TextBox("wooden", 2, InputType.NUMBERS) { Position = new CPos(-1024, 0, 0), Text = "16" }; Add(sizeX); sizeY = new TextBox("wooden", 2, InputType.NUMBERS) { Position = new CPos(1024, 0, 0), Text = "16" }; Add(sizeY); name = new TextBox("wooden", 20, InputType.PATH) { Position = new CPos(0, 1536, 0), Text = "unnamed piece" }; Add(name); var warning = new UITextLine(FontManager.Default, TextOffset.MIDDLE) { Position = new CPos(0, 2548, 0), Color = Color.Red }; warning.SetText("Warning: by using an name for an already existing map, you override it!"); Add(warning); }
public StartScreen(Game game) : base("") { var ws = new UIImage(new BatchObject(UISpriteManager.Get("logo")[0])) { Position = new CPos(0, -3072, 0), Scale = 0.8f }; Add(ws); var welcome = new UITextLine(FontManager.Header, TextOffset.MIDDLE) { Position = new CPos(0, -512, 0) }; welcome.SetText("Welcome to Warrior's Snuggery!"); Add(welcome); var tutorial = new UITextLine(FontManager.Header, TextOffset.MIDDLE) { Position = new CPos(0, 1536, 0) }; tutorial.SetText("If you don't know how to play yet, move down to the tutorial!"); Add(tutorial); var warning = new UITextLine(FontManager.Header, TextOffset.MIDDLE) { Position = new CPos(0, 4096, 0), Color = new Color(0.5f, 0.5f, 1f) }; warning.SetText("WS is still under development. If you encounter any bugs, please report them."); Add(warning); Add(new Button("Lets go!", "wooden", () => game.ShowScreen(ScreenType.DEFAULT, false)) { Position = new CPos(0, 6144, 0) }); }
public InfoScreen() { var corner = (int)(WindowInfo.UnitWidth * 512) - 128; version = new UITextLine(FontManager.Default, TextOffset.RIGHT) { Position = new CPos(corner, 6192, 0), Color = Color.Yellow }; version.SetText(Settings.Version); visibility = new UITextLine(FontManager.Default, TextOffset.RIGHT) { Position = new CPos(corner, 6692, 0) }; tick = new UITextLine(FontManager.Default, TextOffset.RIGHT) { Position = new CPos(corner, 7692, 0) }; render = new UITextLine(FontManager.Default, TextOffset.RIGHT) { Position = new CPos(corner, 7192, 0) }; }
public SettingsScreen(Game game) : base("Settings") { this.game = game; Title.Position = new CPos(0, -4096, 0); // Window var fullscreen = new UITextLine(FontManager.Default) { Position = new CPos(-6096, -3000, 0) }; fullscreen.SetText("Fullscreen:"); Add(fullscreen); var width = new UITextLine(FontManager.Default) { Position = new CPos(-6096, -2300, 0) }; if (Settings.Fullscreen) { width.SetColor(new Color(128, 128, 128)); } width.SetText("Width:"); Add(width); var height = new UITextLine(FontManager.Default) { Position = new CPos(-6096, -1600, 0) }; if (Settings.Fullscreen) { height.SetColor(new Color(128, 128, 128)); } height.SetText("Height:"); Add(height); fullscreenCheck = new CheckBox("wooden", Settings.Fullscreen, (ticked) => { width.SetColor(ticked ? new Color(128, 128, 128) : Color.White); height.SetColor(ticked ? new Color(128, 128, 128) : Color.White); }) { Position = new CPos(-1536, -3000, 0) }; Add(fullscreenCheck); widthWrite = new TextBox("wooden", 5, InputType.NUMBERS) { Position = new CPos(-2048, -2300, 0), Text = Settings.Width.ToString(), OnEnter = () => { var parse = int.Parse(widthWrite.Text); if (parse < 640) { widthWrite.Text = 640 + ""; } else if (parse > ScreenInfo.ScreenWidth) { widthWrite.Text = ScreenInfo.ScreenWidth + ""; } } }; Add(widthWrite); heightWrite = new TextBox("wooden", 5, InputType.NUMBERS) { Position = new CPos(-2048, -1600, 0), Text = Settings.Height.ToString(), OnEnter = () => { var parse = int.Parse(heightWrite.Text); if (parse < 480) { heightWrite.Text = 480 + ""; } else if (parse > ScreenInfo.ScreenHeight) { heightWrite.Text = ScreenInfo.ScreenHeight + ""; } } }; Add(heightWrite); // Graphics var vSync = new UITextLine(FontManager.Default) { Position = new CPos(-512, -3000, 0) }; vSync.SetText("Enable V-Sync:"); Add(vSync); var pixeling = new UITextLine(FontManager.Default) { Position = new CPos(-512, -2300, 0) }; pixeling.SetText("Enable Pixeling:"); Add(pixeling); var textshadow = new UITextLine(FontManager.Default) { Position = new CPos(-512, -1600, 0) }; textshadow.SetText("Enable text shadows:"); Add(textshadow); vSyncCheck = new CheckBox("wooden", Settings.VSync, (b) => { Settings.VSync = b; Window.SetVSync(); }) { Position = new CPos(6656, -3000, 0) }; Add(vSyncCheck); pixelingCheck = new CheckBox("wooden", Settings.EnablePixeling, (b) => Settings.EnablePixeling = b) { Position = new CPos(6656, -2300, 0) }; Add(pixelingCheck); textshadowCheck = new CheckBox("wooden", Settings.EnableTextShadowing, (b) => Settings.EnableTextShadowing = b) { Position = new CPos(6656, -1600, 0) }; Add(textshadowCheck); // Scrolling var scrollSpeed = new UITextLine(FontManager.Default) { Position = new CPos(-6144, -600, 0) }; scrollSpeed.SetText("Camera panning speed:"); Add(scrollSpeed); var edgeScrolling = new UITextLine(FontManager.Default) { Position = new CPos(-6144, 100, 0) }; edgeScrolling.SetText("Edge Panning (0 = disabled):"); Add(edgeScrolling); panningSlider = new SliderBar(4096, "wooden", () => Settings.ScrollSpeed = (int)(panningSlider.Value * 10)) { Position = new CPos(5120, -600, 0), Value = Settings.ScrollSpeed / 10f }; Add(panningSlider); edgePanningSlider = new SliderBar(4096, "wooden", () => Settings.EdgeScrolling = (int)(edgePanningSlider.Value * 10)) { Position = new CPos(5120, 100, 0), Value = Settings.EdgeScrolling / 10f }; Add(edgePanningSlider); // Additional features var frameLimiter = new UITextLine(FontManager.Default) { Position = new CPos(-6144, 1000, 0) }; frameLimiter.SetText("Framelimiter (0 = disabled):"); Add(frameLimiter); frameLimiterWrite = new TextBox("wooden", 2, InputType.NUMBERS) { Position = new CPos(5120, 1000, 0), Text = Settings.FrameLimiter.ToString(), OnEnter = () => { var number = int.Parse(frameLimiterWrite.Text); if (number > ScreenInfo.ScreenRefreshRate) { frameLimiterWrite.Text = ScreenInfo.ScreenRefreshRate.ToString(); } } }; Add(frameLimiterWrite); var developerMode = new UITextLine(FontManager.Default) { Position = new CPos(-6144, 1900, 0) }; developerMode.SetText("Enable Developermode:"); Add(developerMode); developerModeCheck = new CheckBox("wooden", Settings.DeveloperMode, (b) => { Settings.DeveloperMode = b; }) { Position = new CPos(5120, 1900, 0) }; Add(developerModeCheck); // Volume var masterVol = new UITextLine(FontManager.Default) { Position = new CPos(-6144, 2800, 0) }; masterVol.SetText("Master Volume:"); Add(masterVol); var effectVol = new UITextLine(FontManager.Default) { Position = new CPos(-6144, 3700, 0) }; effectVol.SetText("Effects Volume:"); Add(effectVol); var musicVol = new UITextLine(FontManager.Default) { Position = new CPos(-6144, 4600, 0) }; musicVol.SetText("Music Volume:"); Add(musicVol); masterVolumeSlider = new SliderBar(4096, "wooden", () => { Settings.MasterVolume = (float)Math.Round(masterVolumeSlider.Value, 2); MusicController.UpdateVolume(); }) { Position = new CPos(5120, 2800, 0), Value = Settings.MasterVolume }; Add(masterVolumeSlider); effectVolumeSlider = new SliderBar(4096, "wooden", () => { Settings.EffectsVolume = (float)Math.Round(effectVolumeSlider.Value, 2); }) { Position = new CPos(5120, 3700, 0), Value = Settings.EffectsVolume }; Add(effectVolumeSlider); musicVolumeSlider = new SliderBar(4096, "wooden", () => { Settings.MusicVolume = (float)Math.Round(musicVolumeSlider.Value, 2); MusicController.UpdateVolume(); }) { Position = new CPos(5120, 4600, 0), Value = Settings.MusicVolume }; Add(musicVolumeSlider); var warning = new UITextLine(FontManager.Default, TextOffset.MIDDLE) { Position = new CPos(0, 5450, 0), Color = Color.Red }; warning.SetText("Some changes only take effect after restarting and can cause visual bugs."); Add(warning); Add(new Button("Apply", "wooden", Save) { Position = new CPos(-5120, 6144, 0) }); Add(new Button("Save & Back", "wooden", () => game.ShowScreen(ScreenType.MENU)) { Position = new CPos(5120, 6144, 0) }); Add(new Button("Key Bindings", "wooden", () => game.ShowScreen(ScreenType.KEYSETTINGS)) { Position = new CPos(0, 6144, 0) }); }
public DefaultScreen(Game game) : base(string.Empty, 0) { this.game = game; particleManager = new SquareParticleManager(); Add(particleManager); const int shift = margin; // Actors actorList = new ActorList(game, new MPos(512, 11 * 512), new MPos(512, 512), "wooden") { Position = new CPos(Left + 512 + margin, 768 + shift, 0) }; Add(actorList); // Spells spellList = new SpellList(game, new MPos(512, 13 * 512), new MPos(512, 512), "stone") { Position = new CPos(Right - 512 - margin, 0, 0) }; Add(spellList); manaBar = new DisplayBar(new MPos(Width / 2 - 1536, 256), PanelCache.Types["stone"], new Color(0, 0, 255, 196)) { Position = new CPos(0, Bottom - 2048 + margin, 0) }; Add(manaBar); healthBar = new DisplayBar(new MPos(Width / 2 - 256, 512), PanelCache.Types["wooden"], new Color(255, 0, 0, 196)) { Position = new CPos(0, Bottom - 1024 + margin, 0) }; Add(healthBar); var top = Top + 512 + margin; Add(new MoneyDisplay(game) { Position = new CPos(Left + 1536 + shift, top, 0) }); Add(new HealthDisplay(game) { Position = new CPos(Left + 4096 + shift + margin, top, 0) }); if (game.ObjectiveType == ObjectiveType.FIND_EXIT) { Add(new KeyDisplay(game) { Position = new CPos(Left + 712 + shift, top + 1536 + shift + 128, 0) }); } else if (game.ObjectiveType == ObjectiveType.SURVIVE_WAVES) { Add(new WaveDisplay(game) { Position = new CPos(Left + 512 + shift, top + 1536 + shift + 128, 0) }); } var menu = new CheckBox("menu", onTicked: (t) => game.ShowScreen(ScreenType.MENU, true)) { Position = new CPos(Right - 512 - margin, Top + 512 + margin, 0), Scale = 2.5f }; Add(menu); // mission text var missionText = new UITextLine(FontManager.Header, TextOffset.MIDDLE) { Position = new CPos(0, top, 0) }; var missionContent = string.Empty; switch (game.ObjectiveType) { case ObjectiveType.FIND_EXIT: missionContent = "Search for the exit and gain access to it!"; break; case ObjectiveType.KILL_ENEMIES: missionContent = "Wipe out all enemies on the map!"; break; case ObjectiveType.SURVIVE_WAVES: missionContent = "Defend your position from incoming waves!"; break; } missionText.SetText(missionContent); if (game.Save.Level == game.Save.FinalLevel) { missionText.SetColor(Color.Blue); } else if (game.Save.Level > game.Save.FinalLevel) { missionText.SetColor(Color.Green); } Add(missionText); Add(new EnemyPointer(game)); }
public KeySettingsScreen(Game game) : base("Key Bindings") { this.game = game; Title.Position = new CPos(0, -4096, 0); var font = FontManager.Default; Add(new Button("Save & Back", "wooden", () => game.ShowScreen(ScreenType.SETTINGS)) { Position = new CPos(0, 6144, 0) }); var type = PanelCache.Types["wooden"]; var tPause = new UITextLine(font, TextOffset.RIGHT) { Position = new CPos(-1024, -4096, 0) }; tPause.SetText("Pause/unpause"); Add(tPause); pause = new KeyboardButton(Settings.KeyDictionary["Pause"], type) { Position = new CPos(1536, -4096, 0) }; Add(pause); var tLock = new UITextLine(font, TextOffset.RIGHT) { Position = new CPos(-1024, -3072, 0) }; tLock.SetText("Toggle camera lock"); Add(tLock); @lock = new KeyboardButton(Settings.KeyDictionary["CameraLock"], type) { Position = new CPos(1536, -3072, 0) }; Add(@lock); var tactivate = new UITextLine(font, TextOffset.RIGHT) { Position = new CPos(-1024, -2048, 0) }; tactivate.SetText("Activate spell/actor"); Add(tactivate); activate = new KeyboardButton(Settings.KeyDictionary["Activate"], type) { Position = new CPos(1536, -2048, 0) }; Add(activate); var tMove = new UITextLine(font, TextOffset.RIGHT) { Position = new CPos(-3072, -1024, 0) }; tMove.SetText("Movement"); Add(tMove); var line = 0; foreach (var dir in new[] { "Up", "Down", "Left", "Right", "Above", "Below" }) { var text = new UITextLine(font, TextOffset.RIGHT) { Position = new CPos(-1024, -1024 + line * 640, 0) }; text.SetText(dir); line++; Add(text); } up = new KeyboardButton(Settings.KeyDictionary["MoveUp"], type) { Position = new CPos(1536, -1024, 0) }; Add(up); down = new KeyboardButton(Settings.KeyDictionary["MoveDown"], type) { Position = new CPos(1536, -1024 + 640, 1) }; Add(down); left = new KeyboardButton(Settings.KeyDictionary["MoveLeft"], type) { Position = new CPos(1536, -1024 + 1280, 1) }; Add(left); right = new KeyboardButton(Settings.KeyDictionary["MoveRight"], type) { Position = new CPos(1536, -1024 + 1920, 0) }; Add(right); above = new KeyboardButton(Settings.KeyDictionary["MoveAbove"], type) { Position = new CPos(1536, -1024 + 2560, 1) }; Add(above); below = new KeyboardButton(Settings.KeyDictionary["MoveBelow"], type) { Position = new CPos(1536, -1024 + 3200, 0) }; Add(below); var tCam = new UITextLine(font, TextOffset.RIGHT) { Position = new CPos(-3072, 3072, 0) }; tCam.SetText("Camera"); Add(tCam); line = 0; foreach (var dir in new[] { "Up", "Down", "Left", "Right" }) { var text = new UITextLine(font, TextOffset.RIGHT) { Position = new CPos(-1024, 3072 + line * 640, 0) }; text.SetText(dir); line++; Add(text); } camUp = new KeyboardButton(Settings.KeyDictionary["CameraUp"], type) { Position = new CPos(1536, 3072, 0) }; Add(camUp); camDown = new KeyboardButton(Settings.KeyDictionary["CameraDown"], type) { Position = new CPos(1536, 3072 + 640, 1) }; Add(camDown); camLeft = new KeyboardButton(Settings.KeyDictionary["CameraLeft"], type) { Position = new CPos(1536, 3072 + 1280, 1) }; Add(camLeft); camRight = new KeyboardButton(Settings.KeyDictionary["CameraRight"], type) { Position = new CPos(1536, 3072 + 1920, 1) }; Add(camRight); }
public NewStoryGameScreen(Game game) : base("Play Story") { this.game = game; Title.Position = new CPos(0, -4096, 0); var create = new UITextLine(FontManager.Default, TextOffset.MIDDLE) { Position = new CPos(0, -2048, 0) }; create.SetText("Story line. Please adjust the parameters as you wish."); Add(create); var name = new UITextLine(FontManager.Default, TextOffset.RIGHT) { Position = new CPos(-2048, 0, 0) }; name.SetText("Name: "); Add(name); nameInput = new TextBox("wooden", 15, InputType.PATH) { Position = new CPos(1024, 0, 0), Text = "Name" }; Add(nameInput); var difficulty = new UITextLine(FontManager.Default, TextOffset.RIGHT) { Position = new CPos(-2048, 1024, 0) }; difficulty.SetText("Difficulty: "); Add(difficulty); difficultyInput = new SliderBar(4096, "wooden") { Position = new CPos(1024, 1024, 0) }; Add(difficultyInput); var hardcore = new UITextLine(FontManager.Default, TextOffset.RIGHT) { Position = new CPos(0, -1024, 0) }; hardcore.SetText("Hardcore (one life): "); Add(hardcore); hardcoreInput = new CheckBox("wooden") { Position = new CPos(1024, 2048, 0) }; Add(hardcoreInput); var seed = new UITextLine(FontManager.Default, TextOffset.RIGHT) { Position = new CPos(-2048, 3072, 0) }; seed.SetText("Seed: "); Add(seed); seedInput = new TextBox("wooden", 7, InputType.NUMBERS) { Position = new CPos(1024, 3072, 0), Text = getSeed() }; Add(seedInput); Add(new Button("Generate", "wooden", () => { seedInput.Text = getSeed(); }) { Position = new CPos(6144, 3072, 0) }); Add(new Button("Cancel", "wooden", () => game.ShowScreen(ScreenType.DEFAULT, false)) { Position = new CPos(-4096, 6144, 0) }); Add(new Button("Proceed", "wooden", () => { if (!string.IsNullOrWhiteSpace(nameInput.Text)) { GameController.CreateNew(new GameSave((int)Math.Round(difficultyInput.Value * 10), hardcoreInput.Checked, nameInput.Text, int.Parse(seedInput.Text)), MissionType.STORY); } }) { Position = new CPos(4096, 6144, 0) }); }