Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ NewText() [2/2]

static int Terraria.CombatText.NewText ( Rectangle location,
Color color,
string text,
bool dramatic = false,
bool dot = false )
inlinestatic

Definition at line 59 of file CombatText.cs.

60 {
61 if (Main.netMode == 2)
62 {
63 return 100;
64 }
65 for (int i = 0; i < 100; i++)
66 {
67 if (Main.combatText[i].active)
68 {
69 continue;
70 }
71 int num = 0;
72 if (dramatic)
73 {
74 num = 1;
75 }
76 Vector2 vector = FontAssets.CombatText[num].Value.MeasureString(text);
77 Main.combatText[i].alpha = 1f;
78 Main.combatText[i].alphaDir = -1;
79 Main.combatText[i].active = true;
80 Main.combatText[i].scale = 0f;
81 Main.combatText[i].rotation = 0f;
82 Main.combatText[i].position.X = (float)location.X + (float)location.Width * 0.5f - vector.X * 0.5f;
83 Main.combatText[i].position.Y = (float)location.Y + (float)location.Height * 0.25f - vector.Y * 0.5f;
84 Main.combatText[i].position.X += Main.rand.Next(-(int)((double)location.Width * 0.5), (int)((double)location.Width * 0.5) + 1);
85 Main.combatText[i].position.Y += Main.rand.Next(-(int)((double)location.Height * 0.5), (int)((double)location.Height * 0.5) + 1);
86 Main.combatText[i].color = color;
87 Main.combatText[i].text = text;
88 Main.combatText[i].velocity.Y = -7f;
89 if (Main.player[Main.myPlayer].gravDir == -1f)
90 {
91 Main.combatText[i].velocity.Y *= -1f;
92 Main.combatText[i].position.Y = (float)location.Y + (float)location.Height * 0.75f + vector.Y * 0.5f;
93 }
94 Main.combatText[i].lifeTime = 60;
95 Main.combatText[i].crit = dramatic;
96 Main.combatText[i].dot = dot;
97 if (dramatic)
98 {
99 Main.combatText[i].text = text;
100 Main.combatText[i].lifeTime *= 2;
101 Main.combatText[i].velocity.Y *= 2f;
102 Main.combatText[i].velocity.X = (float)Main.rand.Next(-25, 26) * 0.05f;
103 Main.combatText[i].rotation = (float)(Main.combatText[i].lifeTime / 2) * 0.002f;
104 if (Main.combatText[i].velocity.X < 0f)
105 {
106 Main.combatText[i].rotation *= -1f;
107 }
108 }
109 if (dot)
110 {
111 Main.combatText[i].velocity.Y = -4f;
112 Main.combatText[i].lifeTime = 40;
113 }
114 return i;
115 }
116 return 100;
117 }
static Asset< DynamicSpriteFont >[] CombatText
Definition FontAssets.cs:14

References Terraria.CombatText.color, Terraria.GameContent.FontAssets.CombatText, Terraria.Main.combatText, Terraria.CombatText.dot, Microsoft.Xna.Framework.Rectangle.Height, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Main.player, Terraria.Main.rand, Terraria.CombatText.text, Microsoft.Xna.Framework.Rectangle.Width, Microsoft.Xna.Framework.Rectangle.X, and Microsoft.Xna.Framework.Rectangle.Y.