예제 #1
0
        protected override void Draw(GameTime gameTime)
        {
            dPhase = DrawPhase.Trans;
            //draw translated stuff on the target
            Matrix translator = Matrix.CreateTranslation(translation.X, translation.Y, 0);

            GraphicsDevice.SetRenderTarget(rt);
            spriteBatch.Begin(transformMatrix: translator, samplerState: SamplerState.PointWrap);
            switch (gm)
            {
            case (GameMode.TilesetEditor):
                DrawEditor();
                break;

            case (GameMode.Game):
                DrawGame();
                break;

            case (GameMode.Menus):
                DrawMenus();
                break;
            }
            spriteBatch.End();
            dPhase = DrawPhase.NonTrans;
            GraphicsDevice.SetRenderTarget(nonTransRt);
            GraphicsDevice.Clear(Color.TransparentBlack);
            spriteBatch.Begin(samplerState: SamplerState.PointWrap);
            switch (gm)
            {
            case (GameMode.TilesetEditor):
                DrawEditor();
                break;

            case (GameMode.Game):
                DrawGame();
                break;

            case (GameMode.Menus):
                DrawMenus();
                break;
            }
            cursor.Draw(spriteBatch, mousePos, 1f, false);
            spriteBatch.End();
            //draw overlay
            GraphicsDevice.SetRenderTarget(null);
            //draw the non translated target
            Matrix scaler = Matrix.CreateScale(scale.X, scale.Y, 0);

            spriteBatch.Begin(transformMatrix: scaler);
            spriteBatch.Draw(rt, rtPos, null);
            spriteBatch.Draw(nonTransRt, rtPos, null);
            spriteBatch.End();
            base.Draw(gameTime);
        }
예제 #2
0
 //draw
 void DrawOverlay()
 {
     foreach (Tile t in ts.tiles)
     {
         foreach (Point p in currentRange)
         {
             if (t.tsPos == p)
             {
                 overlay.Draw(spriteBatch, t.pos, zoom, true);
             }
         }
     }
 } //temp?
예제 #3
0
 public void DrawIcon(SpriteBatch sb_, int dim_, Vector2 pos_)
 {
     icon.Draw(sb_, pos_, (float)dim_ / icon.frame.Width, false);
 }
예제 #4
0
 public virtual void Draw(SpriteBatch sb_, float zoom_)
 {
     tex.Draw(sb_, pos, zoom_, false);
 }
예제 #5
0
        public void Draw(Rectangle rec_, SpriteBatch sb_)
        {
            if (hasStyle)
            {
                int l  = 0;
                int r  = 0;
                int u  = 0;
                int d  = 0;
                int mx = 0;
                int my = 0;

                MagicTexture L  = GetPiece("L");
                MagicTexture R  = GetPiece("R");
                MagicTexture U  = GetPiece("U");
                MagicTexture D  = GetPiece("D");
                MagicTexture UR = GetPiece("UR");
                MagicTexture UL = GetPiece("UL");
                MagicTexture DL = GetPiece("DL");
                MagicTexture DR = GetPiece("DR");
                MagicTexture M  = GetPiece("M");

                MagicTexture UC = GetPiece("UC");

                for (int x = 0; x *L.frame.Height < rec_.Height; x++)
                {
                    l = x + 1;
                }
                for (int x = 0; x *R.frame.Height < rec_.Height; x++)
                {
                    r = x + 1;
                }
                for (int x = 0; x *U.frame.Width < rec_.Width; x++)
                {
                    u = x + 1;
                }
                for (int x = 0; x *D.frame.Width < rec_.Width; x++)
                {
                    d = x + 1;
                }
                for (int x = 0; x *D.frame.Width < rec_.Width; x++)
                {
                    mx = x + 1;
                }
                for (int x = 0; x *M.frame.Height < rec_.Height; x++)
                {
                    my = x + 1;
                }

                //draw corners
                UL.Draw(sb_, new Vector2(rec_.X, rec_.Y), 1f, false);
                UR.Draw(sb_, new Vector2(rec_.X + U.frame.Width * u + UL.frame.Width, rec_.Y), 1f, false);
                DL.Draw(sb_, new Vector2(rec_.X, rec_.Y + L.frame.Height * l + UL.frame.Height), 1f, false);
                DR.Draw(sb_, new Vector2(rec_.X + U.frame.Width * u + UL.frame.Width, rec_.Y + L.frame.Height * l + UL.frame.Height), 1f, false);

                for (int x = 0; x < u; x++) //draw up parts
                {
                    U.Draw(sb_, new Vector2(rec_.X + UL.frame.Width + U.frame.Width * x, rec_.Y), 1f, false);
                }
                if (UC != null)
                {
                    UC.Draw(sb_, new Vector2(rec_.X + UL.frame.Width + (U.frame.Width * u) / 2 - UC.frame.Width / 2, rec_.Y), 1f, false);
                }
                for (int x = 0; x < l; x++) //draw left parts
                {
                    L.Draw(sb_, new Vector2(rec_.X, rec_.Y + L.frame.Height * x + UL.frame.Height), 1f, false);
                }
                for (int x = 0; x < d; x++) //draw down parts
                {
                    D.Draw(sb_, new Vector2(rec_.X + UL.frame.Width + U.frame.Width * x, rec_.Y + L.frame.Height * l + UL.frame.Height), 1f, false);
                }
                for (int x = 0; x < r; x++) //draw right parts
                {
                    R.Draw(sb_, new Vector2(rec_.X + UL.frame.Width + U.frame.Width * u, rec_.Y + L.frame.Height * x + UL.frame.Height), 1f, false);
                }
                for (int x = 0; x < mx; x++) //draw middle
                {
                    for (int y = 0; y < my; y++)
                    {
                        M.Draw(sb_, new Vector2(rec_.X + UL.frame.Width + M.frame.Width * x, rec_.X + UL.frame.Height + M.frame.Height * y), 1f, false);
                    }
                }
            }
        }