示例#1
0
文件: Goblin.cs 项目: ganzmn/dotnet
        public void Attack(Goblin target)
        {
            int damage = GoblinWeapon.GenerateDamage(target);

            //int damage = (int)(_rng.Next(5) * (1.0 - target.GoblinArmor.PercentReduction));
            Console.WriteLine($"{Name} attacks {target.Name} for {damage} damage!");

            target.Hit(damage);
        }
示例#2
0
文件: Goblin.cs 项目: ganzmn/dotnet
        // for when this instance gets hit
        public void Hit(int damage)
        {
            if (RNG.NextDouble() < DodgeChance)
            {
                //dodged
                Console.WriteLine($"{ Name} dodged!");
            }
            else if (RNG.NextDouble() < CritHitChance)
            {
                damage      = GoblinWeapon.CritDamage();
                _hitPoints -= damage;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"Hit is critical, {Name} receives {damage} damage. They have {_hitPoints} health.");
                Console.ForegroundColor = ConsoleColor.White;
                if (_hitPoints <= 0)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine($"{Name} has died!");
                    IsDead = true;
                }
            }
            else
            {
                // damage = GoblinArmor.AdjustDamage(damage);
                // deduct damage
                _hitPoints -= damage;
                Console.WriteLine($"{Name} receives {damage} damage. They have {_hitPoints} health.");

                // should we die?
                if (_hitPoints <= 0)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine($"{Name} has died!");
                    IsDead = true;
                }
            }
        }