示例#1
0
        static void ChaAct(Character cur_cha, Character other_cha)
        {
            if (cur_cha == player)
            {
                Console.ForegroundColor = ConsoleColor.Green;
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
            }
            var effect_states = cur_cha.StateTakeEffect();

            for (int i = 0; i < effect_states.Count; ++i)
            {
                Console.WriteLine("{0}的{1}状态生效,当前HP:{2}", cur_cha.name, effect_states[i].name, cur_cha.hp);
            }

            Skill skill = null;

            // 选择技能的方式不同
            if (cur_cha == player)
            {
                while (true)
                {
                    Console.WriteLine("====请选择{0}的技能:", cur_cha.name);
                    ShowSkills(cur_cha);
                    skill = InputSkill(player.skills);
                    if (!cur_cha.UseSkill(skill, other_cha))
                    {
                        Console.WriteLine("技能使用条件不满足, 重新选择");
                        continue;
                    }
                    break;
                }
            }
            else
            {
                skill = monster.RandSkill();        // 没有UseSkill,BUG
                Console.WriteLine("{0}使用了'{1}'技能", monster.name, skill.name);
            }

            // 判断攻击谁,不应该根据技能类型判断,而是用一个字段来判断
            if (skill.type == SkillType.Heal)
            {
                if (cur_cha.BeHit(skill))
                {
                    if (skill.type == SkillType.Heal)
                    {
                        Console.WriteLine("{0}成功受到治疗,当前HP:{1}", cur_cha.name, cur_cha.hp);
                    }
                }
            }
            else if (skill.type == SkillType.Invincible)
            {
                if (cur_cha.BeHit(skill))
                {
                    if (skill.type == SkillType.Invincible)
                    {
                        Console.WriteLine("{0}成功无敌了,当前HP:{1},无敌回合{2}", cur_cha.name, cur_cha.hp, skill.time);
                    }
                }
            }

            else
            {
                if (other_cha.BeHit(skill))
                {
                    if (skill.type == SkillType.Damage)
                    {
                        Console.WriteLine("{0}受到伤害{1}点,当前HP:{2}", other_cha.name, skill.damage, other_cha.hp);
                    }
                    else if (skill.type == SkillType.DamageOverTime)
                    {
                        Console.WriteLine("{0}中了状态", other_cha.name);
                    }
                    else if (skill.type == SkillType.Execute)
                    {
                        Console.WriteLine("{0}被处决了!", other_cha.name);
                    }
                }
            }
            Console.ForegroundColor = ConsoleColor.Gray;
        }