本文整理汇总了C#中Character.TakeDamage方法的典型用法代码示例。如果您正苦于以下问题:C# Character.TakeDamage方法的具体用法?C# Character.TakeDamage怎么用?C# Character.TakeDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Character
的用法示例。
在下文中一共展示了Character.TakeDamage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Use
public override void Use(Level level, Character actor, Character target)
{
//Console.WriteLine("{0} is attacking {1} for {2} damage!", actor.Name, target.Name, actor.AttackDamage);
var damage = (int)(actor.AttackDamage + level.rnd.Next(-2, 2));
target.TakeDamage(damage);
//actor.LastAction = string.Format("Attacked {0} for {1} damage!", target.Name, damage);
}
示例2: HandleCombat
private void HandleCombat(List<Elemental> elementals, Character character)
{
for (int i = 0; i < elementals.Count; i++)
{
if (Vector2.DistanceSquared(elementals[i].Position, character.Position)
<= Math.Pow((elementals[i].Width + animation.TargetWidth) / 2, 2))
{
elementals[i].TakeDamage(DamageToElemental(character, elementals[i]));
character.StackDamage((int)(Math.Max(1, (elementals[i].Attack + 4) * (elementals[i].Attack + 5) / (5 * character.TotalDefense))
* Element.GetMultiplier(elementals[i].CurrentElement, character.CurrentElement)));
}
}
character.TakeDamage();
}
示例3: PhysicalAttack
public void PhysicalAttack(Character attacker, Character defender, float hitChance, int skill, float attackRange, int minDamage, int maxDamage)
{
if (defender == null || Vector3.Distance(attacker.WorldObject.transform.position, defender.WorldObject.transform.position) > attackRange)
return;
if (UnityEngine.Random.value <= defender.DodgeBonus)
{
Debug.Log("Attak Dodged");
Miss(attacker);
return;
}
int roll = UnityEngine.Random.Range(1, 20);
int hitRoll = roll + skill;
int targetNum = (int)(20 * hitChance);
Debug.Log("Hit Roll = " + hitRoll.ToString() + " vs " + targetNum.ToString());
if (hitRoll < targetNum)
{
Debug.Log("Miss");
Miss(attacker);
return;
}
else
Hitt(defender);
int damage = UnityEngine.Random.Range(minDamage, maxDamage);
if (roll >= 20 - attacker.CritBonus)
damage = maxDamage * 2;
else
{
damage += hitRoll - targetNum;
float armorParam = 1;
if (defender.ArmorValue > 0)
armorParam = Mathf.Min(damage / defender.ArmorValue, 1.0f);
Debug.Log("Hit Damage = Raw " + damage.ToString() + " Param " + armorParam.ToString());
damage = (int)(damage * armorParam);
}
defender.TakeDamage(damage);
if (defender.Damage >= defender.HitPoints)
attacker.XP += defender.XP;
}
示例4: Attack
/// <summary>
/// Attack the given Character.</summary>
public virtual void Attack(Character enemy)
{
enemy.TakeDamage(Stats.Damage, this);
_timeUntilNextAttack = Time.time + Stats.AttackDuration;
}
示例5: SpellAttack
public void SpellAttack(Character attacker, Character defender, CharacterObject.HitType hitType, float attackRange, int damage)
{
if (defender == null || Vector3.Distance(attacker.WorldObject.transform.position, defender.WorldObject.transform.position) > attackRange)
return;
if (UnityEngine.Random.value <= defender.DodgeBonus)
return;
float armorParam = 1;
if (defender.ArmorValue > 0)
armorParam = Mathf.Min(damage / defender.ArmorValue, 1.0f);
damage = (int)(damage * armorParam);
defender.TakeDamage(damage, hitType);
if (defender.Damage >= defender.HitPoints)
attacker.XP += defender.XP;
}
示例6: InflictDamage
private void InflictDamage(Character subject, CharacterSkill skill)
{
float damage = skill.Damage;
if (damage < skill.Damage)
{
CombatLog.Add(subject.Name + " resisted " + (int)(skill.Damage - damage) + " damage.");
}
else if (damage > skill.Damage)
{
CombatLog.Add("Critical hit!");
}
subject.TakeDamage(damage);
textManager.AddText(new FloatingText("-" + damage, Constants.FloatingTextType.Normal, subject.Position - new Vector2(0, subject.BoundingBox.Height / 2)));
}
示例7: DoDamage
/// <summary>
/// Наносит урон указанной цели.
/// </summary>
/// <param name="target">персонаж-цель</param>
/// <param name="damage">наносимый урон</param>
public virtual void DoDamage(Character target, float damage)
{
target.TakeDamage(damage, this);
}