Beispiel #1
0
        private void UpdateHook(object sender, Game.UpdateEventArgs e)
        {
            if (InputMap.FindMapping(InputAction.Menu).Pressed(_world.Input))
            {
                _closed = true;
            }

            _options.UpdateLabels();
            _menu.Update(e.DeltaTime, _world.Input);
        }
Beispiel #2
0
        private void UpdateHook(object sender, Game.UpdateEventArgs e)
        {
            if (_offsetY == 0)
            {
                if (!_closed && InputMap.FindMapping(InputAction.Inventory).Pressed(_world.Input))
                {
                    InventoryUI.Show(_world, _entity, null, true);
                    _transitioning = true;
                }

                if (!_closed && InputMap.FindMapping(InputAction.Spells).Pressed(_world.Input))
                {
                    SpellsUI.Show(_world, null, true);
                    _transitioning = true;
                }

                if (InputMap.FindMapping(InputAction.Back).Pressed(_world.Input) ||
                    InputMap.FindMapping(InputAction.Inventory).Pressed(_world.Input) ||
                    InputMap.FindMapping(InputAction.Spells).Pressed(_world.Input))
                {
                    _closed = true;
                }
            }
        }
Beispiel #3
0
        private void UpdateHook(object sender, Game.UpdateEventArgs e)
        {
            if (_offsetY == 0)
            {
                if (!_closed && _state is WorldState && InputMap.FindMapping(InputAction.Spells).Pressed(_state.Input))
                {
                    SpellsUI.Show(_state as WorldState, null, true);
                    _transitioning = true;
                }

                if (!_closed && _state is WorldState && InputMap.FindMapping(InputAction.Player).Pressed(_state.Input))
                {
                    PlayerUI.Show(_state as WorldState, null, true);
                    _transitioning = true;
                }

                if (InputMap.FindMapping(InputAction.Back).Pressed(_state.Input) ||
                    (_state is WorldState && InputMap.FindMapping(InputAction.Spells).Pressed(_state.Input)) ||
                    (_state is WorldState && InputMap.FindMapping(InputAction.Player).Pressed(_state.Input)))
                {
                    _closed = true;
                }

                if (_rightPaneSelected)
                {
                    if (InputMap.FindMapping(InputAction.Left).Pressed(_state.Input))
                    {
                        if (_selectedAction > 0)
                        {
                            _selectedAction--;
                        }
                        else
                        {
                            _rightPaneSelected = false;
                        }
                    }

                    if (InputMap.FindMapping(InputAction.Right).Pressed(_state.Input))
                    {
                        if (_selectedAction < _actions.Count - 1)
                        {
                            _selectedAction++;
                        }
                        else
                        {
                            _rightPaneSelected = false;
                        }
                    }

                    if (InputMap.FindMapping(InputAction.Action).Pressed(_state.Input) &&
                        _actions.Count > 0 &&
                        !(_state is CombatState && !(_sortedList[_selectedSlot].Item is CombatItem)))
                    {
                        int oldAction = _selectedAction;
                        _actions[_selectedAction].OnAction(_actions[_selectedAction], _entity, _sortedList[_selectedSlot], this);

                        // update actions manually
                        IEnumerator <ICoroutineOperation> func = ChangeSelectedSlot(_selectedSlot);
                        while (func.MoveNext())
                        {
                        }

                        _selectedAction = oldAction;

                        if (CloseOnAction)
                        {
                            WasActionPerformedOnClose = true;
                            _closed = true;
                        }
                    }
                }
                else if (_selectedSlot != -1 && !_rightPaneSelected)
                {
                    if (InputMap.FindMapping(InputAction.Up).Pressed(_state.Input))
                    {
                        if (_selectedSlot > 0)
                        {
                            _state.Coroutine.AddExisting(ChangeSelectedSlot(_selectedSlot - 1));
                        }
                        else
                        {
                            _state.Coroutine.AddExisting(ChangeSelectedSlot(_entity.Inventory.OccupiedSlots - 1));
                        }
                    }

                    if (InputMap.FindMapping(InputAction.Down).Pressed(_state.Input))
                    {
                        if (_selectedSlot < _entity.Inventory.OccupiedSlots - 1)
                        {
                            _state.Coroutine.AddExisting(ChangeSelectedSlot(_selectedSlot + 1));
                        }
                        else
                        {
                            _state.Coroutine.AddExisting(ChangeSelectedSlot(0));
                        }
                    }

                    if (InputMap.FindMapping(InputAction.Left).Pressed(_state.Input))
                    {
                        _rightPaneSelected = true;
                        _selectedAction    = _actions.Count - 1;
                    }

                    if (InputMap.FindMapping(InputAction.Right).Pressed(_state.Input))
                    {
                        _rightPaneSelected = true;
                        _selectedAction    = 0;
                    }
                }

                if (_state is CombatState && _selectedSlot != -1 && !(_sortedList[_selectedSlot].Item is CombatItem) && _rightPaneSelected)
                {
                    _rightPaneSelected = false;
                }
            }
        }
Beispiel #4
0
        private static void OnUpdate(object sender, Game.UpdateEventArgs e)
        {
            Game game = sender as Game;

            if (game.Window.Title != "Age of Darkness")
            {
                game.Window.Title = "Age of Darkness";
            }

            if (Settings.Fullscreen != game.Fullscreen)
            {
                Settings.Fullscreen = game.Fullscreen;
            }

            if (Settings.VSync != game.VSync)
            {
                Settings.VSync = game.VSync;
            }

            MediaPlayer.Volume = MathHelper.Clamp((float)(Settings.MasterVolume / 100f * Settings.MusicVolume / 100f), 0.0f, 1.0f);

            if (game.Input.Key(Keys.LeftShift) &&
                game.Input.KeyPressed(Keys.F8) &&
                game.CurrentState.GetType() != typeof(MapEditorState) &&
                game.CurrentState.GetType() != typeof(PreloaderState) &&
                game.CurrentState.GetType() != typeof(TeamStorLogoState))
            {
                game.CurrentState = new MapEditorState();
            }

            if (game.Input.Key(Keys.LeftShift) &&
                game.Input.KeyPressed(Keys.F9) &&
                game.CurrentState.GetType() != typeof(OpenMapState) &&
                game.CurrentState.GetType() != typeof(PreloaderState) &&
                game.CurrentState.GetType() != typeof(TeamStorLogoState))
            {
                OpenMapState state = new OpenMapState();
                state.Game = game;
                GameState prevState = game.CurrentState;

                // do it manually so we don't call OnLeave in the other state
                typeof(Game).GetField("_state", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(game, state);
                state.OnEnter(prevState);
            }

            if (game.Input.Key(Keys.LeftShift) &&
                game.Input.KeyPressed(Keys.F10) &&
                game.CurrentState.GetType() != typeof(PreloaderState) &&
                game.CurrentState.GetType() != typeof(TeamStorLogoState))
            {
                switch (SDL2.SDL.SDL_GetPlatform())
                {
                case "Windows":
                    Process.Start(Settings.SettingsDirectory);
                    break;

                case "Linux":
                    Process.Start("xdg-open", "\"" + Settings.SettingsDirectory.Replace("\"", "\\\"") + "\"");
                    break;
                }
            }
        }