Ejemplo n.º 1
0
        public TMBAW_Game()
        {
            // Important services that need to be instanstiated before other things.
            _graphics = new GraphicsDeviceManager(this);
            Content   = new ContentManager(Services, "Content");
            GameData  = new GameDataManager();

            //Window.IsBorderless = true;


            DataFolder.Initialize();
            SettingsFile settings = DataFolder.GetSettingsFile();

            UserName = SteamFriends.GetPersonaName();
            SteamID  = SteamUser.GetSteamID();
#if DEBUG
            SteamUserStats.ResetAllStats(true);
#endif

            MediaPlayer.Volume = settings.MusicVolume;
            MaxVolume          = settings.SoundVolume;

            // Change game settings here.
            _graphics.SynchronizeWithVerticalRetrace = true;
            _graphics.PreferMultiSampling            = false;
            IsFixedTimeStep = true;

            _graphics.ApplyChanges();

            Thread.CurrentThread.Priority = ThreadPriority.Highest;

            GraphicsRenderer.OnResolutionChanged += OnResolutionChanged;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the game to full screen and changes the resolution to match.
        /// </summary>
        /// <param name="value"></param>
        public static void SetFullscreen(bool value)
        {
            _graphicsManager.IsFullScreen = value;

            if (_graphicsManager.IsFullScreen)
            {
                ChangeToNativeResolution();
            }
            else
            {
                SettingsFile settings = DataFolder.GetSettingsFile();
                ChangeResolution(settings.ResolutionWidth, settings.ResolutionHeight);
            }
        }
Ejemplo n.º 3
0
        protected override void Initialize()
        {
            SettingsFile settings = DataFolder.GetSettingsFile();

            GraphicsRenderer.Initialize(GraphicsDevice, _graphics);
            GraphicsRenderer.ChangeResolution(settings.ResolutionWidth, settings.ResolutionHeight);
            GraphicsRenderer.SetFullscreen(settings.IsFullscreen);

            Camera = new Camera(GraphicsDevice.Viewport);

            InitializeUi();
            Session.Initialize();
            GameWorld.Initialize();
            LoadingScreen.Initialize();

            base.Initialize();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Draws the debug information to the screen if debug is on.
        /// </summary>
        /// <param name="spriteBatch"></param>
        public static void Draw(SpriteBatch spriteBatch)
        {
            if (IsDebugOn)
            {
                SettingsFile settings = DataFolder.GetSettingsFile();

                _infos = new List <string>
                {
                    "There Must Be Another Way - Version " + TMBAW_Game.Version,
                    "FPS: " + TMBAW_Game.FPS + " Resolution: " + settings.ResolutionWidth + "x" + settings.ResolutionHeight,
                    "Gamestate: " + TMBAW_Game.CurrentGameState,
                    "Gamemode: " + TMBAW_Game.CurrentGameMode,
                    "Camera Position: " + TMBAW_Game.Camera.GetPosition().X + "," + TMBAW_Game.Camera.GetPosition().Y,
                    "Mouse (Game): " + InputSystem.GetMouseRectGameWorld().X + "," + InputSystem.GetMouseRectGameWorld().Y,
                    "Index of mouse: " + LevelEditor.IndexOfMouse,
                    "Tile Type: " + GameWorld.GetTile(LevelEditor.IndexOfMouse)?.Id.ToString(),
                    "Particles in use: " + ParticleSystem.GetInUseParticleCount(),
                    "Is Sprinting: " + GameWorld.GetPlayers()[0].IsRunningFast,
                    "Steam Name: " + TMBAW_Game.UserName + " ID: " + TMBAW_Game.SteamID.m_SteamID,
                    "Particle update time: " + ParticleSystem.UpdateTime + " " + String.Format("{0:0.00}", ParticleSystem.UpdateTime * 100 / GameWorld.TotalUpdateTimer.GetAverage()) + "% of update time",
                    "Particle draw time: " + ParticleSystem.DrawTime + " " + String.Format("{0:0.00}", ParticleSystem.DrawTime * 100 / GameWorld.TotalDrawTimer.GetAverage()) + "% of draw time",
                    "Tile draw time: " + GraphicsRenderer.TileDrawTimer.GetAverage() + " " + String.Format("{0:0.00}", GraphicsRenderer.TileDrawTimer.GetAverage() * 100 / GameWorld.TotalDrawTimer.GetAverage()) + "% of draw time",
                    "UI draw time: " + GraphicsRenderer.UserInterfaceDrawTimer.GetAverage() + " " + String.Format("{0:0.00}", GraphicsRenderer.UserInterfaceDrawTimer.GetAverage() * 100 / GameWorld.TotalDrawTimer.GetAverage()) + "% of draw time",
                    "Light draw time: " + GraphicsRenderer.LightDrawTimer.GetAverage() + " " + String.Format("{0:0.00}", GraphicsRenderer.LightDrawTimer.GetAverage() * 100 / GameWorld.TotalDrawTimer.GetAverage()) + "% of draw time",
                    "Total update time: " + GameWorld.TotalUpdateTimer.GetAverage(),
                    "Total draw time: " + GameWorld.TotalDrawTimer.GetAverage(),
                    "Visible tiles: " + GameWorld.ChunkManager?.GetVisibleIndexes()?.Length,
                    "Ambient Color: " + GameWorld.WorldData.SunLightColor,
                };
                spriteBatch.Draw(GameWorld.SpriteSheet, new Rectangle(0, 0, TMBAW_Game.UserResWidth, (_infos.Count) * _font.LineSpacing), new Rectangle(304, 224, 8, 8), Color.White * .6f);

                for (int i = 0; i < _infos.Count; i++)
                {
                    Point pos = new Point(0, i * _font.LineSpacing);
                    FontHelper.DrawWithOutline(spriteBatch, _font, _infos[i], pos.ToVector2(), 1, new Color(220, 220, 220), Color.Black);
                }
            }

            if (IsTyping)
            {
                spriteBatch.Draw(GameWorld.SpriteSheet, new Rectangle(0, TMBAW_Game.UserResHeight - 30, TMBAW_Game.UserResWidth, 30), new Rectangle(304, 224, 8, 8), Color.White * .6f);
                chatBox.Draw(spriteBatch);
            }
        }