當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。