Esempio n. 1
0
        public override void Update()
        {
            if (_currentSelectionMenu != null)
            {
                if (_currentSelectionMenu.Activated)
                {
                    if (_currentSelectionMenu.SelectedItem >= _currentInventory.Count)
                    {
                        // Back button.
                        Objects.Destroy(_currentSelectionMenu);
                        _currentSelectionMenu = null;
                        _currentInventory     = null;
                        SoundController.PlaySound(SoundController.Back);
                        // Back button.
                    }
                    else
                    {
                        // Item.
                        InventoryItem item   = _currentInventory.ElementAt(_currentSelectionMenu.SelectedItem).Value;
                        bool          invoke = true;

                        if (item.Spendable)
                        {
                            item.Amount -= 1;

                            if (_currentInventory == Items)
                            {
                                if (item.Amount <= 0)
                                {
                                    _currentInventory.Remove(item.Token);
                                }
                            }
                            else
                            {
                                if (Objects.ObjExists <Battle.Arena>())
                                {
                                    if (item.Amount < 0)
                                    {
                                        item.Amount = 0;
                                        invoke      = false;
                                        _currentSelectionMenu.Activated = false;
                                    }
                                }
                                else
                                {
                                    Objects.Destroy(_currentSelectionMenu);
                                    new Dialogue(new string[] { "" }, new string[] { Strings.CantUsePotionsNow });
                                    invoke = false;
                                    _currentSelectionMenu = null;
                                    _currentInventory     = null;
                                }
                            }
                        }

                        if (invoke)
                        {
                            Objects.Destroy(_currentSelectionMenu);
                            _currentSelectionMenu = null;
                            _currentInventory     = null;
                            _itemActions[item.Token].Invoke(item);
                        }
                        // Item.
                    }
                }
            }
        }
Esempio n. 2
0
        public override void Update()
        {
            if (!_controlsBlock)
            {
                if (Input.KeyboardCheckPress(Controls.KeyUp))
                {
                    SelectedItem -= 1;
                    SoundController.PlaySound(SoundController.Blip);
                }
                if (Input.KeyboardCheckPress(Controls.KeyDown))
                {
                    SelectedItem += 1;
                    SoundController.PlaySound(SoundController.Blip);
                }

                // Wrapping cursor.
                if (SelectedItem < 0)
                {
                    SelectedItem += Items.Length;
                }
                if (SelectedItem >= Items.Length)
                {
                    SelectedItem -= Items.Length;
                }
                // Wrapping cursor.

                if (Input.KeyboardCheckPress(Controls.KeyA))
                {
                    ItemActivate();
                }
            }



            if (_newGameAnimation)
            {
                _newGameAlarm -= 1;

                if (_newGameAlarm == 0)
                {
                    switch (_newGameAnimationStage)
                    {
                    case 0:
                        GameConsole.BaseBackgroundColor = _bufferFg;
                        GameConsole.BaseForegroundColor = _bufferFg;
                        break;

                    case 1:
                        GameConsole.BaseBackgroundColor = _bufferFg;
                        GameConsole.BaseForegroundColor = _bufferBg;
                        break;

                    case 2:
                        GameConsole.BaseBackgroundColor = _bufferBg;
                        GameConsole.BaseForegroundColor = _bufferFg;
                        break;
                    }

                    _newGameAnimationStage += 1;
                    _newGameAlarm           = _newGameTime;
                }

                // Shitcoding my way to victory.
                if (_newGameAnimationStage > 40 && !SoundController.NewGame.IsPlaying)
                {
                    StartNewGame();
                }
            }
        }