Example #1
0
        /// 游戏角色的被攻击行为
        /// </summary>
        public override void Bcombat(GameRoles BRole)
        {
            //声明一个变量保存玩家对怪物的伤害值
            int attackcound;

            //判断是否使用了技能,如果使用了进入
            if (Program.Bskill)
            {
                //伤害值等于技能的返回值
                attackcound = jineng();
                //怪物被攻击后剩余血量=原有血量-攻击伤害+防御
                int HPsheng2 = Hp - attackcound + Defense;
                //怪物血量等于怪物剩余血量
                Hp = HPsheng2;
                //如果怪物剩余血量小于或者等于0,让血量等于零
                if (HPsheng2 <= 0)
                {
                    HPsheng2 = 0;
                }
                Console.WriteLine("\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
                Thread.Sleep(400);
                //输出怪物受到攻击后的属性
                Console.WriteLine("\n\t玩家:" + Program._PlayerRoles.Name + "对怪物:" + Name + "进行攻击,造成了:" + attackcound + "点伤害     \n\n\t怪物" + Name + ":的剩余HP为:" + HPsheng2);
                //让是否选择了技能为假,下次如果没选择使用技能,自动进入没有技能
                Program.Bskill = false;
            }
            //如果没有使用技能
            else
            {
                //伤害值等于玩家攻击值
                attackcound = BRole.Attack;
                //如果攻击值小于防御值,让攻击值等于防御值,也就是攻击等于0
                if (attackcound <= Defense)
                {
                    attackcound             = Defense;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n\t您的攻击值太低了,对方没有遭到伤害");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                //怪物剩余血量
                int HPsheng = Hp - attackcound + Defense;
                //怪物血量同步
                Hp = HPsheng;
                //如果剩余血量小于0,让血量等于0
                if (HPsheng <= 0)
                {
                    HPsheng = 0;
                }
                Console.WriteLine("\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
                Thread.Sleep(400);
                //输出信息
                Console.WriteLine("\n\t玩家:" + Program._PlayerRoles.Name + "对怪物:" + Name + "进行攻击,造成了:" + attackcound + "点伤害    \n\n\t" + Name + " :的剩余HP为:" + HPsheng);
            }
        }
Example #2
0
        /// <summary>
        /// 玩家被攻击行为
        /// </summary>
        public override void Bcombat(GameRoles BRole)
        {
            //伤害值等于这个怪物伤害
            int attackcound = BRole.Attack;

            //判断玩家角色
            if (Program.Enum_GamePlayerRoles == Enum_GameRoles.Enum_Warrior)
            {
                //如果怪物攻击小于玩家的防御
                if (attackcound < Program._RolesWarrior.Defense)
                {
                    //让怪物攻击等于玩家防御,防止玩家血量增加
                    attackcound             = Program._RolesWarrior.Defense;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n\t怪物的攻击值太低了,你没有遭到伤害");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                //玩家现有血量
                Program._RolesWarrior.Hp = Program._RolesWarrior.Hp - attackcound + Program._RolesWarrior.Defense;
                //如果玩家血量小于0
                if (Program._RolesWarrior.Hp <= 0)
                {
                    Program._RolesWarrior.Hp = 0;
                }
                Console.WriteLine("\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
                Thread.Sleep(400);
                Console.WriteLine("\n\t怪物:" + BRole.Name + "  对玩家:" + Program._PlayerRoles.Name + "进行攻击    造成了:" + attackcound + "点伤害    " + "玩家剩余HP:" + Program._RolesWarrior.Hp);
                if (Program._RolesWarrior.Hp == 0)
                {
                    Thread.Sleep(400);
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n\t战斗失败");
                    Console.BackgroundColor = ConsoleColor.White;
                    //玩家死亡后,进入返回页面
                    Program.GameChoice();
                }
            }
            else
            {
                if (attackcound < Program._RolesWizard.Defense)
                {
                    attackcound             = Program._RolesWizard.Defense;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n\t怪物的攻击值太低了,你没有遭到伤害");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                Program._RolesWizard.Hp = Program._RolesWizard.Hp - attackcound + Program._RolesWizard.Defense;
                if (Program._RolesWizard.Hp <= 0)
                {
                    Program._RolesWizard.Hp = 0;
                }
                Console.WriteLine("\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
                Thread.Sleep(400);
                Console.WriteLine("\n怪物:" + BRole.Name + "  对玩家:" + Program._PlayerRoles.Name + "进行攻击    造成了:" + attackcound + "点伤害    " + "玩家剩余HP:" + Program._RolesWizard.Hp);
                if (Program._RolesWizard.Hp == 0)
                {
                    Thread.Sleep(400);
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n\t战斗失败");
                    Console.ForegroundColor = ConsoleColor.White;
                    Program.GameChoice();
                }
            }
        }
Example #3
0
 /// <summary>
 /// 游戏角色的被攻击行为
 /// </summary>
 public virtual void Bcombat(GameRoles BRole)
 {
 }