Ejemplo n.º 1
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            base.OnUpdateFrame(e);

            Services.Input.Update();

            Title = string.Format("TriEngine2D Test X: {0}; Y: {1}; Mem: {2}", Services.Input.MouseX, Services.Input.MouseY, GetMemUsageString());

            if (!Focused)
            {
                return;
            }

            if (Services.Input.KeyPressed(Key.Number1))
            {
                _activeSong = "unknown1";
                Console.WriteLine("Selected song " + _activeSong);
            }
            else if (Services.Input.KeyPressed(Key.Number2))
            {
                _activeSong = "call";
                Console.WriteLine("Selected song " + _activeSong);
            }
            else if (Services.Input.KeyPressed(Key.Number3))
            {
                _activeSong = "pirates";
                Console.WriteLine("Selected song " + _activeSong);
            }

            var song = ResourceManager.Get <ISong>(_activeSong);

            if (Services.Input.KeyPressed(Key.P))
            {
                Console.WriteLine("Playing " + _activeSong);
                song.Play();
            }
            else if (Services.Input.KeyPressed(Key.S))
            {
                Console.WriteLine("Stopping " + _activeSong);
                song.Stop();
            }
            else if (Services.Input.KeyPressed(Key.U))
            {
                Console.WriteLine("Pausing " + _activeSong);
                song.Pause();
            }
            else if (Services.Input.KeyPressed(Key.R))
            {
                Console.WriteLine("Resuming " + _activeSong);
                song.Resume();
            }
            else if (Services.Input.KeyPressed(Key.L))
            {
                song.IsLooped = !song.IsLooped;
                Console.WriteLine(_activeSong + " is {0} looping", song.IsLooped ? "now" : "no longer");
            }
            else if (Services.Input.KeyPressed(Key.Minus))
            {
                song.Volume -= 0.1f;
                Console.WriteLine("Volume of " + _activeSong + " set to {0}", song.Volume);
            }
            else if (Services.Input.KeyPressed(Key.Plus))
            {
                song.Volume += 0.1f;
                Console.WriteLine("Volume of " + _activeSong + " set to {0}", song.Volume);
            }

            if (Services.Input.KeyPressed(Key.Space))
            {
                ResourceManager.Get <ISound>("test").Play();
            }
            else if (Services.Input.KeyPressed(Key.B))
            {
                ResourceManager.Get <ISound>("test2").Play();
            }

            _controlManager.Update();
        }
Ejemplo n.º 2
0
 private void Update(object sender, FrameEventArgs e)
 {
     _controlManager.Update(_controls.ToArray(), Keyboard, Mouse);
     _actorManager.Update(_actors.ToArray());
 }