Пример #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);
        }
Пример #2
0
        public int GetPartyChoice()
        {
            int temp = 0;

            MyDraw.DrawChoiced(temp, players[temp].Name, textPos[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, players[temp].Name, textPos[temp]);
                        temp = temp - 1;
                        MyDraw.DrawChoiced(temp, players[temp].Name, textPos[temp]);
                    }
                }
                else if (key.Key == ConsoleKey.RightArrow)
                {
                    if (temp < textPos.Count - 1)
                    {
                        MyDraw.ClearLine(21);
                        MyDraw.DrawChoiceText(temp, players[temp].Name, textPos[temp]);
                        temp = temp + 1;
                        MyDraw.DrawChoiced(temp, players[temp].Name, textPos[temp]);
                    }
                }
                else if (key.Key == ConsoleKey.Enter)
                {
                    if (players[temp].CanBeTarget(tempSkill))
                    {
                        MyDraw.ClearChoiceText();
                        break;
                    }
                    else
                    {
                        MyDraw.DrawBattleMessage("无法选择已经死亡的目标,请重新选择");
                    }
                }
                else if (key.Key == ConsoleKey.Escape)
                {
                    MyDraw.ClearLine(1);
                    return(-1);
                }
            }
            return(temp);
        }