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


C# Attack.GetSTAB方法代码示例

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


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

示例1: calculateButton_Click

        /// <summary>
        /// Calculates the resistance or weakness of a given type combination to a move of a given type. With the advanced options set, 
        /// this will calculate the minimum and maximum possible damage values, then get a possible damage value.
        /// </summary>
        private void calculateButton_Click(object sender, EventArgs e)
        {
            var bonus = 1.0;

            var attack = new Attack() {
                AttackType = mvType.SelectedItem.ToString(),
                DefenderType1 = defType1.SelectedItem.ToString(),
                DefenderType2 = defType2.SelectedItem.ToString() == "(none)" ? null : defType2.SelectedItem.ToString()
            };

            if (advancedCheck.Checked)
            {
                attack.AttackValue = Convert.ToInt32(atkValBox.Value);
                attack.DefenceValue = Convert.ToInt32(defValBox.Value);
                attack.AttackerLevel = Convert.ToInt32(atkLvlBox.Value);
                attack.BaseDamage = Convert.ToInt32(mvPowBox.Value);
                attack.AttackerType1 = atkType1.SelectedItem.ToString();
                attack.AttackerType2 = atkType2.SelectedItem.ToString() == "(none)" ? null : atkType2.SelectedItem.ToString();
                attack.GetSTAB();
            }

            // Basic mode
            bonus = Pokemon.CalculateBonus(attack);

            if (bonus == 0)
                resultText.Text = "It doesn't affect the enemy Pokémon.";
            else if (bonus == 0.5 || bonus == 0.25)
                resultText.Text = "It's not very effective (x" + bonus + ")...";
            else if (bonus == 2 || bonus == 4)
                resultText.Text = "It's super effective (x" + bonus + ")!";
            else
                resultText.Text = "It hit.";

            // Advanced mode
            var range = new int[4];
            if (advancedCheck.Checked)
            {
                if (bonus == 0)
                {
                    damageText.Text = "No damage dealt - immune.";
                }
                else
                {
                    range = Calculator.calculateDamageRange(bonus, attack);

                    string damage = String.Empty;
                    if (range[0] == 1)
                        damage = "A critical hit! ";

                    damage += "Damage done between " + range[1] + " and " + range[3] + " (dealt: " + range[2] + ")";
                    damageText.Text = damage;
                }
            }
        }
开发者ID:KBKarma,项目名称:TypeCalculator,代码行数:58,代码来源:Form1.cs


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