Exemplo n.º 1
0
        public override Option <ICommand> HandleKeyInput(int key)
        {
            switch (InputMapping.GetInventoryInput(key))
            {
            case InventoryInput.MoveDown:
                if (_currIndex < _subinv.TypeCount - 1)
                {
                    CurrKey++;
                }
                return(Option.None <ICommand>());

            case InventoryInput.MoveUp:
                if (_currIndex > 0)
                {
                    CurrKey--;
                }
                return(Option.None <ICommand>());

            case InventoryInput.Open:
                Item item = _subinv.GetItem(_currIndex);
                return(ResolveInput(item));

            case InventoryInput.OpenLetter:
                char charKey = key.ToChar();
                if (_subinv.HasIndex(charKey - 'a'))
                {
                    CurrKey = charKey;
                    goto case InventoryInput.Open;
                }
                else
                {
                    return(Option.None <ICommand>());
                }

            default:
                return(Option.None <ICommand>());
            }
        }