예제 #1
0
        public void Attack(Character victim)
        {
            float successPercent = RPGMath.Clamp(Stats.dexerity / victim.Stats.dexerity, 0.2f, 0.8f);

            successPercent += (Stats.accuracy / 100f);

            bool success = RPGRandom.NextFloat(0f, 1f) > (1.0f - successPercent);

            float damageMultiplier = RPGRandom.NextFloat(0.8f, 1.0f);
            float reducedPercent   = 1.0f - (RPGMath.Clamp(victim.Stats.armorClass, 0f, 80f) / 100f);

            float damage = success ? (Stats.strength * damageMultiplier * reducedPercent) : 0;

            if (success)
            {
                victim.ModifyHealth(-damage);
            }

            if (OnAttack != null)
            {
                OnAttack.Invoke(this, new OnAttackEventArgs(damage, success, this, victim));
            }
        }
예제 #2
0
 public Monster(string name, char symbol, Vector2 position, Stats stats) : base(name, symbol, position, stats)
 {
     Reward    = new Reward(RPGRandom.NextFloat(30, 80), RPGRandom.NextInt(0, 2));
     OnAttack += Monster_OnAttack;
 }