Example #1
0
        public Player(Entity entity) : base(entity)
        {
            Collider.LocalPosition = new Vector2(1, 3);
            Collider.Width         = 14;
            Collider.Height        = 13;

            _jumpEventDescription = AudioManager.LoadEvent("event:/SOUNDS/PLAYER/Jump");
            _landEventDescription = AudioManager.LoadEvent("event:/SOUNDS/PLAYER/Land");
            _jumpEventDescription.LoadSampleData();
            _landEventDescription.LoadSampleData();
            _eventInstances.Add("Jump", _jumpEventDescription.CreateInstance());
            _eventInstances.Add("Land", _landEventDescription.CreateInstance());

            Texture2D texture = ContentHandler.Instance.Load <Texture2D>("Sprites/SlimeCube");

            entity.AddComponent(new Sprite(entity, texture, texture.Width, texture.Height, Vector2.Zero, .5f));
        }
Example #2
0
        public override void Enter()
        {
            InitUI();

            // You would rather place the following in LoadContent() - it's here more for readability.
            // Here you load any banks that you're using. This could be a music bank, a SFX bank, etc.
            // The strings bank isn't actually necessary - however if you want to do string lookups, include it.
            _banks.Add(StudioSystem.LoadBank("Master.bank"));
            _banks.Add(StudioSystem.LoadBank("Master.strings.bank"));
            _banks.Add(StudioSystem.LoadBank("Music.bank"));
            _banks.Add(StudioSystem.LoadBank("SFX.bank"));
            _banks.Add(StudioSystem.LoadBank("Vehicles.bank"));
            _banks.Add(StudioSystem.LoadBank("VO.bank"));
            _banks.Add(StudioSystem.LoadBank("Dialogue_EN.bank"));

            // Events are split in the code into descriptions and instances.
            // You may have multiple instances of one event, but the description for it should only be loaded once.
            // Here is why you want the strings bank loaded, btw. So much more intuitive than Guids.

            _engineDescription = StudioSystem.GetEvent("event:/Vehicles/Car Engine");
            _musicDescription  = StudioSystem.GetEvent("event:/Music/Level 03");

            // Loading an event description by Guid.
            // FMOD Studio will give you a string like below when you select "Copy Guid". It has to be parsed to be used.
            FMOD.Studio.Util.parseID("{be6203d8-c8d8-41c5-8ce6-bce0de95807b}", out Guid sfxGuid);
            _bonkDescription = StudioSystem.GetEvent(sfxGuid);

            // There are three ways to load sample data (any non-streamed sounds):
            // -From a bank. This will keep ALL the bank's data in memory until unloaded.
            // -From an event description. This will just keep the event's necessary data in memory until unloaded.
            // -From an event instance. Same as above, except the data will only be in memory while an instance is.
            // Assess when you need memory loaded and for how long, then choose which method to use properly.
            _engineDescription.LoadSampleData();
            // The music doesn't need its data pre-loaded, since it'll just play right away, continuously.
            _engineInstance = _engineDescription.CreateInstance();
            _musicInstance  = _musicDescription.CreateInstance();

            // Sound effects could be played whenever, so you don't want them constantly loading / unloading.
            _bonkDescription.LoadSampleData();

            // If you have any parameters set within FMOD Studio, you can change them within the code.
            _engineInstance.SetParameterValue("RPM", _rpm);
            _engineInstance.SetParameterValue("Load", -1f);
        }
Example #3
0
        private void InitUI()
        {
            _rpmLabel = new Label(
                "rpm",
                () => new Vector2(Game1.ScreenSize.X / 2 - Game1.ScreenSize.X / 4, Game1.ScreenSize.Y * 0.7f - 64)
                );
            _rpmDown = new Button(
                "<",
                () => new Vector2(
                    _rpmLabel.Position.X - 48,
                    _rpmLabel.Position.Y + 64
                    ),
                new Vector2(64, 64),
                () =>
            {
                _rpm -= 25;
                if (_rpm < 0)
                {
                    _rpm = 0;
                }
                _engineInstance.SetParameterValue("RPM", _rpm);
            }
                );
            _rpmUp = new Button(
                ">",
                () => new Vector2(
                    _rpmLabel.Position.X + 48,
                    _rpmLabel.Position.Y + 64
                    ),
                new Vector2(64, 64),
                () =>
            {
                _rpm += 25;
                if (_rpm > 10000)
                {
                    _rpm = 10000;
                }
                _engineInstance.SetParameterValue("RPM", _rpm);
            }
                );

            _engineStart = new Button(
                "start",
                () => new Vector2(
                    _rpmLabel.Position.X,
                    _rpmLabel.Position.Y + 128 + 32
                    ),
                new Vector2(128 + 32, 64),
                null,
                () =>
            {
                if (_engineInstance.PlaybackState == FMOD.Studio.PLAYBACK_STATE.PLAYING)
                {
                    _engineStart.Text = "start";
                    _engineInstance.Stop();
                }
                else
                {
                    _engineStart.Text = "stop";
                    _engineInstance.Start();
                }
            }
                );

            _musicLabel = new Label(
                "music",
                () => new Vector2(Game1.ScreenSize.X / 2 + Game1.ScreenSize.X / 4, Game1.ScreenSize.Y * 0.7f - 64)
                );
            _intensityDown = new Button(
                "<",
                () => new Vector2(
                    _musicLabel.Position.X - 48,
                    _musicLabel.Position.Y + 64
                    ),
                new Vector2(64, 64),
                null,
                () =>
            {
                _musicIntensity -= 1;
                if (_musicIntensity < 0)
                {
                    _musicIntensity = 0;
                }
                _musicInstance.SetParameterValue("Intensity", _musicIntensity);
            }
                );
            _intensityUp = new Button(
                ">",
                () => new Vector2(
                    _musicLabel.Position.X + 48,
                    _musicLabel.Position.Y + 64
                    ),
                new Vector2(64, 64),
                null,
                () =>
            {
                _musicIntensity += 1;
                if (_musicIntensity > 4)
                {
                    _musicIntensity = 4;
                }
                _musicInstance.SetParameterValue("Intensity", _musicIntensity);
            }
                );

            _musicStart = new Button(
                "start",
                () => new Vector2(
                    _musicLabel.Position.X,
                    _musicLabel.Position.Y + 128 + 32
                    ),
                new Vector2(128 + 32, 64),
                null,
                () =>
            {
                if (_musicInstance.PlaybackState == FMOD.Studio.PLAYBACK_STATE.PLAYING)
                {
                    _musicStart.Text = "start";
                    _musicInstance.Stop();
                }
                else
                {
                    _musicStart.Text = "stop";
                    _musicInstance.Start();
                    _musicInstance.SetParameterValue("Intensity", _musicIntensity);
                }
            }
                );


            _bonk = new Button(
                "bonk",
                () => new Vector2(Game1.ScreenSize.X / 2, _musicLabel.Position.Y + 128 + 32),
                new Vector2(128, 64),
                null,
                () =>
            {
                var i = _bonkDescription.CreateInstance();
                i.SetParameterValue("Speed", 4);
                i.Start();                         // That's actually a memory leak. Event instances should be disposed.
            }
                );


            _back = new Button(
                "<-",
                () => new Vector2(32, 32),
                new Vector2(64, 64),
                null,
                () => SceneController.ChangeScene(new DemoSelectorScene())
                );
        }