예제 #1
0
        public override async Task Execute()
        {
            await TextArea.PrintLine();

            var player = GameState.Player;

            renderer.InventoryScreen = 0;

            using (gameControl.PushRenderer(renderer))
            {
                while (renderer.InventoryScreen < 2)
                {
                    await gameControl.WaitAsync(150);

                    await gameControl.WaitForKey();

                    renderer.InventoryScreen++;
                }
            }
        }
예제 #2
0
        private async Task <int> RunSubMenu(SubMenu menu)
        {
            this.menu = menu;

            menuRenderer.Menu = menu;

            for (int i = 0; i < menu.theList.Count; i++)
            {
                if (menu.theList[i].Length + 6 > menu.width)
                {
                    menu.width = menu.theList[i].Length + 6;
                }
            }

            string displayTitle = "Choose " + menu.title;

            if (displayTitle.Length + 2 > menu.width)
            {
                menu.width = displayTitle.Length + 2;
            }

            try
            {
                gameControl.PushRenderer(menuRenderer);

                Keys key;

                do
                {
                    key = await gameControl.WaitForKey(showPrompt : false);

                    if (key == Keys.Up)
                    {
                        menu.value--;
                        if (menu.value < 0)
                        {
                            menu.value = 0;
                        }
                    }
                    if (key == Keys.Down)
                    {
                        menu.value++;
                        if (menu.value >= menu.theList.Count)
                        {
                            menu.value = menu.theList.Count - 1;
                        }
                    }
                    else if (key >= Keys.D0)
                    {
                        int v;

                        if (key >= Keys.A)
                        {
                            v  = (int)(key) - (int)(Keys.A);
                            v += 10;
                        }
                        else
                        {
                            v = key - Keys.D0;
                        }

                        if (v < menu.theList.Count)
                        {
                            menu.value = v;
                            key        = Keys.Enter;
                        }
                    }
                } while (key != Keys.Enter);

                await gameControl.WaitAsync(300);
            }
            finally
            {
                gameControl.PopRenderer(menuRenderer);
            }

            return(menu.value);
        }