コード例 #1
0
ファイル: ProjectileAttack.cs プロジェクト: w1r2p1/unitrpg
        public override SkillForecast ComputeForecast(ICombatant attacker, ICombatant defender)
        {
            var hitChance = new HitChance(attacker, defender);

            var critChance   = new CritChance(attacker, defender);
            var glanceChance = new GlanceChance(attacker, defender);

            var chances = new SkillChances {
                CritChance   = critChance.Value,
                HitChance    = hitChance.Value,
                GlanceChance = glanceChance.Value
            };

            var attackCount = new AttackCount(attacker, defender);

            var hit = new SkillHit {
                BaseDamage = DamageUtils.ComputeMeleeDamage(attacker, defender),
                HitCount   = attackCount.Value
            };

            return(new SkillForecast {
                Type = Type,
                Hit = hit,
                Chances = chances,
                Attacker = attacker,
                Defender = defender
            });
        }
コード例 #2
0
        /// <summary>
        /// Get the actual melee damage effect after glance, crit, hit and stuff are accounted for.
        /// </summary>
        /// <param name="baseDamage">The raw damage</param>
        /// <param name="chances">The chances for other things to modify it</param>
        /// <param name="randomizer">A randomizer</param>
        /// <returns></returns>
        public static WeaponHit GetFinalizedPhysicalDamage(int baseDamage, SkillChances chances, IRandomizer randomizer)
        {
            // MISS :<
            if (!RandomUtils.DidEventHappen(chances.HitChance, randomizer))
            {
                return(new Miss(MissReason.Miss));
            }

            // CRIT :)
            if (RandomUtils.DidEventHappen(chances.CritChance, randomizer))
            {
                return(new WeaponCrit(baseDamage));
            }


            // GLANCE :(
            if (RandomUtils.DidEventHappen(chances.GlanceChance, randomizer))
            {
                return(new WeaponGlance(baseDamage));
            }


            // BASE :|
            return(new WeaponHit(baseDamage));
        }
コード例 #3
0
        public override SkillForecast ComputeForecast(ICombatant attacker, ICombatant defender)
        {
            var attackCount = 1;
            var chances     = new SkillChances {
                CritChance   = 100,
                HitChance    = 100,
                GlanceChance = 0
            };

            var myKinesis = attacker.GetAttribute(Attribute.AttributeType.Special).Value;
            var hit       = new SkillHit {
                BaseDamage = myKinesis,
                HitCount   = attackCount
            };

            return(new SkillForecast {
                Type = Type,
                Hit = hit,
                Chances = chances,
                Attacker = attacker,
                Defender = defender
            });
        }