Terraria.Player.GetImmuneAlpha C# (CSharp) Method

GetImmuneAlpha() public method

public GetImmuneAlpha ( Color newColor, float alphaReduction ) : Color
newColor Color
alphaReduction float
return Color
        public Color GetImmuneAlpha(Color newColor, float alphaReduction)
        {
            float scale = (float)((int)byte.MaxValue - this.immuneAlpha) / (float)byte.MaxValue;
            if ((double)alphaReduction > 0.0)
                scale *= 1f - alphaReduction;
            if (this.immuneAlpha > 125)
                return Color.Transparent;
            return Color.Multiply(newColor, scale);
        }

Usage Example

Example #1
0
 protected void DrawGhost(Player drawPlayer)
 {
     SpriteEffects none = SpriteEffects.None;
     if (drawPlayer.direction == 1)
     {
         none = SpriteEffects.None;
     }
     else
     {
         none = SpriteEffects.FlipHorizontally;
     }
     Color immuneAlpha = drawPlayer.GetImmuneAlpha(Lighting.GetColor(((int)(drawPlayer.position.X + (drawPlayer.width * 0.5))) / 0x10, ((int)(drawPlayer.position.Y + (drawPlayer.height * 0.5))) / 0x10, new Color((mouseTextColor / 2) + 100, (mouseTextColor / 2) + 100, (mouseTextColor / 2) + 100, (mouseTextColor / 2) + 100)));
     Rectangle rectangle = new Rectangle(0, (ghostTexture.Height / 4) * drawPlayer.ghostFrame, ghostTexture.Width, ghostTexture.Height / 4);
     Vector2 origin = new Vector2(rectangle.Width * 0.5f, rectangle.Height * 0.5f);
     this.spriteBatch.Draw(ghostTexture, new Vector2((float)(((int)(drawPlayer.position.X - screenPosition.X)) + (rectangle.Width / 2)), (float)(((int)(drawPlayer.position.Y - screenPosition.Y)) + (rectangle.Height / 2))), new Rectangle?(rectangle), immuneAlpha, 0f, origin, (float)1f, none, 0f);
 }
All Usage Examples Of Terraria.Player::GetImmuneAlpha
Player