当前位置: 首页>>代码示例>>C#>>正文


C# Damage类代码示例

本文整理汇总了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 ();
 }
开发者ID:mofr,项目名称:FimbulWinter,代码行数:7,代码来源:Damageable.cs

示例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;
 }
开发者ID:shuitian,项目名称:LonelyCity,代码行数:33,代码来源:Damage.cs

示例3: BeginAttack

 public virtual void BeginAttack(Damage damageToDeal, Fighter attacker)
 {
     weaponUser = attacker;
     attackCast.OnHit += OnWeaponHit;
     damageOut = damageToDeal;
     attackCast.Begin ();
 }
开发者ID:redbluegames,项目名称:ness,代码行数:7,代码来源:Weapon.cs

示例4: OnTakeDamage

 public void OnTakeDamage(Damage d)
 {
     shieldHealth -= d.damage;
     if (shieldHealth <= 0) {
         Destroy (gameObject);
     }
 }
开发者ID:Lomztein,项目名称:Microsquad,代码行数:7,代码来源:ShieldGenerator.cs

示例5: AddNewDamage

 public ActionResult AddNewDamage(Damage damage)
 {
     var context = new RiskSystemEntities();
     context.Damages.Add(damage);
     context.SaveChanges();
     return RedirectToAction("Damages");
 }
开发者ID:dave93b,项目名称:MKM,代码行数:7,代码来源:HomeController.cs

示例6: Pop

 public void Pop(Damage damage)
 {
     var message = _messagePrefab.Instantiate();
     message.transform.SetParent(transform, false);
     message.transform.localPosition = Vector3.zero;
     message.Show(damage);
 }
开发者ID:choihb,项目名称:snugdc-project-sprpg,代码行数:7,代码来源:HudDamagePoper.cs

示例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);
 }
开发者ID:Beanalby,项目名称:1GameAMonth13,代码行数:7,代码来源:Rock.cs

示例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;
 }
开发者ID:shuitian,项目名称:pokemon_rpg,代码行数:7,代码来源:Character.cs

示例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);
            }
        }
    }
开发者ID:GGJ204-EBUG,项目名称:EnemyBuildingGame,代码行数:34,代码来源:Explosion.cs

示例10: takeDamage

	public virtual void takeDamage(Damage d)
	{
		hp -= d.value;

		if (hp <= 0)
			this.diedFrom (d);
	}
开发者ID:fuchs-,项目名称:MBA,代码行数:7,代码来源:Entity.cs

示例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);
        }
    }
开发者ID:GGJ204-EBUG,项目名称:EnemyBuildingGame,代码行数:29,代码来源:Bullet.cs

示例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);
        }
    }
开发者ID:GGJ204-EBUG,项目名称:EnemyBuildingGame,代码行数:33,代码来源:LaserCannon.cs

示例13: Damage

 // Copy constructor
 public Damage(Damage copyFrom)
 {
     HitLocation = copyFrom.HitLocation;
     Amount = copyFrom.Amount;
     Attacker = copyFrom.Attacker;
     Attack = copyFrom.Attack;
 }
开发者ID:redbluegames,项目名称:ness,代码行数:8,代码来源:Damage.cs

示例14: RecieveDamage

 public virtual bool RecieveDamage(Damage dmg)
 {
     _health -= dmg.damage;
     if ( _health < 0 )
         return true;
     return false;
 }
开发者ID:AtwoodDeng,项目名称:miniRTS,代码行数:7,代码来源:RobotHealth.cs

示例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;
        }
开发者ID:myko,项目名称:Eternia,代码行数:25,代码来源:Ability.cs


注:本文中的Damage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。