Ejemplo n.º 1
0
        protected override void LoadContent()
        {
            Form myGameForm = (Form)Control.FromHandle(Window.Handle);

            myGameForm.Closing      += ClosingFunction;
            myGameForm.StartPosition = FormStartPosition.CenterScreen;

            var pp = 0;

            _colors = new Microsoft.Xna.Framework.Color[256];

            for (var r = 0; r < 6; r++)
            {
                for (var g = 0; g < 6; g++)
                {
                    for (var b = 0; b < 6; b++)
                    {
                        var rr  = r * 255 / 5;
                        var gg  = g * 255 / 5;
                        var bb  = b * 255 / 5;
                        var mid = (rr * 30 + gg * 59 + bb * 11) / 100;

                        var r1 = (rr + mid * 1) / 2 * 230 / 255 + 10;
                        var g1 = (gg + mid * 1) / 2 * 230 / 255 + 10;
                        var b1 = (bb + mid * 1) / 2 * 230 / 255 + 10;
                        _colors[pp++] = new Microsoft.Xna.Framework.Color(r1, g1, b1);
                    }
                }
            }

            //while (pp < 256)
            //{
            //    colors[pp++] = Color.Black;
            //}

            var spriteSheet = Content.Load <Texture2D>("Textures/icons");

            SpriteSheet.LoadTiles(Content);
            Screen       = new Screen(GameConts.Width, GameConts.Height, new SpriteSheet(spriteSheet));
            _lightScreen = new Screen(GameConts.Width, GameConts.Height, new SpriteSheet(spriteSheet));

            GameEffectManager.Initialize(Content);
            GameEffectManager.SetMasterVolume(GameConts.Instance.SoundEffectVolume);

            GameSongManager.Initialize(Content);
            GameSongManager.SetMasterVolume(GameConts.Instance.MusicVolume);
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _pixels   = new Microsoft.Xna.Framework.Color[GameConts.Width * GameConts.Height];
            _image    = new Texture2D(GraphicsDevice, GameConts.Width, GameConts.Height);
            _input    = new InputHandler();
            UiManager = new UiManager(this, _input);

            ResetGame();
            SetMenu(new TitleMenu());

            //GameSongManager.Play("arpanauts");
        }
Ejemplo n.º 2
0
        protected internal override void HandleInput(InputHandler input)
        {
            float volume = GameEffectManager.GetMasterVolume();

            if (_type == SoundType.Music)
            {
                volume = GameSongManager.GetMasterVolume();
            }

            _current = volume;
            if (input.Right.Clicked)
            {
                volume += 0.05f;
                if (volume > 1.0f)
                {
                    volume = 1.0f;
                }
            }
            else if (input.Left.Clicked)
            {
                volume -= 0.05f;
                if (volume < 0.0f)
                {
                    volume = 0.0f;
                }
            }

            if (!volume.Equals(_current))
            {
                switch (_type)
                {
                case SoundType.Effects:
                    GameConts.Instance.SoundEffectVolume = volume;
                    GameEffectManager.SetMasterVolume(volume);
                    break;

                case SoundType.Music:
                    GameConts.Instance.MusicVolume = volume;
                    GameSongManager.SetMasterVolume(volume);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                GameConts.Instance.Save();
            }

            Text = $"{_volumeLabel}{volume.ToString("P0")}";
        }