public void DrawDefaultTile(SpriteBatch spriteBatch, Loc drawPos)
 {
     BlankBG.Draw(spriteBatch, drawPos);
 }
        public override void DrawGame(SpriteBatch spriteBatch)
        {
            //
            //When in editor mode, we want to display an overlay over some entities
            //
            base.DrawGame(spriteBatch);


            if (DiagManager.Instance.DevEditor.GroundEditor.Active && ZoneManager.Instance.CurrentGround != null)
            {
                if (AutoTileInProgress != null)
                {
                    for (int jj = viewTileRect.Y; jj < viewTileRect.End.Y; jj++)
                    {
                        for (int ii = viewTileRect.X; ii < viewTileRect.End.X; ii++)
                        {
                            Loc testLoc = new Loc(ii, jj);
                            if (Collision.InBounds(ZoneManager.Instance.CurrentGround.Width, ZoneManager.Instance.CurrentGround.Height, testLoc) &&
                                AutoTileInProgress.IncludesLoc(testLoc))
                            {
                                AutoTile brush = AutoTileInProgress.GetBrush(testLoc);
                                if (brush.IsEmpty())
                                {
                                    GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * ZoneManager.Instance.CurrentGround.TileSize - ViewRect.X, jj * ZoneManager.Instance.CurrentGround.TileSize - ViewRect.Y, ZoneManager.Instance.CurrentGround.TileSize, ZoneManager.Instance.CurrentGround.TileSize), null, Color.Black);
                                }
                                else
                                {
                                    brush.Draw(spriteBatch, new Loc(ii * ZoneManager.Instance.CurrentGround.TileSize, jj * ZoneManager.Instance.CurrentGround.TileSize) - ViewRect.Start);
                                }
                            }
                        }
                    }
                }

                //draw the blocks
                if (ShowWalls)
                {
                    int texSize = ZoneManager.Instance.CurrentGround.TexSize;
                    for (int jj = viewTileRect.Y * texSize; jj < viewTileRect.End.Y * texSize; jj++)
                    {
                        for (int ii = viewTileRect.X * texSize; ii < viewTileRect.End.X * texSize; ii++)
                        {
                            Loc testLoc = new Loc(ii, jj);
                            if (Collision.InBounds(ZoneManager.Instance.CurrentGround.Width * texSize, ZoneManager.Instance.CurrentGround.Height * texSize, testLoc))
                            {
                                bool blocked = ZoneManager.Instance.CurrentGround.GetObstacle(ii, jj) == 1u;
                                if (BlockInProgress != null && BlockInProgress.IncludesLoc(testLoc))
                                {
                                    blocked = BlockInProgress.GetBrush(testLoc);
                                }

                                if (blocked)
                                {
                                    GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * GraphicsManager.TEX_SIZE - ViewRect.X, jj * GraphicsManager.TEX_SIZE - ViewRect.Y, GraphicsManager.TEX_SIZE, GraphicsManager.TEX_SIZE), null, Color.Red * 0.6f);
                                }
                            }
                        }
                    }
                }


                //DevHasGraphics()
                //Draw Entity bounds
                GroundDebug dbg = new GroundDebug(spriteBatch, Color.BlueViolet);
                foreach (GroundEntity entity in ZoneManager.Instance.CurrentGround.IterateEntities())
                {
                    if (entity.DevEntitySelected)
                    {
                        //Invert the color of selected entities
                        dbg.DrawColor     = new Color(entity.DevEntColoring.B, entity.DevEntColoring.G, entity.DevEntColoring.R, entity.DevEntColoring.A);
                        dbg.LineThickness = 1.0f;
                        dbg.DrawFilledBox(new Rect(entity.Bounds.X, entity.Bounds.Y, entity.Width - 1, entity.Height - 1), 92);
                    }
                    else if (!entity.DevHasGraphics())
                    {
                        //Draw entities with no graphics of their own as a filled box
                        dbg.DrawColor     = entity.DevEntColoring;
                        dbg.LineThickness = 1.0f;
                        dbg.DrawFilledBox(new Rect(entity.Bounds.X, entity.Bounds.Y, entity.Width - 1, entity.Height - 1), 128);
                    }
                    else
                    {
                        //Draw boxes around other entities with graphics using low opacity
                        dbg.DrawColor     = new Color(entity.DevEntColoring.R, entity.DevEntColoring.G, entity.DevEntColoring.B, 92);
                        dbg.LineThickness = 1.0f;
                        dbg.DrawBox(new Rect(entity.Bounds.X, entity.Bounds.Y, entity.Width - 1, entity.Height - 1));
                    }
                    //And don't draw bounds of entities that have a graphics representation
                }
            }
        }
