Ejemplo n.º 1
0
        public override void Draw(GameTime gameTime)
        {
            SokobanGame.Instance.GraphicsDevice.Clear(Colors.GameScreenBackground);

            map.Draw();

            sb.Begin();
            var       tex = map.Tileset.Texture;
            Rectangle r   = new Rectangle((int)(playerPos.X * map.TileWidth + map.RenderOffset.X),
                                          (int)(playerPos.Y * map.TileHeight + map.RenderOffset.Y),
                                          map.TileWidth,
                                          map.TileHeight);

            sb.Draw(tex, r, map.Tileset.GetSourceRect(playerTile), Color.White);
            sb.End();

            if (debugMode)
            {
                map.DrawDebug();
            }

            int width  = SokobanGame.Width;
            int height = SokobanGame.Height;

            sb.DrawRect(0, 0, width, topPad, Colors.PadBackground);
            sb.DrawRect(0, height - botPad, width, botPad, Colors.PadBackground);

            sb.DrawRect(0, topPad, width, borderSize, Colors.PadBorder);
            sb.DrawRect(0, height - botPad - borderSize, width, borderSize, Colors.PadBorder);

            string lvlName;

            if (!map.Properties.TryGetValue("Name", out lvlName))
            {
                lvlName = "noname";
            }

            sb.Begin();
            float midTopPad = topPad * 0.5f;
            int   s         = topPad / 2 + 4;

            r.X      = 40;
            r.Y      = (int)(midTopPad - s);
            r.Width  = s * 2;
            r.Height = s * 2;

            sb.Draw(Assets.Keys, r, Assets.SrcEsc, Color.White);
            var tr = sb.DrawString(font, "Go Back", new Vector2(r.Right, midTopPad), Colors.PadText, Align.MidLeft);

            r.X = tr.Right;
            sb.Draw(Assets.PadBtns, r, Assets.SrcB, Color.White);

            sb.DrawString(font, lvlName, new Vector2(width * 0.5f, midTopPad), Colors.PadText, Align.Center);

            string moves = string.Format("Moves: {0}", map.Room.Moves);

            sb.DrawString(font, moves, new Vector2(width * 0.75f, midTopPad), Colors.PadText, Align.MidLeft);

            float midBotPad = height - botPad * 0.5f;

            s = botPad / 2 + 4;

            r.X      = width / 2 - s;
            r.Y      = (int)(midBotPad - s);
            r.Width  = s * 2;
            r.Height = s * 2;
            sb.Draw(Assets.Keys, r, Assets.SrcR, Color.White);

            tr  = sb.DrawString(font, "Reset", new Vector2(r.Right, midBotPad), Colors.PadText, Align.MidLeft);
            r.X = r.X - r.Width - 48;
            sb.Draw(Assets.PadBtns, r, Assets.SrcDPad, Color.White);
            var mr = sb.DrawString(font, "Move", new Vector2(r.X - 8, midBotPad), Colors.PadText, Align.MidRight);

            r.X = mr.X - r.Width - 4;
            sb.Draw(Assets.Keys, r, Assets.SrcUp, Color.White);
            r.X = r.X - r.Width + 12;
            sb.Draw(Assets.Keys, r, Assets.SrcRight, Color.White);
            r.X = r.X - r.Width + 12;
            sb.Draw(Assets.Keys, r, Assets.SrcDown, Color.White);
            r.X = r.X - r.Width + 12;
            sb.Draw(Assets.Keys, r, Assets.SrcLeft, Color.White);

            r.X = tr.Right;
            sb.Draw(Assets.PadBtns, r, Assets.SrcY, Color.White);

            r.X = r.Right + 48;
            sb.Draw(Assets.Keys, r, Assets.SrcZ, Color.White);
            var ur = sb.DrawString(font, "Undo", new Vector2(r.Right, midBotPad), Colors.PadText, Align.MidLeft);

            r.X = ur.Right;
            sb.Draw(Assets.PadBtns, r, Assets.SrcX, Color.White);

            sb.End();

            if (!debugMode)
            {
                return;
            }
            SokobanGame.Instance.DrawDebugMessage(string.Format("Solved: {0}", map.Room.IsSolved()), new Vector2(300, 60), Color.Black);
            SokobanGame.Instance.DrawDebugMessage(string.Format("Entities: {0}", map.Room.CurrentState.Entities.Count), new Vector2(SokobanGame.Width - 300, 60), Color.Black);
            int i = 0;

            foreach (Entity e in map.Room.CurrentState.Entities)
            {
                string info = string.Format("{0} => {1}", e.Pos, e.GetType().Name);
                SokobanGame.Instance.DrawDebugMessage(info, new Vector2(SokobanGame.Width - 300, 80 + i * 20), Color.Black);
                i++;
            }
            InputManager.DrawDebugThumbStick(100, 100, 200);
        }