Esempio n. 1
0
        private static bool   ThePlayerRound(GameCore core)
        {
            //GameCore.Energy = 3;
            GameCore.PShield = 0;
            GameCore.Round  += 1;
            int SelectIndex = 0;

            core.DrawCard(5);
            while (core.HandCardGroup.Count > 0)
            {
                PrintUnitData();
                int line = Console.CursorTop;


                bool goOut = false;

                Console.Write("卡牌:");
                Console.SetCursorPosition(20, line);
                //if (core.HandCardGroup[SelectIndex].EnergyCost <= GameCore.Energy)
                Console.WriteLine("描述:");
                foreach (var item in core.HandCardGroup)
                {
                    Console.WriteLine("  ({1}){0}", item.Name, item.EnergyCost);
                }


                while (core.HandCardGroup.Count > 0 && goOut == false)
                {
                    Console.SetCursorPosition(0, SelectIndex + 1 + line);
                    Console.Write("=>");
                    Console.SetCursorPosition(22, line + 1);
                    Console.Write("                                                                                                ");
                    Console.SetCursorPosition(22, line + 1);
                    Console.Write(core.HandCardGroup[SelectIndex].Describe);
                    if (core.HandCardGroup[SelectIndex].EnergyCost > GameCore.Energy)
                    {
                        Console.SetCursorPosition(20, line);
                        Console.Write("描述:(灵气不足无法打出)");
                    }
                    else
                    {
                        Console.SetCursorPosition(20, line);
                        Console.Write("描述:                           ");
                    }
                    ConsoleKey key = Console.ReadKey(true).Key;
                    Console.SetCursorPosition(0, SelectIndex + 1 + line);
                    Console.Write("  ");
                    switch (key)
                    {
                    case ConsoleKey.S:
                    case ConsoleKey.DownArrow:
                        SelectIndex += 1;
                        break;

                    case ConsoleKey.W:
                    case ConsoleKey.UpArrow:
                        SelectIndex -= 1;
                        break;

                    case ConsoleKey.D:
                    case ConsoleKey.RightArrow:
                        goOut = PlayOneCard(core, SelectIndex, goOut);
                        if (GameCore.PHp <= 0 || GameCore.EHp <= 0)
                        {
                            return(true);
                        }
                        break;

                    case ConsoleKey.A:
                    case ConsoleKey.LeftArrow:
                        core.HandCardGroup.Clear();
                        goOut = true;
                        break;
                    }
                    if (SelectIndex >= core.HandCardGroup.Count - 1)
                    {
                        SelectIndex = core.HandCardGroup.Count - 1;
                    }
                    else if (SelectIndex <= 0)
                    {
                        SelectIndex = 0;
                    }
                }
            }
            /////////////////////////////////////////////////////////////////////////////////////////////

            PrintUnitData();
            Console.WriteLine("玩家回合结束(A)或(左方向键)退出");
            while (true)
            {
                ConsoleKey key = Console.ReadKey(true).Key;
                if (key == ConsoleKey.A || key == ConsoleKey.LeftArrow)
                {
                    break;
                }
            }


            return(false);
        }