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


C# Character.TakeDamage方法代码示例

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

示例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();
 }
开发者ID:zanagi,项目名称:MelSpaceHunter,代码行数:14,代码来源:Form.cs

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

示例4: Attack

 /// <summary>
 /// Attack the given Character.</summary>
 public virtual void Attack(Character enemy)
 {
     enemy.TakeDamage(Stats.Damage, this);
     _timeUntilNextAttack = Time.time + Stats.AttackDuration;
 }
开发者ID:PaulSchweizer,项目名称:GameDev,代码行数:7,代码来源:Character.cs

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

示例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)));
        }
开发者ID:Raunio,项目名称:Bearventure,代码行数:17,代码来源:CombatManager.cs

示例7: DoDamage

 /// <summary>
 /// Наносит урон указанной цели.
 /// </summary>
 /// <param name="target">персонаж-цель</param>
 /// <param name="damage">наносимый урон</param>
 public virtual void DoDamage(Character target, float damage)
 {
     target.TakeDamage(damage, this);
 }
开发者ID:ai-ry,项目名称:TopDownRPG,代码行数:9,代码来源:GameUnit.cs


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