Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new AudioEffectGroup class.
 /// </summary>
 /// <param name="name">The Name.</param>
 /// <param name="masterVolume">The MasterVolume.</param>
 public AudioEffectGroup(string name, float masterVolume)
 {
     _audioEffects = new List <AudioEffect>();
     Name          = name;
     MasterVolume  = masterVolume;
     SGL.QueryComponents <AudioManager>().AddEffectGroup(this);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the scene.
        /// </summary>
        /// <param name="gameTime">The GameTime.</param>
        public override void Update(GameTime gameTime)
        {
            if (_entityComposer.GameOver)
            {
                _blackBlend.IsEnabled = true;
                if (_blackBlend.IsCompleted)
                {
                    var endScene = SGL.QueryComponents <SceneManager>().Get <EndScene>();
                    endScene.Score = _entityComposer.Score;
                    endScene.AchievementManager = _entityComposer.AchievementManager;
                    SGL.QueryComponents <SceneManager>().ActiveScene = endScene;
                }
            }
            else
            {
                HandleInput(gameTime);
                if (!_achievementsOpen)
                {
                    _skyBox.Update(gameTime);
                    _entityComposer.Update(gameTime);
                    _scoreBoard.CurrentHealth = _entityComposer.Player.Health;
                    _scoreBoard.CurrentScore  = _entityComposer.Score;
                    _minimap.Update(gameTime);
                    _debugDisplay.Update(gameTime);
                }
            }

            _blackBlend.Update(gameTime);
            _achievementControl.Visible = _achievementsOpen;
            UIManager.Update(gameTime);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new OpenGLRenderer class.
 /// </summary>
 public OpenGLRenderer()
 {
     _renderContext     = new RenderContext();
     _graphicsDevice    = SGL.QueryComponents <GraphicsDevice>();
     _textEntityManager = new TextEntityManager();
     _window            = SGL.QueryComponents <RenderTarget>().Window;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new EntityComposer class.
        /// </summary>
        public EntityComposer()
        {
            Projectiles      = new List <Projectile>();
            Enemies          = new List <Enemy>();
            Explosions       = new List <Explosion>();
            Input            = SGL.QueryComponents <InputManager>();
            _scoreIndicators = new List <ScoreIndicator>();
            Score            = 0;
            _random          = new GameRandom();

            var contentManager = SGL.QueryComponents <ContentManager>();

            var playerTexture = contentManager.Load <Texture2D>("shipAnimation.png");

            _projectileTexture = contentManager.Load <Texture2D>("laser.png");
            _enemyTexture      = contentManager.Load <Texture2D>("mineAnimation.png");
            _explosionTexture  = contentManager.Load <Texture2D>("explosion.png");
            EnableHPBars       = true;

            _laserFire = new SoundEffect(SGL.QueryResource <Sound>("laserFire.wav"),
                                         AudioManager.Instance.SoundEffectGroups[0]);
            _explosion = new SoundEffect(SGL.QueryResource <Sound>("explosion.wav"),
                                         AudioManager.Instance.SoundEffectGroups[0]);

            AudioManager.Instance.SoundEffectGroups[0].MasterVolume = 0.05f;

            Player = new Player(playerTexture);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes the scene.
 /// </summary>
 public override void Initialize()
 {
     _backgroundPosition = new Vector2(0);
     _font  = new Font("Segoe UI", 30, TypefaceStyle.Bold);
     _font2 = new Font("Segoe UI", 13, TypefaceStyle.Regular);
     _font3 = new Font("Segoe UI", 16, TypefaceStyle.Bold);
     Input  = SGL.QueryComponents <InputManager>();
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a content resource.
        /// </summary>
        /// <param name="path">The Path.</param>
        /// <returns>AudioSource.</returns>
        public override AudioSource CreateContent(string path)
        {
            var source = SGL.QueryComponents <AudioManager>().CreatePropperAudioSource(path);

            source.Instance.Name = new FileInfo(path).Name;

            return(source);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new Minimap class.
 /// </summary>
 /// <param name="entityComposer">The EntityComposer.</param>
 public Minimap(EntityComposer entityComposer)
 {
     _enemyPositions        = new List <Vector2>();
     _currentEntityComposer = entityComposer;
     _projectilePositions   = new List <Vector2>();
     _magicNumberX          = 800 / Width;
     _magicNumberY          = 800 / Height;
     Visible  = true;
     _minimap = SGL.QueryComponents <ContentManager>().Load <Texture2D>("minimap.png");
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new DirectXGraphics class.
        /// </summary>
        public DirectXGraphics()
        {
            ResourceManager   = new DirectXResourceManager();
            ContentProcessors = new IContentProcessor[]
            { new DirectXFontContentProcessor(), new DirectXPenContentProcessor(), new DirectXTextureContentProcessor() };
            SmoothingMode     = SmoothingMode.AntiAlias;
            InterpolationMode = InterpolationMode.Linear;

            _graphicsDevice = SGL.QueryComponents <GraphicsDevice>();
        }
Ejemplo n.º 9
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            RenderTarget renderTarget = RenderTarget.Create();

            renderTarget.Window.Title         = string.Format("XPlane {0}", Application.ProductVersion);
            renderTarget.Window.Icon          = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            renderTarget.Window.SurfaceLayout = new SurfaceLayout(true, false, true);

            SGL.Initialize(new Configurator(new BackBuffer(800, 480), new Game1(), renderTarget));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes a new DirectXGraphics class.
        /// </summary>
        public DirectXGraphics()
        {
            ResourceManager   = new DirectXResourceManager();
            ContentProcessors = new IContentProcessor[]
            { new DirectXFontContentProcessor(), new DirectXPenContentProcessor(), new DirectXTextureContentProcessor() };
            SmoothingMode     = SmoothingMode.AntiAlias;
            InterpolationMode = InterpolationMode.Linear;

            _graphicsDevice = SGL.QueryComponents <GraphicsDevice>();

            var d2DFactory = new Factory(FactoryType.MultiThreaded);

            DirectXHelper.D2DFactory         = d2DFactory;
            DirectXHelper.DirectWriteFactory = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared);
        }
Ejemplo n.º 11
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            RenderTarget renderTarget = RenderTarget.Create();

            renderTarget.Window.Icon             = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            renderTarget.Window.Title            = "Flying Bird";
            renderTarget.Window.CursorVisibility = true;
            renderTarget.Window.SurfaceLayout    = new SurfaceLayout(true, false, true);

            SGL.Initialize();

            SGL.Components.Get <GraphicsDevice>().ClearColor = Color.FromArgb(255, 128, 197, 205);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Updates the scene.
        /// </summary>
        /// <param name="gameTime">The GameTime.</param>
        public override void Update(GameTime gameTime)
        {
            _blackBlend.Update(gameTime);
            UIManager.Update(gameTime);

            if (_menuButton1.IsMouseDown(MouseButtons.Left))
            {
                SGL.QueryComponents <SceneManager>().ActiveScene = SGL.QueryComponents <SceneManager>().Get <GameScene>();
            }

            if (_menuButton3.IsMouseDown(MouseButtons.Left))
            {
                Application.Exit();
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Updates the scene.
        /// </summary>
        /// <param name="gameTime">The GameTime.</param>
        public override void Update(GameTime gameTime)
        {
            _blackBlend.Update(gameTime);

            if (Input.Keyboard.GetState().IsKeyDown(Keys.Enter))
            {
                SGL.QueryComponents <SceneManager>().ActiveScene = SGL.QueryComponents <SceneManager>().Get <MenuScene>();
            }

            float achievementLvl = AchievementManager.Achievements.Sum(achievement => achievement.CurrentLevel);

            achievementLvl /= AchievementManager.Achievements.Count;

            _achievmentMultiplier = achievementLvl;

            _finalScore = (int)(Score * achievementLvl);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Initializes a new DebugDisplay class.
        /// </summary>
        /// <param name="entityComposer">The EntityComposer.</param>
        public DebugDisplay(EntityComposer entityComposer)
        {
            _currentEntityComposer = entityComposer;
            _gameLoop = SGL.QueryComponents <GameLoop>();

            _font          = new Font("Segoe UI", 12, TypefaceStyle.Regular);
            _cpuWatcher    = new CpuWatcher();
            _memoryWatcher = new MemoryWatcher();
            _threadWatcher = new ThreadWatcher();
            _display       = new Rectangle(0, 0, 800, 480);
            _debugMessage  = "Query information ...";
            _pen           = new Pen(Color.Green, 1);
            _pen2          = new Pen(Color.Red, 1);
            _pen3          = new Pen(Color.Blue, 1);

            _cpuWatcher.Start();
            _memoryWatcher.Start();
            _threadWatcher.Start();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new AudioEffect class.
        /// </summary>
        /// <param name="audioSource">The AudioSource.</param>
        public AudioEffect(AudioSource audioSource)
        {
            AudioSource = audioSource;
            var audioInitializer = SGL.QueryComponents <AudioManager>().AudioInitializer;
            var logger           = LogManager.GetClassLogger();

            if (audioInitializer == null)
            {
                logger.Warn("The specified audio initializer was null.");
            }
            else if (!audioInitializer.IsSupported)
            {
                logger.Warn("The specified AudioProvider is not supported.");
            }
            else
            {
                _audioProvider = audioInitializer.Create();
                _audioProvider.PlaybackChanged += PlaybackChanged;
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Updates the scene.
 /// </summary>
 /// <param name="gameTime">The GameTime.</param>
 public override void Update(GameTime gameTime)
 {
     _skyBox.Update(gameTime);
     _fadeableText1.Update(gameTime);
     if (_fadeableText1.AnimationComplete)
     {
         _fadeableText2.Update(gameTime);
         if (_fadeableText2.AnimationComplete)
         {
             _fadeableText3.Update(gameTime);
             if (_fadeableText3.AnimationComplete)
             {
                 _blackBlend.Update(gameTime);
                 if (_blackBlend.IsCompleted)
                 {
                     SGL.QueryComponents <SceneManager>().ActiveScene =
                         SGL.QueryComponents <SceneManager>().Get <MenuScene>();
                 }
             }
         }
     }
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Initializes a new Keyboard class.
 /// </summary>
 public Keyboard()
 {
     _currentKeyState = new Dictionary <Keys, bool>();
     _gameWindow      = SGL.QueryComponents <RenderTarget>().Window;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Initializes the Scene.
 /// </summary>
 public override void Initialize()
 {
     Input = SGL.QueryComponents <InputManager>();
 }
Ejemplo n.º 19
0
 /// <summary>
 /// FormClosing Event.
 /// </summary>
 /// <param name="sender">The Sender.</param>
 /// <param name="e">The EventArgs.</param>
 private void _surface_FormClosing(object sender, FormClosingEventArgs e)
 {
     e.Cancel = true;
     SGL.Shutdown();
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Initializes the RenderContext.
        /// </summary>
        public void Initialize()
        {
            _windowHandle = SGL.QueryComponents <RenderTarget>().Handle;

            _deviceContext = NativeMethods.GetDC(_windowHandle);

            var pfd = new PixelFormatDescriptor();

            pfd.Size              = (short)Marshal.SizeOf(pfd);
            pfd.Version           = 1;
            pfd.FormatDescription = PixelFormatDescription.DrawToWindow |
                                    PixelFormatDescription.SupportOpenGL |
                                    PixelFormatDescription.DoubleBuffer;
            pfd.PixelType      = 0;
            pfd.ColorBits      = 24;
            pfd.RedBits        = 0;
            pfd.RedShift       = 0;
            pfd.GreenBits      = 0;
            pfd.GreenShift     = 0;
            pfd.BlueBits       = 0;
            pfd.BlueShift      = 0;
            pfd.AlphaBits      = 0;
            pfd.AlphaShift     = 0;
            pfd.AccumBits      = 0;
            pfd.AccumRedBits   = 0;
            pfd.AccumGreenBits = 0;
            pfd.AccumBlueBits  = 0;
            pfd.AccumAlphaBits = 0;
            pfd.DepthBits      = 24;
            pfd.StencilBits    = 8;
            pfd.AuxBuffers     = 0;
            pfd.LayerType      = 0;
            pfd.Reserved       = 0;
            pfd.LayerMask      = 0;
            pfd.VisibleMask    = 0;
            pfd.DamageMask     = 0;

            int pixelFormat;

            if ((pixelFormat = OpenGLInterops.ChoosePixelFormat(_deviceContext, ref pfd)) == 0)
            {
                throw new GraphicsException("Unable to choose pixel format.");
            }

            if (!OpenGLInterops.SetPixelFormat(_deviceContext, pixelFormat, ref pfd))
            {
                throw new GraphicsException("Unable to set pixel format.");
            }

            _renderContext = OpenGLInterops.wglCreateContext(_deviceContext);
            OpenGLInterops.wglMakeCurrent(_deviceContext, _renderContext);

            try
            {
                int[] attributes =
                {
                    (int)ContextAttributes.MajorVersion,                                        3,
                    (int)ContextAttributes.MinorVersion,                                        3,
                    (int)ContextAttributes.Flags,        (int)ContextAttributes.ForwardCompatible,
                    0
                };

                var hrc = OpenGLInterops.CreateContextWithAttributes(_deviceContext, IntPtr.Zero, attributes);
                OpenGLInterops.wglMakeCurrent(IntPtr.Zero, IntPtr.Zero);
                OpenGLInterops.wglDeleteContext(_renderContext);
                OpenGLInterops.wglMakeCurrent(_deviceContext, hrc);
                _renderContext = hrc;
            }
            catch (MissingMethodException)
            {
                throw new GraphicsException("Unable to create OpenGL 3.3 context.");
            }
        }