Beispiel #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));
        }
Beispiel #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);
        }