Terraria.CombatText.NewText C# (CSharp) Method

NewText() public static method

public static NewText ( Rectangle location, Color color, string text, bool dramatic = false, bool dot = false ) : int
location Microsoft.Xna.Framework.Rectangle
color Color
text string
dramatic bool
dot bool
return int
        public static int NewText(Rectangle location, Color color, string text, bool dramatic = false, bool dot = false)
        {
            if (Main.netMode == 2)
                return 100;
            for (int index1 = 0; index1 < 100; ++index1)
            {
                if (!Main.combatText[index1].active)
                {
                    int index2 = 0;
                    if (dramatic)
                        index2 = 1;
                    Vector2 vector2 = Main.fontCombatText[index2].MeasureString(text);
                    Main.combatText[index1].alpha = 1f;
                    Main.combatText[index1].alphaDir = -1;
                    Main.combatText[index1].active = true;
                    Main.combatText[index1].scale = 0.0f;
                    Main.combatText[index1].rotation = 0.0f;
                    Main.combatText[index1].position.X = (float)(location.X + location.Width * 0.5 - vector2.X * 0.5);
                    Main.combatText[index1].position.Y = (float)(location.Y + location.Height * 0.25 - vector2.Y * 0.5);
                    Main.combatText[index1].position.X += Main.rand.Next(-(int)(location.Width * 0.5), (int)(location.Width * 0.5) + 1);
                    Main.combatText[index1].position.Y += Main.rand.Next(-(int)(location.Height * 0.5), (int)(location.Height * 0.5) + 1);
                    Main.combatText[index1].color = color;
                    Main.combatText[index1].text = text;
                    Main.combatText[index1].velocity.Y = -7f;
                    if (Main.player[Main.myPlayer].gravDir == -1.0)
                    {
                        Main.combatText[index1].velocity.Y *= -1f;
                        Main.combatText[index1].position.Y = (float)(location.Y + location.Height * 0.75 + vector2.Y * 0.5);
                    }
                    Main.combatText[index1].lifeTime = 60;
                    Main.combatText[index1].crit = dramatic;
                    Main.combatText[index1].dot = dot;
                    if (dramatic)
                    {
                        Main.combatText[index1].text = text;
                        Main.combatText[index1].lifeTime *= 2;
                        Main.combatText[index1].velocity.Y *= 2f;
                        Main.combatText[index1].velocity.X = Main.rand.Next(-25, 26) * 0.05f;
                        Main.combatText[index1].rotation = Main.combatText[index1].lifeTime / 2 * (1.0f / 500.0f);
                        if (Main.combatText[index1].velocity.X < 0.0)
                            Main.combatText[index1].rotation *= -1f;
                    }
                    if (dot)
                    {
                        Main.combatText[index1].velocity.Y = -4f;
                        Main.combatText[index1].lifeTime = 40;
                    }
                    return index1;
                }
            }
            return 100;
        }

Usage Example

コード例 #1
0
 public static int NewText(Rectangle location, Color color, int amount, bool dramatic = false, bool dot = false)
 {
     return(CombatText.NewText(location, color, amount.ToString(), dramatic, dot));
 }