本文整理匯總了C#中Terraria.Player.Hurt方法的典型用法代碼示例。如果您正苦於以下問題:C# Player.Hurt方法的具體用法?C# Player.Hurt怎麽用?C# Player.Hurt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Terraria.Player
的用法示例。
在下文中一共展示了Player.Hurt方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CanUse
public bool CanUse(Player p, int ind)
{
if(cost>p.statLife) return false;
float defMod = (p.statDefense/2f);
int dmg = (int)((cost) + defMod);
p.Hurt(dmg, 0);
return true;
}
示例2: UpdateAccessory
public override void UpdateAccessory(Player player)
{
player.lavaMax += 2; // 2 seconds lava invincibility.
if (player.HasBuff(BuffID.CursedInferno) >= 0 || player.lavaWet)
player.statDefense += 4;
player.buffImmune[BuffID.OnFire] = true;
if (player.wet)
{
player.Hurt(2, 0); // If the player is in water, deal damage.
}
Lighting.AddLight(player.position, 0.8F, 0.6F, 0); // Add a average, red light to the player.
}
示例3: UpdateAccessory
public override void UpdateAccessory(Player player)
{
// If the player has either of the buffs, add 1 defence.
if (player.HasBuff(BuffID.OnFire) >= 0 || player.HasBuff(BuffID.CursedInferno) >= 0)
player.statDefense += 1;
player.lavaMax += 30; // Half a second lava immunity
if (player.wet)
{
player.Hurt(1, 0); // If the player is in water, deal damage.
}
Lighting.AddLight(player.position, 0.5F, 0.1F, 0); // Add a small, red light to the player.
}
示例4: UseDrill
public void UseDrill(Player mountedPlayer)
{
if (this._type != 8 || !this._abilityActive)
{
return;
}
Mount.DrillMountData drillMountData = (Mount.DrillMountData)this._mountSpecificData;
if (drillMountData.beamCooldown == 0)
{
int i = 0;
while (i < drillMountData.beams.Length)
{
Mount.DrillBeam drillBeam = drillMountData.beams[i];
if (drillBeam.cooldown == 0)
{
Point16 point = this.DrillSmartCursor(mountedPlayer, drillMountData);
if (point != Point16.NegativeOne)
{
drillBeam.curTileTarget = point;
int pickPower = Mount.drillPickPower;
bool flag = mountedPlayer.whoAmI == Main.myPlayer;
if (flag)
{
bool flag2 = true;
if (WorldGen.InWorld((int)point.X, (int)point.Y, 0) && Main.tile[(int)point.X, (int)point.Y] != null && Main.tile[(int)point.X, (int)point.Y].type == 26 && !Main.hardMode)
{
flag2 = false;
mountedPlayer.Hurt(mountedPlayer.statLife / 2, -mountedPlayer.direction, false, false, Lang.deathMsg(-1, -1, -1, 4), false, -1);
}
if (flag2)
{
mountedPlayer.PickTile((int)point.X, (int)point.Y, pickPower);
}
}
Vector2 vector = new Vector2((float)(point.X << 4) + 8f, (float)(point.Y << 4) + 8f);
Vector2 v = vector - mountedPlayer.Center;
float num = v.ToRotation();
for (int j = 0; j < 2; j++)
{
float num2 = num + ((Main.rand.Next(2) == 1) ? -1f : 1f) * 1.57079637f;
float num3 = (float)Main.rand.NextDouble() * 2f + 2f;
Vector2 vector2 = new Vector2((float)Math.Cos((double)num2) * num3, (float)Math.Sin((double)num2) * num3);
int num4 = Dust.NewDust(vector, 0, 0, 230, vector2.X, vector2.Y, 0, default(Color), 1f);
Main.dust[num4].noGravity = true;
Main.dust[num4].customData = mountedPlayer;
}
if (flag)
{
Tile.SmoothSlope((int)point.X, (int)point.Y, true);
}
drillBeam.cooldown = Mount.drillPickTime;
break;
}
break;
}
else
{
i++;
}
}
drillMountData.beamCooldown = Mount.drillBeamCooldownMax;
}
}
示例5: OnHitPlayer
public override void OnHitPlayer(Player target, int damage, bool crit)
{
target.Hurt(5, projectile.direction);
}
示例6: TileHurtPlayer
/// <summary>
/// Hurt a player when he/she touches a tile.
/// </summary>
/// <param name="p">The player who touches or doesn't touch the tile.</param>
/// <param name="tileTypes">The types of the tiles to check.</param>
/// <param name="damage">The damage to inflict to the player.</param>
/// <param name="canHurt">A function used to check when to hurt the player.</param>
/// <param name="deathText">The text do display when the player dies from the damage.</param>
/// <param name="r">The radius.</param>
public static void TileHurtPlayer(Player p, IEnumerable<int> tileTypes, int damage, Func<bool> canHurt = null, string deathText = " got slain...", int r = 0)
{
if (p.immune)
return;
bool hurt = TouchesTile(p, r, tileTypes);
if (canHurt != null)
hurt &= canHurt();
if (hurt)
p.Hurt(damage + (p.statDefense / 2), 0, false, false, deathText);
}