/// <summary>
    /// navigates through menu and return cursor position for the view
    /// </summary>
    public Vector3 Navigate()
    {
        Vector3 cursorPos = rootMenuNavigation.Navigate();

        if (Input.GetKeyDown(KeyCode.Space))
        {
            rootMenuNavigation.Confirm();
        }
        SetBattleFieldInfoText();
        return(cursorPos);
    }
Exemple #2
0
    /// <summary>
    /// Navigates through different options of the submenu and returns cursor position for the view
    /// </summary>
    private void NavigateSubMenuLoop()
    {
        if (!_isSelectingTarget)
        {
            // navigates through the sub menu options until the player return to root menu or confirms an action
            _menuCursorPosition = _subMenuNavigation.Navigate();
            SetBattleInfoTextBySubMenuElement();
            if (Input.GetKeyDown(KeyCode.Space))
            {
                SetBattleFieldCursorDependingOnMagicType();
                _isSelectingTarget = true;
            }
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                BackToRoot();
            }
        }
        else
        {
            // after the player confirms an action, he has to choose which target he attacks.
            Fighter target = NavigateTargets();
            if (Input.GetKeyDown(KeyCode.Space))
            {
                // after confirming the target, the action will be added to the battleActionProcessor
                // and the turn of the active player ends
                _isSelectingTarget = false;
                var attacker = _battleActionProcessor.ActiveFighter;
                switch (_subMenu)
                {
                case SubMenu.Magic:
                    var spell = attacker.spells[_subMenuNavigation.index];
                    _battleActionProcessor.AddMagic(attacker, target, spell);
                    break;

                case SubMenu.Skills:
                    BackToRoot();
                    break;

                case SubMenu.Bestia:
                    var bestia = attacker.bestias[_subMenuNavigation.index];
                    _battleActionProcessor.AddBestia(attacker, target, bestia);
                    break;

                case SubMenu.Inventory:
                    BackToRoot();
                    break;

                case SubMenu.Flight:
                    BackToRoot();
                    break;
                }

                EndTurn();
            }
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                BattleSoundManager.Instance.PlayCancel();
                CancelTargetSelection();
                _isSelectingTarget = false;
            }
        }
    }