Beispiel #1
0
    public async ValueTask LoadAll(IJSRuntime runtime)
    {
        await _loader.LoadAll(runtime);

        _frightened = _loader.GetSoundEffect(SoundName.Frightened);
        _ghostEyes  = _loader.GetSoundEffect(SoundName.GhostEyes);

        _sirens = new[]
        {
            _loader.GetSoundEffect(SoundName.Siren1),
            _loader.GetSoundEffect(SoundName.Siren2),
            _loader.GetSoundEffect(SoundName.Siren3),
            _loader.GetSoundEffect(SoundName.Siren4),
            _loader.GetSoundEffect(SoundName.Siren5)
        };

        _frightened.Loop();
        _ghostEyes.Loop();

        _sirens.ForEach(async s =>
        {
            s.Loop();
            await s.SetVolume(.5f);
        });

        _loaded = true;
    }
Beispiel #2
0
        static void Main(string[] args)
        {
            Background = Color.Black;
            Static     = new Color(52, 73, 94);
            Foreground = new Color(253, 227, 167);

            Engine.Initialize <SfmlRenderer, IrrKlangModule.IrrKlangAudioModule>();

            Engine.EventHost.RegisterEvent <KeyDownEvent>((int)Keyboard.Key.Escape, 0, (ev) =>
            {
                while (Engine.SceneHost.CurrentScene != null)
                {
                    Engine.SceneHost.Pop();
                }
            });

            Engine.EventHost.RegisterEvent <InitializeEvent>(0, (ev) =>
            {
                Engine.DesiredResolution = new Vector2(640f, 480f);

                Container = Engine.ResourceHost.LoadDictionary("main", "Resources");
                Font12    = LoadFont("Fonts/merriweather_12.fnt");
                Font16    = LoadFont("Fonts/merriweather_16.fnt");
                Logo      = LoadTexture("logo.png");
                Player    = LoadTexture("player.png");
                Portal    = LoadTexture("portal.png");
                Hint1     = LoadTexture("hint1.png");
                Hint2     = LoadTexture("hint2.png");
                Hint3     = LoadTexture("hint3.png");
                EndScreen = LoadTexture("endscreen.png");

                Music    = LoadSound("music.wav");
                EnemyHit = LoadSound("ehit.wav");
                Cut      = LoadSound("cut.wav");
                Ground   = LoadSound("ground.wav");

                Music.Loop();

                Image image = new Image(1, 1);
                image.SetColor(0, 0, Color.White);
                Pixel = Engine.Renderer.TextureFromImage(image);

                var scene = Engine.SceneHost.CreateGlobal <MainScene>();
                Engine.SceneHost.Push(scene);
            });

            Engine.StartGame("cut", WindowStyle.Default);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Background = Color.Black;
            Static = new Color(52, 73, 94);
            Foreground = new Color(253, 227, 167);

            Engine.Initialize<SfmlRenderer, IrrKlangModule.IrrKlangAudioModule>();

            Engine.EventHost.RegisterEvent<KeyDownEvent>((int)Keyboard.Key.Escape, 0, (ev) =>
                {
                    while (Engine.SceneHost.CurrentScene != null)
                        Engine.SceneHost.Pop();
                });

            Engine.EventHost.RegisterEvent<InitializeEvent>(0, (ev) =>
            {
                Engine.DesiredResolution = new Vector2(640f, 480f);

                Container = Engine.ResourceHost.LoadDictionary("main", "Resources");
                Font12 = LoadFont("Fonts/merriweather_12.fnt");
                Font16 = LoadFont("Fonts/merriweather_16.fnt");
                Logo = LoadTexture("logo.png");
                Player = LoadTexture("player.png");
                Portal = LoadTexture("portal.png");
                Hint1 = LoadTexture("hint1.png");
                Hint2 = LoadTexture("hint2.png");
                Hint3 = LoadTexture("hint3.png");
                EndScreen = LoadTexture("endscreen.png");

                Music = LoadSound("music.wav");
                EnemyHit = LoadSound("ehit.wav");
                Cut = LoadSound("cut.wav");
                Ground = LoadSound("ground.wav");

                Music.Loop();

                Image image = new Image(1, 1);
                image.SetColor(0, 0, Color.White);
                Pixel = Engine.Renderer.TextureFromImage(image);

                var scene = Engine.SceneHost.CreateGlobal<MainScene>();
                Engine.SceneHost.Push(scene);
            });

            Engine.StartGame("cut", WindowStyle.Default);
        }
Beispiel #4
0
 /// <summary>
 /// Determines if a sound effect should loop.
 /// </summary>
 /// <param name="soundEffect">
 /// The sound effect.
 /// </param>
 /// <returns>
 /// A value indicating whether the sound effect should loop.
 /// </returns>
 protected virtual bool LoopSound(SoundEffect soundEffect)
 {
     return soundEffect.Loop();
 }
Beispiel #5
0
        /// <summary>
        /// Determines if a sound effect should loop.
        /// </summary>
        /// <param name="soundEffect">
        /// The sound effect.
        /// </param>
        /// <returns>
        /// A value indicating whether the sound effect should loop.
        /// </returns>
        protected override bool LoopSound(SoundEffect soundEffect)
        {
            var loop = soundEffect.Loop();
            if (!loop && soundEffect.Routine != 0)
            {
                this.CallInterrupt(soundEffect.Routine);
            }

            return loop;
        }