コード例 #1
0
 public void Draw(SpriteBatch spriteBatch)
 {
     if (!active || CustomDraw(spriteBatch))
     {
         return;
     }
     if (dynamicTexture == null)
     {
         spriteBatch.Draw(texture, position, null, color, rotation, Vector2.Zero, scale, flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
     }
     else
     {
         dynamicTexture.Draw(spriteBatch, position, null, color, rotation, Vector2.Zero, scale, flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
     }
 }
コード例 #2
0
ファイル: Main.cs プロジェクト: ttqqll-DNPC/Stellaris
        protected override void Draw(GameTime gameTime)
        {
            Common.UpdateFPS(gameTime);
            GraphicsDevice.Clear(Color.Black);
            u.width   = 100;
            u.height  = 100;
            u.postion = new Vector2(100, 100);
            u.Update();
            Window.Title = u.mouseStatus.ToString();
            var z = Common.MouseState.position.Y / Common.Resolution.Y * 1.15f;

            vertexBatch.Begin(swordFx.Texture, PrimitiveType.TriangleList);
            var v = new Triangle(vertices).Rotate(timer, TriangleVertexType.A).RotationList(TriangleVertexType.A, 3.1415f).
                    TransformPosition(Matrix.CreateScale(1f, z, 1f), Common.MouseState.position);

            v = v.Transform(delegate(int index, Vertex vertex)
            {
                return(vertex.ChangeColor(vertex.Color * (index * 1.4f / v.vertex.Length)));
            });
            vertexBatch.Draw(v);
            vertexBatch.End();
            vertexBatch.Begin(PrimitiveType.LineStrip);
            u.DrawBorder(vertexBatch);
            vertexBatch.End();
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive);
            text.Draw(spriteBatch, new Vector2(100, 100), null, Color.White, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0);
            for (int i = 0; i < bullets.Count; i++)
            {
                if (bullets[i] == null)
                {
                    break;
                }
                bullets[i].Draw(spriteBatch);
            }
            for (int k = 0; k < 1; k++)
            {
                for (int i = 0; i < 15; i++)
                {
                    if (mousePos[i] != Vector2.Zero)
                    {
                        float m = (mousePos[i] - mousePos.TryGetValue(i + 1)).Length() * 0.3f;

                        /*try
                         * {
                         *  Vector2[] v = Helper.LagrangeInterpolation(mousePos.CutOut(i - 1, i + 1), (int)(m));
                         *  for (int j = 0; j < v.Length; j++)
                         *  {
                         *      a.Draw(spriteBatch, v[j] + k * new Vector2(10, 10), null, Color.White * (1.5f - (float)(Math.Sqrt(i) / Math.Sqrt(14))), 0.7853f, new Vector2(20, 20), 1.3f * (1 - (float)(Math.Sqrt(i) / Math.Sqrt(14))), SpriteEffects.None, 0f);
                         *  }
                         * }
                         * catch
                         * {
                         *
                         * }*/
                        for (int j = 0; j < m; j++)
                        {
                            a.Draw(spriteBatch, mousePos[i].LinearInterpolationTo(mousePos.TryGetValue(i + 1), j, m) + k * new Vector2(10, 10), null, Color.White * (1.1f - (float)(Math.Sqrt(i) / Math.Sqrt(14))), 0.7853f, new Vector2(20, 20), 0.9f * (1 - (float)(Math.Sqrt(i) / Math.Sqrt(14))), SpriteEffects.None, 0f);
                        }
                    }
                }
                MeteorBullet.flarefx.Draw(spriteBatch, mousePos[0], null, Color.White * 0.9f, 0.7853f, new Vector2(20, 20), 1.4f, SpriteEffects.None, 0f);
                spriteBatch.End();
                base.Draw(gameTime);
            }
        }