示例#1
0
        ///ROUTINES.
        public Item SingleItemSelectionMenu(string ask, List <Item> itemlist)
        {
            if (itemlist.Count == 0)
            {
                return(null);
            }
            if (itemlist.Count == 1)
            {
                return(itemlist[0]);
            }
            int            cursor = 0;
            ConsoleKeyInfo keyPressed;

            do
            {
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Clear();
                Console.WriteLine("What item would you want to " + ask + "?");
                for (int i = 0; i < itemlist.Count; i++)
                {
                    if (i == cursor)
                    {
                        Console.BackgroundColor = ConsoleColor.DarkRed;
                    }
                    else
                    {
                        Console.BackgroundColor = ConsoleColor.Black;
                    }
                    Console.WriteLine(itemlist[i].DisplayName);
                }
                keyPressed = Console.ReadKey(true);
                switch (keyPressed.Key)
                {
                case ConsoleKey.NumPad2:
                case ConsoleKey.DownArrow: cursor++; break;

                case ConsoleKey.NumPad8:
                case ConsoleKey.UpArrow: cursor--; break;

                //case ConsoleKey.Spacebar: return itemlist[cursor]; break;
                //case ConsoleKey.Enter: return itemlist[cursor]; break;
                case ConsoleKey.Escape: Log.AddOneFromList(StringFactory.CancelStrings()); return(null);

                default: break;
                }
                if (cursor >= itemlist.Count)
                {
                    cursor = 0;
                }
                if (cursor < 0)
                {
                    cursor = itemlist.Count - 1;
                }
            } while (keyPressed.Key != ConsoleKey.Spacebar && keyPressed.Key != ConsoleKey.Enter);
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.Gray;
            return(itemlist[cursor]);
        }
示例#2
0
        void shootDialogue()
        {
            if (Inv.Wielded.Range == 1)
            {
                Log.AddLine("You can't shoot with the " + Inv.Wielded.DisplayName + "!");
                return;
            }
            Log.AddLine("Which target? (tab - next, f - fire, esc - cancel)");
            bool nextTargetPlease = true;

            while (nextTargetPlease)
            {
                nextTargetPlease = false;
                foreach (Actor currTarget in World.AllActors)
                {
                    if (WorldLOS.VisibleLineExist(CoordX, CoordY, currTarget.CoordX, currTarget.CoordY))
                    {
                        WorldRendering.drawInCircleFOV(CoordX, CoordY, visibilityRadius);
                        WorldRendering.drawUnitsInCircle(CoordX, CoordY, visibilityRadius);
                        this.Draw();
                        currTarget.DrawHighlighted();
                        Console.ForegroundColor = ConsoleColor.Red;
                        WorldRendering.DrawLineNotInclusive(CoordX, CoordY, currTarget.CoordX, currTarget.CoordY, '*');
                        ConsoleKeyInfo keyPressed = Console.ReadKey(true);
                        if (keyPressed.Key == ConsoleKey.Tab)
                        {
                            nextTargetPlease = true;
                            continue;
                        }
                        if (keyPressed.Key == ConsoleKey.Escape)
                        {
                            Log.AddOneFromList(StringFactory.CancelStrings());
                            return;
                        }
                        if (keyPressed.Key == ConsoleKey.F)
                        {
                            Attack.RangedAttack(this, currTarget);
                            return;
                        }
                    }
                }
            }
            Log.ReplaceLastLine("No targets in range!");
        }
示例#3
0
        public List <Item> MultipleItemSelectionMenu(string ask, List <Item> itemlist)
        {
            if (itemlist.Count <= 1)
            {
                return(itemlist);
            }
            int         cursor          = 0;
            List <Item> selectedItems   = new List <Item>();
            List <bool> selectedIndexes = new List <bool>();

            for (int i = 0; i < itemlist.Count; i++)
            {
                selectedIndexes.Add(false);
            }
            string         selectChar;
            ConsoleKeyInfo keyPressed;

            do
            {
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Clear();
                Console.WriteLine("What do you want to " + ask + "?");
                for (int i = 0; i < itemlist.Count; i++)
                {
                    if (i == cursor)
                    {
                        Console.BackgroundColor = ConsoleColor.DarkRed;
                    }
                    else
                    {
                        Console.BackgroundColor = ConsoleColor.Black;
                    }
                    if (selectedIndexes[i] == false)
                    {
                        selectChar = "-";
                    }
                    else
                    {
                        selectChar = " +";
                    }
                    Console.WriteLine(selectChar + " " + itemlist[i].DisplayName);
                }
                keyPressed = Console.ReadKey(true);
                switch (keyPressed.Key)
                {
                case ConsoleKey.NumPad2:
                case ConsoleKey.DownArrow: cursor++; break;

                case ConsoleKey.NumPad8:
                case ConsoleKey.UpArrow: cursor--; break;

                case ConsoleKey.Spacebar: selectedIndexes[cursor] = !selectedIndexes[cursor]; break;

                case ConsoleKey.Escape: Log.AddOneFromList(StringFactory.CancelStrings());  return(selectedItems); break;

                default: break;
                }
                if (cursor >= itemlist.Count)
                {
                    cursor = 0;
                }
                if (cursor < 0)
                {
                    cursor = itemlist.Count - 1;
                }
            } while (keyPressed.Key != ConsoleKey.Enter);
            for (int i = 0; i < itemlist.Count; i++)
            {
                if (selectedIndexes[i])
                {
                    selectedItems.Add(itemlist[i]);
                }
            }
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.Gray;
            return(selectedItems);
        }