Exemplo n.º 1
0
        public void ApplyConfig(bool Activate = true)
        {
            if (CurrentConfig.Fullscreen)
            {
                ApplyConfigToForm();

                graphics.IsFullScreen = true;
                graphics.ApplyChanges();
            }
            else
            {
                ApplyConfigToForm();

                graphics.IsFullScreen              = false;
                graphics.PreferredBackBufferWidth  = CurrentConfig.Width;
                graphics.PreferredBackBufferHeight = CurrentConfig.Height;
                graphics.ApplyChanges();
            }

            AmbientSounds.UpdateVolumes();

            if (Activate)
            {
                NeedsApplication = true;
            }
        }
Exemplo n.º 2
0
        static void LoadSound()
        {
            string path = Path.Combine(Content.RootDirectory, "Sound");

            string[] files = Directory.GetFiles(path);

            foreach (String file in files)
            {
                int i = file.IndexOf("Sound") + 5 + 1;
                if (i < 0)
                {
                    continue;
                }
                int j = file.IndexOf(".", i);
                if (j <= i)
                {
                    continue;
                }
                String name      = file.Substring(i, j - i);
                String extension = file.Substring(j + 1);

                if (extension == "xnb")
                {
                    try
                    {
                        SoundWad.Wad.AddSound(Content.Load <SoundEffect>("Sound\\" + name), name);
                    }
                    catch (Exception e)
                    {
                    }
                }
            }

            AmbientSounds.StartAmbientSounds();
        }
Exemplo n.º 3
0
            public Config()
            {
#if DEBUG
                Fullscreen = false;
                Width      = 1280;
                Height     = 720;

                MusicVolume = 0;
                SoundVolume = .5f;
#else
                Fullscreen = false;
                Width      = 1280;
                Height     = 720;

                //Fullscreen = true;
                //Width = GraphicsManager.GraphicsDevice.Adapter.CurrentDisplayMode.Width;
                //Height = GraphicsManager.GraphicsDevice.Adapter.CurrentDisplayMode.Height;

                MusicVolume = 1;
                SoundVolume = 1;
                AmbientSounds.UpdateVolumes();
#endif
            }
Exemplo n.º 4
0
 public void SetSoundVolume(float volume)
 {
     CurrentConfig.SoundVolume = ArgTo0to1(volume);
     AmbientSounds.UpdateVolumes();
     SaveConfig();
 }
