GetAlpha() public method

public GetAlpha ( Color newColor ) : Color
newColor Color
return Color
Exemplo n.º 1
0
        public static void DrawChain(int index, Vector2 to, string chainPath)
        {
            Texture2D texture = ModLoader.GetTexture(chainPath);

            Terraria.Projectile projectile      = Main.projectile[index];
            Vector2             vector          = projectile.Center;
            Rectangle?          sourceRectangle = null;
            Vector2             origin          = new Vector2((float)texture.Width * 0.5f, (float)texture.Height * 0.5f);
            float   num      = (float)texture.Height;
            Vector2 vector2  = to - vector;
            float   rotation = (float)Math.Atan2((double)vector2.Y, (double)vector2.X) - 1.57f;
            bool    flag     = true;

            if (float.IsNaN(vector.X) && float.IsNaN(vector.Y))
            {
                flag = false;
            }
            if (float.IsNaN(vector2.X) && float.IsNaN(vector2.Y))
            {
                flag = false;
            }
            while (flag)
            {
                if ((double)vector2.Length() < (double)num + 1.0)
                {
                    flag = false;
                }
                else
                {
                    Vector2 value = vector2;
                    value.Normalize();
                    vector += value * num;
                    vector2 = to - vector;
                    Color color = Lighting.GetColor((int)vector.X / 16, (int)((double)vector.Y / 16.0));
                    color = projectile.GetAlpha(color);
                    Main.spriteBatch.Draw(texture, vector - Main.screenPosition, sourceRectangle, color, rotation, origin, 1f, SpriteEffects.None, 0f);
                }
            }
        }
Exemplo n.º 2
0
        public static void DrawSpear(int index, Color lightColor)
        {
            Terraria.Projectile projectile = Main.projectile[index];
            Vector2             zero       = Vector2.Zero;
            SpriteEffects       effects    = SpriteEffects.None;

            if (projectile.spriteDirection == -1)
            {
                zero.X  = (float)Main.projectileTexture[projectile.type].Width;
                effects = SpriteEffects.FlipHorizontally;
            }
            Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], new Vector2(projectile.position.X - Main.screenPosition.X + (float)(projectile.width / 2), projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY), new Rectangle?(new Rectangle(0, 0, Main.projectileTexture[projectile.type].Width, Main.projectileTexture[projectile.type].Height)), projectile.GetAlpha(lightColor), projectile.rotation, zero, projectile.scale, effects, 0f);
        }