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


C# Unit.GetMaxHealth方法代码示例

本文整理汇总了C#中Unit.GetMaxHealth方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.GetMaxHealth方法的具体用法?C# Unit.GetMaxHealth怎么用?C# Unit.GetMaxHealth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Unit的用法示例。


在下文中一共展示了Unit.GetMaxHealth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetHealthText

 public void SetHealthText(Unit unit)
 {
     health_text.text = "Health: " + unit.GetHealth();
     health_bar.value = unit.GetHealth() / unit.GetMaxHealth();
 }
开发者ID:DeeCeptor,项目名称:Odyssey,代码行数:5,代码来源:PlayerInterface.cs

示例2: ShowEstimatedDamagePanel

    public void ShowEstimatedDamagePanel(Unit target)
    {
        battle_prediction_panel.SetActive(true);

        // Set enemy HP, out of their max HP
        enemy_hp_slider.value = target.GetHealth() / target.GetMaxHealth();

        // Estimate the amount of damage the selected unit will do to the target
        float damage = target.CalculateDamage(selected_unit, selected_unit.location);
        estimated_damage_slider.value = damage / target.GetMaxHealth();
        estimated_damage_text.text = "Estimated damage: " + (int)damage;
    }
开发者ID:DeeCeptor,项目名称:Odyssey,代码行数:12,代码来源:PlayerInterface.cs

示例3: CalculateDamage

    // Returns how much damage the attacker would do to this unit
    public float CalculateDamage(Unit attacker, Hex from)
    {
        // Have the damage be the percentage of the health remaining of this unit. Weak units don't do as much damage
        float raw_normal_damage = attacker.GetDamage() * (attacker.GetHealth() / attacker.GetMaxHealth());
        float raw_piercing_damage = attacker.GetPiercingDamage() * (attacker.GetHealth() / attacker.GetMaxHealth());

        // Get the right type of defence to use. Ranged defence from ranged units
        float defence = 0;
        if (attacker.is_ranged_unit)
        {
            defence = this.GetRangedDefence();
        }
        else
            defence = this.GetDefence();

        // Modify the damage by the defence percentage. 10% defence means 90% of the damage is inflicted.
        float modified_normal_damage = raw_normal_damage - (raw_normal_damage * defence);

        // Piercing damage is not affected by the enemy's defense.
        float damage = modified_normal_damage + raw_piercing_damage;

        // Apply bonuses to damage that's been modified by the enemies' defence
        // Apply bonus against specific type of unit
        if (this.unit_type == Unit_Types.Melee)
            damage += damage * attacker.GetMeleeBonus();
        else if (this.unit_type == Unit_Types.Cavalry)
            damage += damage * attacker.GetMeleeBonus();
        else if (this.unit_type == Unit_Types.Ranged)
            damage += damage * attacker.GetMeleeBonus();

        // If the attacker is flanking, apply a flanking bonus
        if (!IsFacing(from))
        {
            damage += damage * attacker.GetFlankingBonus();
        }

        return damage;
    }
开发者ID:DeeCeptor,项目名称:Odyssey,代码行数:39,代码来源:Unit.cs


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