本文整理汇总了C#中Damage类的典型用法代码示例。如果您正苦于以下问题:C# Damage类的具体用法?C# Damage怎么用?C# Damage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Damage类属于命名空间,在下文中一共展示了Damage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TakeDamage
public void TakeDamage(Damage damage)
{
if (!enabled)
return;
OnDamage (damage);
OnDamageAction.Invoke ();
}
示例2: CalculateDamage
/// <summary>
/// 伤害核心计算公式
/// </summary>
/// <param name="monster">怪物</param>
/// <param name="skillDamage">已经过法强加成的伤害类</param>
/// <returns>计算抗性后的伤害值</returns>
public static float CalculateDamage(Monster monster, Damage.SkillDamage skillDamage)
{
///当前版本不存在神圣伤害or物理伤害
if (!monster.armorComponent)
{
return skillDamage.GetTotalDamage();
}
float[] elementDefenceList = monster.armorComponent.GetElementDefenceList();
float sum = 0;
for (int i = 0; i < Elements.ELEMENT_NUMBER; i++)
{
///当前版本不存在将伤害小于0的效果
if (skillDamage.elementsDamage[i] < 0)
{
skillDamage.elementsDamage[i] = 0;
}
///当前版本不存在将伤害转化成治疗的效果
float p = 1 - elementDefenceList[i] / 100;
if (p < 0)
{
p = 0;
}
sum += skillDamage.elementsDamage[i] * p;
}
///FIXME 物理组件存在物理抗性,物理抗性还需计算
return sum + skillDamage.physicalDamage;
}
示例3: BeginAttack
public virtual void BeginAttack(Damage damageToDeal, Fighter attacker)
{
weaponUser = attacker;
attackCast.OnHit += OnWeaponHit;
damageOut = damageToDeal;
attackCast.Begin ();
}
示例4: OnTakeDamage
public void OnTakeDamage(Damage d)
{
shieldHealth -= d.damage;
if (shieldHealth <= 0) {
Destroy (gameObject);
}
}
示例5: AddNewDamage
public ActionResult AddNewDamage(Damage damage)
{
var context = new RiskSystemEntities();
context.Damages.Add(damage);
context.SaveChanges();
return RedirectToAction("Damages");
}
示例6: Pop
public void Pop(Damage damage)
{
var message = _messagePrefab.Instantiate();
message.transform.SetParent(transform, false);
message.transform.localPosition = Vector3.zero;
message.Show(damage);
}
示例7: TakeDamage
public void TakeDamage(Damage damage)
{
// we hit a bullet / a bullet hit us, both go away
AudioSource.PlayClipAtPoint(rockGotHit, Camera.main.transform.position);
Instantiate(rockHitEffect, transform.position, transform.rotation);
Destroy(gameObject);
}
示例8: Attack
public virtual bool Attack(Character target)
{
Damage damage = new Damage(this, target, attack * (1 - target.defence / 100));
Damage.AddDamage(damage);
//target.LoseHp(attack * (1 - target.defence / 100));
return true;
}
示例9: OnTriggerStay
void OnTriggerStay(Collider col)
{
GameObject target;
if (col.attachedRigidbody != null)
{
target = col.attachedRigidbody.gameObject;
}
else
{
target = col.gameObject;
}
if (!targets.Contains(target))
{
targets.Add(target);
float dist = (target.transform.position - transform.position).magnitude;
Damage dam = new Damage();
dam.amount = damage * radius / (dist + 1);
dam.source = this;
dam.targetCollider = col;
DamageReceiver receiver = target.GetComponent<DamageReceiver>();
if (receiver != null)
{
receiver.TakeDamage(dam);
}
if (target.rigidbody != null)
{
target.rigidbody.AddExplosionForce(damage * 100, transform.position, radius);
}
}
}
示例10: takeDamage
public virtual void takeDamage(Damage d)
{
hp -= d.value;
if (hp <= 0)
this.diedFrom (d);
}
示例11: OnTriggerEnter
void OnTriggerEnter(Collider col)
{
if (!destroyed)
{
destroyed = true;
GameObject target;
if (col.attachedRigidbody != null)
{
target = col.attachedRigidbody.gameObject;
}
else
{
target = col.gameObject;
}
Damage dam = new Damage();
dam.amount = damage;
dam.source = this;
dam.targetCollider = col;
DamageReceiver receiver = target.GetComponent<DamageReceiver>();
if (receiver != null)
{
receiver.TakeDamage(dam);
}
Destroy(gameObject);
}
}
示例12: Update
void Update()
{
if (isFiring)
{
Ray ray = new Ray(startPos.position, startPos.forward);
RaycastHit hit;
Vector3 hitPos;
if (Physics.Raycast(ray, out hit, range))
{
hitPos = hit.point;
GameObject target;
if (hit.collider.attachedRigidbody != null) target = hit.collider.attachedRigidbody.gameObject;
else target = hit.collider.gameObject;
DamageReceiver receiver = target.GetComponent<DamageReceiver>();
if (receiver != null)
{
Damage dam = new Damage();
dam.amount = Time.deltaTime * damage;
dam.targetCollider = hit.collider;
dam.source = this;
receiver.TakeDamage(dam);
}
}
else
{
hitPos = startPos.position + startPos.forward * range;
}
line.SetPosition(0, startPos.position);
line.SetPosition(1, hitPos);
}
}
示例13: Damage
// Copy constructor
public Damage(Damage copyFrom)
{
HitLocation = copyFrom.HitLocation;
Amount = copyFrom.Amount;
Attacker = copyFrom.Attacker;
Attack = copyFrom.Attack;
}
示例14: RecieveDamage
public virtual bool RecieveDamage(Damage dmg)
{
_health -= dmg.damage;
if ( _health < 0 )
return true;
return false;
}
示例15: Ability
public Ability()
{
Name = "!!! Unnamed Ability !!!";
Description = "";
Animations = new List<GraphicsEffectDefinition>();
CastingAnimations = new List<GraphicsEffectDefinition>();
ImpactAnimations = new List<GraphicsEffectDefinition>();
Damage = new Damage();
Healing = new Damage();
DamageType = DamageTypes.SingleTarget;
TargettingType = TargettingTypes.Hostile;
Cooldown = new Cooldown(0f);
Range = new Range(20f);
Area = 1f;
ThreatModifier = 1f;
AurasApplied = new List<Aura>();
Duration = 1;
CanMiss = true;
CanBeDodged = true;
CanCrit = true;
CanBeBlocked = true;
}