Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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}");
        }
Ejemplo n.º 3
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)
            });
        }
Ejemplo n.º 4
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));
        }