Example #1
0
        public void DrawUpperLayer(SpriteBatch spriteBatch)
        {
            foreach (var layer in _map.Layers.Where(l => l.Name != "UpperLayer"))
            {
                layer.IsVisible = false;
            }

            var upperLayer = _map.GetLayer("UpperLayer");

            upperLayer.IsVisible = true;

            InGameDebugger.AppendLine($"Opacity: {upperLayer.Opacity}");
            InGameDebugger.AppendLine($"Visibility: {upperLayer.IsVisible}");

            //_map.Draw(_camera.GetViewMatrix());

            spriteBatch.Begin(
                samplerState: SamplerState.PointClamp,
                blendState: BlendState.AlphaBlend,
                transformMatrix: _camera.GetViewMatrix()
                );

            foreach (var layer in _map.TileLayers.Where(t => t.Name.Equals("UpperLayer")))
            {
                layer.Draw(spriteBatch);
            }

            // Collisions DEBUG
            foreach (var rectangleF in Collisions)
            {
                spriteBatch.DrawRectangle(rectangleF, Color.Aqua);
            }
            spriteBatch.End();
        }
Example #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _componentSubject.LoadContent(Content);

            var debugSpriteFont = Content.Load <BitmapFont>("fonts/montserrat-32");

            InGameDebugger.Initialize(_spriteBatch, debugSpriteFont);
        }
Example #3
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            _graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            _componentSubject.Draw(gameTime, _spriteBatch, _camera);

            InGameDebugger.Flush();

            base.Draw(gameTime);
        }
Example #4
0
        public void UpdateUpperLayerVisibility(Player player)
        {
            var upperLayer = _map.TileLayers
                             .First(l => l.Name.Equals("UpperLayer"));
            var upperLayerTiles = from tile in upperLayer.Tiles
                                  where tile.Id != 0
                                  select new RectangleF(
                x: tile.X * upperLayer.TileWidth,
                y: tile.Y * upperLayer.TileHeight,
                width: upperLayer.TileWidth,
                height: upperLayer.TileHeight);
            var isCollidingWithPlayer = upperLayerTiles.Any(t => t.Intersects(player.BoundingBox));

            InGameDebugger.AppendLine($"IsColliding: {isCollidingWithPlayer}");

            upperLayer.Opacity = isCollidingWithPlayer ? 0.25f : 1f;
            //upperLayer.IsVisible = !isCollidingWithPlayer;
        }
    // Update is called once per frame
    void Update()
    {
        // Press R to restart
        if (Input.GetKeyDown(KeyCode.R))
        {
            // Just reloads the current scene.
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }

        // Press C to toggle debug info.
        if (Input.GetKeyDown(KeyCode.C))
        {
            InGameDebugger debugger = GetComponent <InGameDebugger>();
            if (debugger != null)
            {
                debugger.SetActive(!debugger.IsActive);
            }
        }
    }
Example #6
0
 public void Awake()
 {
     instance = this;
 }