Beispiel #1
0
        /// <summary>
        /// 等待用户选择技能,选择不同的技能,会显示对应的技能介绍
        /// </summary>
        /// <param name="b"></param>
        /// <returns></returns>
        public int GetSkillChoice(BaseCharacter b)
        {
            int temp = 0;

            //默认显示第一个技能
            MyDraw.DrawChoiced(temp, b.skill[temp].name, textPos[temp]);
            MyDraw.DrawChoiceInfo(b.skill[temp]);
            bool enter = false;

            while (!enter)
            {
                ConsoleKeyInfo key = Console.ReadKey(true);
                //选择←
                if (key.Key == ConsoleKey.LeftArrow)
                {
                    if (temp > 0)
                    {
                        //清空技能介绍
                        MyDraw.ClearLine(21);
                        //显示对应技能选中的颜色效果
                        MyDraw.DrawChoiceText(temp, b.skill[temp].name, textPos[temp]);
                        temp = temp - 1;
                        //显示左边的技能和对应介绍
                        MyDraw.DrawChoiced(temp, b.skill[temp].name, textPos[temp]);
                        MyDraw.DrawChoiceInfo(b.skill[temp]);
                    }
                }
                else if (key.Key == ConsoleKey.RightArrow)
                {
                    if (temp < textPos.Count - 1)
                    {
                        MyDraw.ClearLine(21);
                        MyDraw.DrawChoiceText(temp, b.skill[temp].name, textPos[temp]);
                        temp = temp + 1;
                        MyDraw.DrawChoiced(temp, b.skill[temp].name, textPos[temp]);
                        MyDraw.DrawChoiceInfo(b.skill[temp]);
                    }
                }
                else if (key.Key == ConsoleKey.Enter)
                {
                    if (b.skill[temp].CanUseSkill(b))
                    {
                        //选中技能之后,清楚技能信息
                        MyDraw.ClearChoiceText();
                        break;
                    }
                }
            }

            return(temp);
        }