本文整理汇总了C#中Terraria.Projectile.Damage方法的典型用法代码示例。如果您正苦于以下问题:C# Projectile.Damage方法的具体用法?C# Projectile.Damage怎么用?C# Projectile.Damage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terraria.Projectile
的用法示例。
在下文中一共展示了Projectile.Damage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExplosionEffect
public static void ExplosionEffect(Projectile p)
{
Main.PlaySound(2, (int)p.position.X, (int)p.position.Y, 14);
for (int num500 = 0; num500 < 10; num500++)
{
Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 31, 0f, 0f, 100, default(Color), 1.5f);
}
for (int num501 = 0; num501 < 5; num501++)
{
int num502 = Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 6, 0f, 0f, 100, default(Color), 2.5f);
Main.dust[num502].noGravity = true;
Main.dust[num502].velocity *= 3f;
num502 = Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 6, 0f, 0f, 100, default(Color), 1.5f);
Main.dust[num502].velocity *= 2f;
}
int num503 = Gore.NewGore(new Vector2(p.position.X, p.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);
Main.gore[num503].velocity *= 0.4f;
Gore expr_105D2_cp_0 = Main.gore[num503];
expr_105D2_cp_0.velocity.X = expr_105D2_cp_0.velocity.X + (float)Main.rand.Next(-10, 11) * 0.1f;
Gore expr_10602_cp_0 = Main.gore[num503];
expr_10602_cp_0.velocity.Y = expr_10602_cp_0.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.1f;
num503 = Gore.NewGore(new Vector2(p.position.X, p.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);
Main.gore[num503].velocity *= 0.4f;
Gore expr_10696_cp_0 = Main.gore[num503];
expr_10696_cp_0.velocity.X = expr_10696_cp_0.velocity.X + (float)Main.rand.Next(-10, 11) * 0.1f;
Gore expr_106C6_cp_0 = Main.gore[num503];
expr_106C6_cp_0.velocity.Y = expr_106C6_cp_0.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.1f;
if (p.owner == Main.myPlayer)
{
p.penetrate = -1;
p.position.X = p.position.X + (float)(p.width / 2);
p.position.Y = p.position.Y + (float)(p.height / 2);
p.width = 48;
p.height = 48;
p.position.X = p.position.X - (float)(p.width / 2);
p.position.Y = p.position.Y - (float)(p.height / 2);
p.Damage();
}
}
示例2: ProjectileKilled
public static void ProjectileKilled(Projectile p)
{
if (p.type == 882)
{
UlterrariaProjectiles.ExplosionEffect(p);
}
if (p.type == 843)
{
Main.PlaySound(2, (int)p.position.X, (int)p.position.Y, 14);
for (int num500 = 0; num500 < 10; num500++)
{
Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 31, 0f, 0f, 100, default(Color), 1.5f);
}
for (int num501 = 0; num501 < 5; num501++)
{
int num502 = Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 6, 0f, 0f, 100, default(Color), 2.5f);
Main.dust[num502].noGravity = true;
Main.dust[num502].velocity *= 3f;
num502 = Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 6, 0f, 0f, 100, default(Color), 1.5f);
Main.dust[num502].velocity *= 2f;
}
int num503 = Gore.NewGore(new Vector2(p.position.X, p.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);
Main.gore[num503].velocity *= 0.4f;
Gore expr_105D2_cp_0 = Main.gore[num503];
expr_105D2_cp_0.velocity.X = expr_105D2_cp_0.velocity.X + (float)Main.rand.Next(-10, 11) * 0.1f;
Gore expr_10602_cp_0 = Main.gore[num503];
expr_10602_cp_0.velocity.Y = expr_10602_cp_0.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.1f;
num503 = Gore.NewGore(new Vector2(p.position.X, p.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);
Main.gore[num503].velocity *= 0.4f;
Gore expr_10696_cp_0 = Main.gore[num503];
expr_10696_cp_0.velocity.X = expr_10696_cp_0.velocity.X + (float)Main.rand.Next(-10, 11) * 0.1f;
Gore expr_106C6_cp_0 = Main.gore[num503];
expr_106C6_cp_0.velocity.Y = expr_106C6_cp_0.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.1f;
if (p.owner == Main.myPlayer)
{
p.penetrate = -1;
p.position.X = p.position.X + (float)(p.width / 2);
p.position.Y = p.position.Y + (float)(p.height / 2);
p.width = 48;
p.height = 48;
p.position.X = p.position.X - (float)(p.width / 2);
p.position.Y = p.position.Y - (float)(p.height / 2);
p.damage = 100;
p.Damage();
}
}
if (p.type == 852)
{
float angle = -45;
for (int i = 0; i < 8; i++)
{
angle += 45;
float rads = MathHelper.ToRadians(angle);
Vector2 vel = angle.ToRotationVector2();
vel *= 7f;
Projectile.NewProjectile(p.Center.X, p.Center.Y, vel.X, vel.Y, 24, (int)(p.damage * 0.8f), 0.2f);
}
for (int i = 0; i < 16; i++)
{
int d = Dust.NewDust(p.position, p.width, p.height, 41);
Main.dust[d].noGravity = true;
}
}
if (p.type == 849)
{
Main.PlaySound(2, (int)p.position.X, (int)p.position.Y, 14);
for (int num500 = 0; num500 < 10; num500++)
{
Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 31, 0f, 0f, 100, default(Color), 1.5f);
}
for (int num501 = 0; num501 < 5; num501++)
{
int num502 = Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 6, 0f, 0f, 100, default(Color), 2.5f);
Main.dust[num502].noGravity = true;
Main.dust[num502].velocity *= 3f;
num502 = Dust.NewDust(new Vector2(p.position.X, p.position.Y), p.width, p.height, 6, 0f, 0f, 100, default(Color), 1.5f);
Main.dust[num502].velocity *= 2f;
}
int num503 = Gore.NewGore(new Vector2(p.position.X, p.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);
Main.gore[num503].velocity *= 0.4f;
Gore expr_105D2_cp_0 = Main.gore[num503];
expr_105D2_cp_0.velocity.X = expr_105D2_cp_0.velocity.X + (float)Main.rand.Next(-10, 11) * 0.1f;
Gore expr_10602_cp_0 = Main.gore[num503];
expr_10602_cp_0.velocity.Y = expr_10602_cp_0.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.1f;
num503 = Gore.NewGore(new Vector2(p.position.X, p.position.Y), default(Vector2), Main.rand.Next(61, 64), 1f);
Main.gore[num503].velocity *= 0.4f;
Gore expr_10696_cp_0 = Main.gore[num503];
expr_10696_cp_0.velocity.X = expr_10696_cp_0.velocity.X + (float)Main.rand.Next(-10, 11) * 0.1f;
Gore expr_106C6_cp_0 = Main.gore[num503];
expr_106C6_cp_0.velocity.Y = expr_106C6_cp_0.velocity.Y + (float)Main.rand.Next(-10, 11) * 0.1f;
if (p.owner == Main.myPlayer)
{
p.penetrate = -1;
p.position.X = p.position.X + (float)(p.width / 2);
p.position.Y = p.position.Y + (float)(p.height / 2);
p.width = 48;
p.height = 48;
p.position.X = p.position.X - (float)(p.width / 2);
p.position.Y = p.position.Y - (float)(p.height / 2);
p.damage = 100;
//.........这里部分代码省略.........
示例3: ProjectileAiStyles
//.........这里部分代码省略.........
for (int n = 0; n < Main.npc.Length; n++)
{
if (!Main.npc[i].friendly)
{
Rectangle rect = new Rectangle((int)Main.npc[n].position.X, (int)Main.npc[n].position.Y, Main.npc[n].width, Main.npc[n].height);
if (Ulterraria.LineIntersectsRect(p1, p2, rect))
{
// half damage
Ulterraria.DoArcHit(n, 0.5f, p);
}
}
}
}
}
}
if (electrocute)
{
int windowSize = 512 + (p.soundDelay << 2);
float centerX = (float)(waterX << 4) + 8f;
float centerY = (float)(waterY << 4) + 8f;
Rectangle window = new Rectangle((int)centerX - (windowSize >> 1), (int)centerY - (windowSize >> 1), windowSize, windowSize);
for (int i = 0; i < Main.npc.Length; i++)
{
if (!Main.npc[i].friendly)
{
if (Main.npc[i].wet && !Main.npc[i].lavaWet)
{
if (window.Intersects(new Rectangle((int)Main.npc[i].position.X, (int)Main.npc[i].position.Y, Main.npc[i].width, Main.npc[i].height)))
{
if (Collision.CanHit(new Vector2(centerX, centerY), 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height))
{
bool crit = Main.rand.Next(1, 101) <= Main.player[p.owner].magicCrit;
int dmg = Main.DamageVar(((float)(15 + p.soundDelay + Main.rand.Next(p.timeLeft)) * (((float)windowSize - (Main.npc[i].position - new Vector2(centerX, centerY)).Length()) / (float)windowSize)));
Main.npc[i].StrikeNPC(dmg, 0f, 0, crit, true);
Main.npc[i].immune[p.owner] = Main.rand.Next(5, 10);
}
}
}
}
}
if (Main.myPlayer == Main.player[p.owner].whoAmI)
{
if (!Main.player[p.owner].immune && Main.player[p.owner].wet && !Main.player[p.owner].lavaWet)
{
if (window.Intersects(new Rectangle((int)Main.player[p.owner].position.X, (int)Main.player[p.owner].position.Y, Main.player[p.owner].width, Main.player[p.owner].height)))
{
if (Collision.CanHit(new Vector2(centerX, centerY), 1, 1, Main.player[p.owner].position, Main.player[p.owner].width, Main.player[p.owner].height))
{
bool crit = Main.rand.Next(1, 101) <= Main.player[p.owner].magicCrit;
int dmg = Main.DamageVar(((float)(15 + p.soundDelay + Main.rand.Next(p.timeLeft)) * (((float)windowSize - (Main.player[p.owner].position - new Vector2(centerX, centerY)).Length()) / (float)windowSize)));
bool kb = Main.player[p.owner].noKnockback;
Main.player[p.owner].noKnockback = true;
Main.player[p.owner].Hurt(dmg, Main.player[p.owner].direction, false, false, " electrocuted themself...", crit);
Main.player[p.owner].immuneTime = Main.rand.Next(5, 10);
Main.player[p.owner].noKnockback = kb;
}
}
}
}
}
p.penetrate = 20;