Exemple #3
0
        protected override void PostDraw(SpriteBatch spriteBatch)
        {
            Matrix matrix = Matrix.CreateScale(new Vector3(drawScale, drawScale, 1));

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, matrix);

            if (AutoTileInProgress != null)
            {
                for (int jj = viewTileRect.Y; jj < viewTileRect.End.Y; jj++)
                {
                    for (int ii = viewTileRect.X; ii < viewTileRect.End.X; ii++)
                    {
                        Loc testLoc = new Loc(ii, jj);
                        if (Collision.InBounds(ZoneManager.Instance.CurrentMap.Width, ZoneManager.Instance.CurrentMap.Height, testLoc) &&
                            AutoTileInProgress.IncludesLoc(testLoc))
                        {
                            AutoTile brush = AutoTileInProgress.GetBrush(testLoc);
                            if (brush.IsEmpty())
                            {
                                GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * GraphicsManager.TileSize - ViewRect.X, jj * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, Color.Black);
                            }
                            else
                            {
                                brush.Draw(spriteBatch, new Loc(ii * GraphicsManager.TileSize, jj * GraphicsManager.TileSize) - ViewRect.Start);
                            }
                        }
                    }
                }
            }

            //draw the blocks

            for (int jj = viewTileRect.Y; jj < viewTileRect.End.Y; jj++)
            {
                for (int ii = viewTileRect.X; ii < viewTileRect.End.X; ii++)
                {
                    Loc testLoc = new Loc(ii, jj);
                    if (Collision.InBounds(ZoneManager.Instance.CurrentMap.Width, ZoneManager.Instance.CurrentMap.Height, testLoc))
                    {
                        TerrainTile tile = ZoneManager.Instance.CurrentMap.Tiles[ii][jj].Data;
                        if (TerrainInProgress != null && TerrainInProgress.IncludesLoc(testLoc))
                        {
                            tile = TerrainInProgress.GetBrush(testLoc);
                            if (tile.TileTex.IsEmpty())
                            {
                                GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * GraphicsManager.TileSize - ViewRect.X, jj * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, Color.Black);
                            }
                            else
                            {
                                tile.TileTex.Draw(spriteBatch, new Loc(ii * GraphicsManager.TileSize, jj * GraphicsManager.TileSize) - ViewRect.Start);
                            }
                        }

                        if (ShowTerrain)
                        {
                            TerrainData data  = tile.GetData();
                            Color       color = Color.Transparent;
                            switch (data.BlockType)
                            {
                            case TerrainData.Mobility.Block:
                                color = Color.Red;
                                break;

                            case TerrainData.Mobility.Water:
                                color = Color.Blue;
                                break;

                            case TerrainData.Mobility.Lava:
                                color = Color.Orange;
                                break;

                            case TerrainData.Mobility.Abyss:
                                color = Color.Black;
                                break;

                            case TerrainData.Mobility.Impassable:
                                color = Color.White;
                                break;
                            }
                            if (color != Color.Transparent)
                            {
                                GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * GraphicsManager.TileSize - ViewRect.X, jj * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, color * 0.5f);
                            }
                        }
                    }
                }
            }
            if (ShowEntrances)
            {
                foreach (LocRay8 entrance in ZoneManager.Instance.CurrentMap.EntryPoints)
                {
                    Color showColor = Color.OrangeRed;
                    GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(entrance.Loc.X * GraphicsManager.TileSize - ViewRect.X, entrance.Loc.Y * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, showColor * 0.75f);
                }
            }

            if (TileInProgress != null)
            {
                for (int jj = viewTileRect.Y; jj < viewTileRect.End.Y; jj++)
                {
                    for (int ii = viewTileRect.X; ii < viewTileRect.End.X; ii++)
                    {
                        Loc testLoc = new Loc(ii, jj);
                        if (Collision.InBounds(ZoneManager.Instance.CurrentMap.Width, ZoneManager.Instance.CurrentMap.Height, testLoc) &&
                            TileInProgress.IncludesLoc(testLoc))
                        {
                            EffectTile tile = TileInProgress.GetBrush(testLoc);
                            if (tile.ID < 0)
                            {
                                GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * GraphicsManager.TileSize - ViewRect.X, jj * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, Color.Black);
                            }
                            else
                            {
                                TileData entry = DataManager.Instance.GetTile(tile.ID);
                                if (entry.Anim.AnimIndex != "")
                                {
                                    DirSheet sheet   = GraphicsManager.GetObject(entry.Anim.AnimIndex);
                                    Loc      drawLoc = new Loc(ii * GraphicsManager.TileSize, jj * GraphicsManager.TileSize) - ViewRect.Start + new Loc(GraphicsManager.TileSize / 2) - new Loc(sheet.Width, sheet.Height) / 2;
                                    sheet.DrawDir(spriteBatch, drawLoc.ToVector2(), entry.Anim.GetCurrentFrame(GraphicsManager.TotalFrameTick, sheet.TotalFrames),
                                                  entry.Anim.GetDrawDir(Dir8.None), Color.White);
                                }
                                else
                                {
                                    GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * GraphicsManager.TileSize - ViewRect.X, jj * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, Color.White);
                                }
                            }
                        }
                    }
                }
            }

            spriteBatch.End();
        }