Exemplo n.º 5
0
        void GameLogic(GameTime gameTime)
        {
            //Send("setMode", "in-game");
            //Send("setScreen", "in-game-ui");

            switch (State)
            {
            case GameState.ToEditor:
                NewWorldEditor();
                State = GameState.Game;

                Send("setMode", "in-game");
                Send("setScreen", "editor-ui");

                break;

            case GameState.ToMap:
                Render.StandardRenderSetup();
                DrawFullScreen(Assets.ScreenLoading);

                if (Program.StartupMap == null)
                {
                    Program.StartupMap = "Beset.m3n";
                }
                SetScenarioToLoad(Program.StartupMap);

                break;

            case GameState.TitleScreen:
                StartMenuMusicIfNeeded();
                AmbientSounds.EndAll();

                // No mouse input to web browser.
                SteamWrapper.SteamHtml.AllowMouseEvents = false;

                Render.StandardRenderSetup();

                DrawFullScreen(Assets.ScreenTitle);

                if (gameTime.TotalGameTime.Seconds < .005f)
                {
                    break;
                }

                if (MouseMovedSome)
                {
                    World.DrawArrowCursor();
                }
                else
                {
                    if (Input.DeltaMousPos.Length() > 40)
                    {
                        MouseMovedSome = true;
                    }
                }

                if (InputHelper.SomethingPressed())
                {
                    State = GameState.MainMenu;
                    Send("setMode", "main-menu");
                    Send("setScreen", "game-menu");
                }

                break;

            case GameState.MainMenu:
                StartMenuMusicIfNeeded();
                AmbientSounds.EndAll();

                if (!InputHelper.SomethingDown())
                {
                    SteamWrapper.SteamHtml.AllowMouseEvents = true;
                }

                if (_MapLoading != MapLoading)
                {
                    _MapLoading = MapLoading;
                    SetMapLoading();
                }

                if (MapLoading && NewMap != null)
                {
                    World      = NewMap;
                    MapLoading = false;

                    SetMapLoading();
                }

                Render.StandardRenderSetup();
                if (DrawMapPreview && World != null && World.DataGroup != null)
                {
                    Render.UnsetDevice();
                    try
                    {
                        World.DataGroup.UpdateGradient_ToPlayers();
                        World.DataGroup.UpdateGradient_ToBuildings();
                        World.DataGroup.UpdateGradient_ToPlayers();
                        World.DataGroup.UpdateGradient_ToBuildings();
                    }
                    catch
                    {
                    }

                    World.UpdateMinimap();

                    GridHelper.GraphicsDevice.SetRenderTarget(null);
                }

                Render.StandardRenderSetup();
                DrawFullScreen(Assets.ScreenDark);
                DrawWebView();

                if (DrawMapPreview && World != null && World.DataGroup != null)
                {
                    MapPreviewPos  = new vec2(0.76f, 0.32f);
                    MapPreviewSize = new vec2(.4f, .4f);

                    bool UseSolidColor = MapLoading || World == BlankWorld;
                    World.DrawMinimap(MapPreviewPos, MapPreviewSize, ShowCameraBox: false, SolidColor: UseSolidColor);
                }

                World.DrawArrowCursor();

                break;

            case GameState.Loading:
                FadeOutMenuMusicIfNeeded();

                PreGame();

                Render.StandardRenderSetup();
                DrawFullScreen(Assets.ScreenLoading);

                if (ScenarioToLoad != null)
                {
                    Send("setMode", "in-game");
                    Send("setScreen", "in-game-ui");

                    World = new World(
                        GameParams: Program.StartupGameParams,
                        RemoveComputerDragonLords: Program.RemoveComputerDragonLords);

                    TimeLoading          = 0;
                    World.LoadPlayerInfo = false;
                    World.Load(Path.Combine(MapDirectory, ScenarioToLoad));

                    Program.WorldLoaded = true;
                    Networking.ToServer(new Message(MessageType.DoneLoading));

                    ScenarioToLoad = null;
                    TimeSinceLoad  = 0;
                    DrawFullScreen(Assets.ScreenLoading);

                    GetNames();


                    //World.SaveCurrentStateInBuffer();
                    ////var m = new MessageGameState(World.SimStep, World.WorldBytes);
                    //var m = new Message(MessageType.DoneLoading);
                    //var s = m.Encode();

                    //Networking.SendString(new SteamPlayer(SteamCore.PlayerId()), s);
                    //var t = Networking.ReceiveString();
                    //var _s = t.Item2;

                    //Console.WriteLine("!");
                }

                if (Program.GameStarted)
                {
                    if (Program.Spectate)
                    {
                        State = GameState.Game;
                    }
                }
                else
                {
                    TimeLoading += DeltaT;

                    if (TimeLoading > 25)
                    {
                        OnFailedToJoinGame();
                    }

                    TimeSinceLoad = 0;
                    break;
                }

                FadeOutLoading();

                break;

            case GameState.Game:
                StartGameMusicIfNeeded();

                CalculateMouseDownOverUi();

                DrawGame(gameTime);

                if (Program.Spectate && ShouldDrawFading())
                {
                    Render.StandardRenderSetup();
                    DrawFullScreen(Assets.ScreenLoading);

                    FadeOutLoading();
                }
                else
                {
                    DrawWebView();

                    World.DrawUi();

                    if (TimeSinceLoad < 1.5f)
                    {
                        BlackOverlay(1f - (float)(TimeSinceLoad - 1.3f) / .2f);
                    }
                }

                break;
            }
        }