Ejemplo n.º 1
0
        public void DrawMap(SpriteBatch batch, Vector2 posistion)
        {
            posistion += Camera.Position;
            var yOffset = posistion.Y;

            for (var y = 0; y < Rows; y++)
            {
                var xOffset = posistion.X;
                for (var x = 0; x < Columns; x++)
                {
                    var offset = new Vector2(xOffset, yOffset);
                    TileSet.DrawTile(batch, Layer1.GetTile(x, y), offset, posistion, null, 0.4f);
                    if (x == (int)Start.X && y == (int)Start.Y)
                    {
                        TileSet.DrawTile(batch, WorldHelpers.GetStartTile(StartSide), offset, posistion, null, 0.45f);
                    }
                    if (x == (int)End.X && y == (int)End.Y)
                    {
                        TileSet.DrawTile(batch, WorldHelpers.GetEndTile(EndSide), offset, posistion, null, 0.45f);
                    }
                    foreach (var p in Players)
                    {
                        p.Draw(batch, posistion);
                    }

                    TileSet.DrawTileBridges(batch, Layer1.GetTile(x, y), offset, posistion, null, 0.6f);


                    TileSet.DrawTile(batch, Layer2.GetTile(x, y), offset, posistion, Players, 0.7f);
                    TileSet.DrawTileBridges(batch, Layer2.GetTile(x, y), offset, posistion, null, 0.9f);
                    xOffset += TileSet.TileWidth;
                    if (xOffset > Game.Width)
                    {
                        break;
                    }
                }
                yOffset += TileSet.TileHeight;
                if (yOffset > Game.Height)
                {
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public override void Draw(SpriteBatch batch)
        {
            var posistion = Camera.Position;

            batch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone);
            {
                batch.Draw(Game.SideBar);
                foreach (var t in Tiles)
                {
                    var c      = t == CurrentTile ? Color.White : Color.Gray;
                    var offset = new Vector2(t.MapLocation.X * TileSet.TileWidth, t.MapLocation.Y * TileSet.TileHeight) +
                                 Camera.Position;
                    TileSet.DrawTile(batch, t.BottomTileNumber, offset, posistion, null, 0.4f, 1f, c);
                    TileSet.DrawTileBridges(batch, t.BottomTileNumber, offset, posistion, null, 0.6f, 1f, c);
                    if (StartLayer == 1 && t.MapLocation.X == (int)Start.X && t.MapLocation.Y == (int)Start.Y)
                    {
                        TileSet.DrawTile(batch, WorldHelpers.GetStartTile(StartSide), offset, posistion, null, 0.45f);
                    }
                    if (EndLayer == 1 && t.MapLocation.X == (int)End.X && t.MapLocation.Y == (int)End.Y)
                    {
                        TileSet.DrawTile(batch, WorldHelpers.GetEndTile(EndSide), offset, posistion, null, 0.45f);
                    }
                    TileSet.DrawTile(batch, t.TopTileNumber, offset, posistion, null, 0.7f, 1, c * 0.5f);
                    TileSet.DrawTileBridges(batch, t.TopTileNumber, offset, posistion, null, 0.8f, 1, c * 0.5f);
                    var os = t.OpenSides();
                    foreach (var s in os[0])
                    {
                        c = Layer == 1 ? Color.Red * 0.5f : Color.Red * 0.25f;
                        switch (s)
                        {
                        case Side.Top:
                            batch.Draw(Golf.Pixel,
                                       new Rectangle((int)offset.X, (int)offset.Y - TileSet.TileHeight, TileSet.TileWidth,
                                                     TileSet.TileHeight), null, c, 0, Vector2.Zero, SpriteEffects.None, 1f);
                            break;

                        case Side.Bottom:
                            batch.Draw(Golf.Pixel,
                                       new Rectangle((int)offset.X, (int)offset.Y + TileSet.TileHeight, TileSet.TileWidth,
                                                     TileSet.TileHeight), null, c, 0, Vector2.Zero, SpriteEffects.None, 1f);
                            break;

                        case Side.Left:
                            batch.Draw(Golf.Pixel,
                                       new Rectangle((int)offset.X - TileSet.TileWidth, (int)offset.Y, TileSet.TileWidth,
                                                     TileSet.TileHeight), null, c, 0, Vector2.Zero, SpriteEffects.None, 1f);
                            break;

                        case Side.Right:
                            batch.Draw(Golf.Pixel,
                                       new Rectangle((int)offset.X + TileSet.TileWidth, (int)offset.Y, TileSet.TileWidth,
                                                     TileSet.TileHeight), null, c, 0, Vector2.Zero, SpriteEffects.None, 1f);
                            break;
                        }
                    }
                    foreach (var s in os[1])
                    {
                        c = Layer == 2 ? Color.Blue * 0.5f : Color.Blue * 0.25f;
                        switch (s)
                        {
                        case Side.Top:
                            batch.Draw(Golf.Pixel,
                                       new Rectangle((int)offset.X, (int)offset.Y - TileSet.TileHeight, TileSet.TileWidth,
                                                     TileSet.TileHeight), null, c, 0, Vector2.Zero, SpriteEffects.None, 1f);
                            break;

                        case Side.Bottom:
                            batch.Draw(Golf.Pixel,
                                       new Rectangle((int)offset.X, (int)offset.Y + TileSet.TileHeight, TileSet.TileWidth,
                                                     TileSet.TileHeight), null, c, 0, Vector2.Zero, SpriteEffects.None, 1f);
                            break;

                        case Side.Left:
                            batch.Draw(Golf.Pixel,
                                       new Rectangle((int)offset.X - TileSet.TileWidth, (int)offset.Y, TileSet.TileWidth,
                                                     TileSet.TileHeight), null, c, 0, Vector2.Zero, SpriteEffects.None, 1f);
                            break;

                        case Side.Right:
                            batch.Draw(Golf.Pixel,
                                       new Rectangle((int)offset.X + TileSet.TileWidth, (int)offset.Y, TileSet.TileWidth,
                                                     TileSet.TileHeight), null, c, 0, Vector2.Zero, SpriteEffects.None, 1f);
                            break;
                        }
                    }
                }
            }
            batch.End();
            batch.Begin();
            {
                var str = Fonts.GameFont.MeasureString(Strings.Exit);
                batch.DrawString(Fonts.GameFont, Strings.Exit,
                                 new Vector2(Game.Width - (str.X + 10) + 2, Game.Height - (str.Y + 10) + 3),
                                 Color.Black * 0.25f);
                batch.DrawString(Fonts.GameFont, Strings.Exit,
                                 new Vector2(Game.Width - (str.X + 10), Game.Height - (str.Y + 10)),
                                 Color.White);

                DrawTileSelector(batch, Layer == 1 ? CurrentTile.BottomTileNumber : CurrentTile.TopTileNumber);
                DrawLayerSelector(batch);
                DrawLayerDeleteSelector(batch);
                DrawStartSelector(batch);
                DrawEndSelector(batch);
                DrawPlaySelector(batch);
                DrawSaveSelector(batch);
                batch.End();
            }
            base.Draw(batch);
        }