Terraria.Projectile.GetAlpha C# (CSharp) Method

GetAlpha() public method

public GetAlpha ( Color newColor ) : Color
newColor Color
return Color
        public Color GetAlpha(Color newColor)
        {
            if (type == 270)
                return new Color(255, 255, 255, Main.rand.Next(0, 255));
            int num1;
            int num2;
            int num3;
            if (type == 650)
            {
                int num4 = (int)(newColor.R * 1.5);
                int num5 = (int)(newColor.G * 1.5);
                int num6 = (int)(newColor.B * 1.5);
                if (num4 > 255)
                    num1 = 255;
                if (num5 > 255)
                    num2 = 255;
                if (num6 > 255)
                    num3 = 255;
            }
            else
            {
                if (type == 604 || type == 631)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 0);
                if (type == 636)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 64 - alpha / 4);
                if (type == 603 || type == 633)
                    return new Color(255, 255, 255, 200);
                if (type == 623 || type >= 625 && type <= 628)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 255 - alpha);
                if (type == 645 || type == 643)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 127 - alpha / 2);
                if (type == 611)
                    return new Color(255, 255, 255, 200);
                if (type == 640 || type == 644)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 0);
                if (type == 612)
                    return new Color(255, 255, 255, 127);
                if (aiStyle == 105)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 255 - alpha);
                if (type == 554)
                    return new Color(200, 200, 200, 200);
                if (type == 601)
                    return PortalHelper.GetPortalColor(owner, (int)ai[0]);
                if (type == 602)
                {
                    Color portalColor = PortalHelper.GetPortalColor(owner, (int)ai[1]);
                    portalColor.A = 227;
                    return portalColor;
                }
                if (type == 585)
                {
                    byte a = newColor.A;
                    newColor = Color.Lerp(newColor, Color.White, 0.5f);
                    newColor.A = a;
                    return newColor;
                }
                if (type == 573 || type == 578 || (type == 579 || type == 617) || type == 641)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 255 - alpha);
                if (type == 9 || type == 490)
                    return Color.White;
                if (type == 575 || type == 596)
                {
                    if (timeLeft < 30)
                        alpha = (int)(255 - 255 * (double)(timeLeft / 30f));
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 128 - alpha / 2);
                }
                if (type == 546)
                    return new Color(255, 200, 255, 200);
                if (type == 553)
                    return new Color(255, 255, 200, 200);
                if (type == 540)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 0);
                if (type == 498)
                    return new Color(255, 100, 20, 200);
                if (type == 538)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 255 - alpha);
                if (type == 518)
                {
                    float num4 = (float)(1.0 - (double)alpha / 255);
                    return new Color((int)(200.0 * num4), (int)(200.0 * num4), (int)(200.0 * num4), (int)(100.0 * num4));
                }
                if (type == 518 || type == 595)
                {
                    Color color = Color.Lerp(newColor, Color.White, 0.85f);
                    color.A = Convert.ToByte(-128);
                    return color * (float)(1.0 - (double)alpha / 255);
                }
                if (type == 536 || type == 607)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 63 - alpha / 4);
                if (type == 591)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 63 - alpha / 4);
                if (type == 493 || type == 494)
                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 255 - alpha);
                if (type == 492)
                    return new Color(255, 255, 255, 255);
                if (type == 491)
                    return new Color(255, 255, 255, 255);
                if (type == 485 || type == 502)
                    return new Color(255, 255, 255, 200);
                if (type == 488)
                    return new Color(255, 255, 255, 255);
                if (type == 477 || type == 478 || type == 479)
                {
                    if (alpha == 0)
                        return new Color(255, 255, 255, 200);
                    return new Color(0, 0, 0, 0);
                }
                if (type == 473)
                    return new Color(255, 255, 255, 255);
                if (type == 50 || type == 53 || type == 515)
                    return new Color(255, 255, 255, 0);
                if (type == 92)
                    return new Color(255, 255, 255, 0);
                if (type == 91)
                    return new Color(200, 200, 200, 0);
                if (type == 34 || type == 15 || (type == 93 || type == 94) || (type == 95 || type == 96 || (type == 253 || type == 258)) || type == 102 && alpha < 255)
                    return new Color(200, 200, 200, 25);
                if (type == 465)
                    return new Color(255, 255, 255, 0) * (float)(1.0 - (double)alpha / 255);
                if (type == 503)
                    return Color.Lerp(Color.Lerp(newColor, Color.White, 0.5f) * (float)(1.0 - (double)alpha / 255), Color.Lerp(Color.Purple, Color.White, 0.33f), (float)(0.25 + Math.Cos(localAI[0]) * 0.25));
                if (type == 467)
                    return new Color(255, 255, 255, 255) * (float)(1.0 - (double)alpha / 255);
                if (type == 634 || type == 635)
                    return new Color(255, 255, 255, 127) * Opacity;
                if (type == 451)
                    return new Color(255, 255, 255, 200) * (float)((255 - (double)alpha) / 255);
                if (type == 454 || type == 452)
                    return new Color(255, 255, 255, 255) * (float)(1.0 - (double)alpha / 255);
                if (type == 464)
                    return new Color(255, 255, 255, 255) * (float)((255 - (double)alpha) / 255);
                if (type == 450)
                    return new Color(200, 200, 200, 255 - alpha);
                if (type == 459)
                    return new Color(255, 255, 255, 200);
                if (type == 447)
                    return new Color(255, 255, 255, 200);
                if (type == 446)
                    return Color.Lerp(newColor, Color.White, 0.8f) * (float)(1.0 - (double)alpha / 255);
                if (type >= 646 && type <= 649)
                    return Color.Lerp(newColor, Color.White, 0.8f) * (float)(1.0 - (double)alpha / 255);
                if (type == 445)
                    return new Color(255, 255, 255, 128) * (float)(1.0 - (double)alpha / 255);
                if (type == 440 || type == 449 || type == 606)
                {
                    num1 = 255 - alpha;
                    num2 = 255 - alpha;
                    num3 = 255 - alpha;
                }
                else
                {
                    if (type == 444)
                        return newColor * (float)(1.0 - (double)alpha / 255);
                    if (type == 443)
                        return new Color(255, 255, 255, 128) * (float)(1.0 - (double)alpha / 255);
                    if (type == 438)
                        return new Color(255, 255, 255, 128) * (float)(1.0 - (double)alpha / 255);
                    if (type == 592)
                        return new Color(255, 255, 255, 128) * (float)(1.0 - (double)alpha / 255);
                    if (type == 437)
                        return new Color(255, 255, 255, 0) * (float)(1.0 - (double)alpha / 255);
                    if (type == 462)
                        return new Color(255, 255, 255, 128) * (float)(1.0 - (double)alpha / 255);
                    if (type == 352)
                        return new Color(250, 250, 250, alpha);
                    if (type == 435)
                    {
                        newColor = Color.Lerp(newColor, Color.White, 0.8f);
                        return new Color(newColor.R, newColor.G, newColor.B, 25);
                    }
                    if (type == 436)
                    {
                        newColor = Color.Lerp(newColor, Color.White, 0.8f);
                        return new Color(newColor.R, newColor.G, newColor.B, 25);
                    }
                    if (type == 409)
                        return new Color(250, 250, 250, 200);
                    if (type == 348 || type == 349)
                        return new Color(200, 200, 200, alpha);
                    if (type == 337)
                        return new Color(250, 250, 250, 150);
                    if (type >= 424 && type <= 426)
                    {
                        byte num4 = 150;
                        if (newColor.R < num4)
                            newColor.R = num4;
                        if (newColor.G < num4)
                            newColor.G = num4;
                        if (newColor.B < num4)
                            newColor.B = num4;
                        return new Color(newColor.R, newColor.G, newColor.B, 255);
                    }
                    if (type == 431 || type == 432)
                        return new Color(250, 250, 250, 255 - alpha);
                    if (type == 343 || type == 344)
                    {
                        float num4 = (float)(1.0 - (double)alpha / 255);
                        return new Color((int)(250.0 * num4), (int)(250.0 * num4), (int)(250.0 * num4), (int)(100.0 * num4));
                    }
                    if (type == 332)
                        return new Color(255, 255, 255, 255);
                    if (type == 329)
                        return new Color(200, 200, 200, 50);
                    if (type >= 326 && type <= 328 || type >= 400 && type <= 402)
                        return Color.Transparent;
                    if (type == 324 && frame >= 6 && frame <= 9)
                        return new Color(255, 255, 255, 255);
                    if (type == 16)
                        return new Color(255, 255, 255, 0);
                    if (type == 321)
                        return new Color(200, 200, 200, 0);
                    if (type == 76 || type == 77 || type == 78)
                        return new Color(255, 255, 255, 0);
                    if (type == 308)
                        return new Color(200, 200, 255, 125);
                    if (type == 263)
                    {
                        if (timeLeft < 255)
                            return new Color(255, 255, 255, (byte)timeLeft);
                        return new Color(255, 255, 255, 255);
                    }
                    if (type == 274)
                    {
                        if (timeLeft >= 85)
                            return new Color(255, 255, 255, 100);
                        byte num4 = (byte)(timeLeft * 3);
                        byte num5 = (byte)(100.0 * (num4 / 255));
                        return new Color(num4, num4, num4, num5);
                    }
                    if (type == 5)
                        return new Color(255, 255, 255, 0);
                    if (type == 300 || type == 301)
                        return new Color(250, 250, 250, 50);
                    if (type == 304)
                        return new Color(255 - alpha, 255 - alpha, 255 - alpha, (byte)((255 - alpha) / 3.0));
                    if (type == 116 || type == 132 || (type == 156 || type == 157) || (type == 157 || type == 173))
                    {
                        if (localAI[1] >= 15.0)
                            return new Color(255, 255, 255, alpha);
                        if (localAI[1] < 5.0)
                            return Color.Transparent;
                        int num4 = (int)((localAI[1] - 5.0) / 10.0 * 255);
                        return new Color(num4, num4, num4, num4);
                    }
                    if (type == 254)
                    {
                        if (timeLeft < 30)
                            alpha = (int)(255 - 255 * (double)(timeLeft / 30f));
                        return new Color(255 - alpha, 255 - alpha, 255 - alpha, 0);
                    }
                    if (type == 265 || type == 355)
                    {
                        if (alpha > 0)
                            return Color.Transparent;
                        return new Color(255, 255, 255, 0);
                    }
                    if (type == 270 && ai[0] >= 0.0)
                    {
                        if (alpha > 0)
                            return Color.Transparent;
                        return new Color(255, 255, 255, 200);
                    }
                    if (type == 257)
                    {
                        if (alpha > 200)
                            return Color.Transparent;
                        return new Color(255 - alpha, 255 - alpha, 255 - alpha, 0);
                    }
                    if (type == 259)
                    {
                        if (alpha > 200)
                            return Color.Transparent;
                        return new Color(255 - alpha, 255 - alpha, 255 - alpha, 0);
                    }
                    if (type >= 150 && type <= 152)
                        return new Color(255 - alpha, 255 - alpha, 255 - alpha, 255 - alpha);
                    if (type == 250)
                        return Color.Transparent;
                    if (type == 251)
                        return new Color(255 - alpha, 255 - alpha, 255 - alpha, 0);
                    if (type == 131)
                        return new Color(255 - alpha, 255 - alpha, 255 - alpha, 0);
                    if (type == 211)
                        return new Color(255, 255, 255, 0);
                    if (type == 229)
                        return new Color(255, 255, 255, 50);
                    if (type == 221)
                        return new Color(255, 255, 255, 200);
                    if (type == 20)
                    {
                        if (alpha <= 150)
                            return new Color(255, 255, 255, 0);
                        return new Color(0, 0, 0, 0);
                    }
                    if (type == 207)
                    {
                        num1 = 255 - alpha;
                        num2 = 255 - alpha;
                        num3 = 255 - alpha;
                    }
                    else
                    {
                        if (type == 242)
                        {
                            if (alpha < 140)
                                return new Color(255, 255, 255, 100);
                            return Color.Transparent;
                        }
                        if (type == 638)
                            return new Color(255, 255, 255, 100) * Opacity;
                        if (type == 209)
                        {
                            num1 = newColor.R - alpha;
                            num2 = newColor.G - alpha;
                            num3 = newColor.B - alpha / 2;
                        }
                        else
                        {
                            if (type == 130)
                                return new Color(255, 255, 255, 175);
                            if (type == 182)
                                return new Color(255, 255, 255, 200);
                            if (type == 226)
                            {
                                int num4 = 255;
                                int num5 = 255;
                                int num6 = 255;
                                float num7 = (float)(Main.mouseTextColor / 200.0 - 0.300000011920929);
                                int num8 = (int)(num4 * num7);
                                int num9 = (int)(num5 * num7);
                                int num10 = (int)(num6 * num7);
                                int r = num8 + 50;
                                if (r > 255)
                                    r = 255;
                                int g = num9 + 50;
                                if (g > 255)
                                    g = 255;
                                int b = num10 + 50;
                                if (b > 255)
                                    b = 255;
                                return new Color(r, g, b, 200);
                            }
                            if (type == 227)
                            {
                                int num4;
                                int num5 = num4 = 255;
                                int num6 = num4;
                                int num7 = num4;
                                float num8 = (float)(Main.mouseTextColor / 100.0 - 1.60000002384186);
                                int num9 = (int)(num7 * num8);
                                int num10 = (int)(num6 * num8);
                                int num11 = (int)(num5 * num8);
                                int a = (int)(100.0 * num8);
                                int r = num9 + 50;
                                if (r > 255)
                                    r = 255;
                                int g = num10 + 50;
                                if (g > 255)
                                    g = 255;
                                int b = num11 + 50;
                                if (b > 255)
                                    b = 255;
                                return new Color(r, g, b, a);
                            }
                            if (type == 114 || type == 115)
                            {
                                if (localAI[1] >= 15.0)
                                    return new Color(255, 255, 255, alpha);
                                if (localAI[1] < 5.0)
                                    return Color.Transparent;
                                int num4 = (int)((localAI[1] - 5.0) / 10.0 * 255);
                                return new Color(num4, num4, num4, num4);
                            }
                            if (type == 83 || type == 88 || (type == 89 || type == 90) || (type == 100 || type == 104 || type == 279) || type >= 283 && type <= 287)
                            {
                                if (alpha < 200)
                                    return new Color(255 - alpha, 255 - alpha, 255 - alpha, 0);
                                return Color.Transparent;
                            }
                            if (type == 34 || type == 35 || (type == 15 || type == 19) || (type == 44 || type == 45))
                                return Color.White;
                            if (type == 79)
                            {
                                num1 = Main.DiscoR;
                                num2 = Main.DiscoG;
                                num3 = Main.DiscoB;
                                return new Color();
                            }
                            if (type == 9 || type == 15 || (type == 34 || type == 50) || (type == 53 || type == 76 || (type == 77 || type == 78)) || (type == 92 || type == 91))
                            {
                                num1 = newColor.R - alpha / 3;
                                num2 = newColor.G - alpha / 3;
                                num3 = newColor.B - alpha / 3;
                            }
                            else
                            {
                                if (type == 18)
                                    return new Color(255, 255, 255, 50);
                                if (type == 16 || type == 44 || type == 45)
                                {
                                    num1 = newColor.R;
                                    num2 = newColor.G;
                                    num3 = newColor.B;
                                }
                                else if (type == 12 || type == 72 || (type == 86 || type == 87))
                                    return new Color(255, 255, 255, newColor.A - alpha);
                            }
                        }
                    }
                }
            }
            float num12 = (float)(255 - alpha) / 255;
            int r1 = (int)(newColor.R * num12);
            int g1 = (int)(newColor.G * num12);
            int b1 = (int)(newColor.B * num12);
            int a1 = newColor.A - alpha;
            if (a1 < 0)
                a1 = 0;
            if (a1 > 255)
                a1 = 255;
            return new Color(r1, g1, b1, a1);
        }

Usage Example

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);
                }
            }
        }
All Usage Examples Of Terraria.Projectile::GetAlpha