Ejemplo n.º 1
0
    /// <summary>
    /// Taking the currently selected movement rule, build a set of compatible boards and
    /// add their player-facing names to the boardType dropdown
    /// </summary>
    private void BuildBoardDropdownOptions()
    {
        List <Dropdown.OptionData> boardTypeOptions = new List <Dropdown.OptionData>();

        boardType.ClearOptions();

        MovementRuleSetting selectedRuleSetting =
            movementRules.Find(setting => {
            return(setting.GetComponent <Toggle>().isOn);
        });

        foreach (var boardConfiguration in boardConfigurations.configurations)
        {
            bool validMove = boardConfiguration.allowedMoves.Any(move => { return(move == selectedRuleSetting.movement); });
            if (validMove)
            {
                foreach (var allowedBoard in boardConfiguration.allowedBoards)
                {
                    GameObject       boardObject = Resources.Load <GameObject>(allowedBoard);
                    Board            b           = boardObject.GetComponent <Board>();
                    BoardRuleSetting optionData  = new BoardRuleSetting();
                    optionData.text          = b.boardName;
                    optionData.boardResource = allowedBoard;
                    boardTypeOptions.Add(optionData);
                }
            }
        }

        boardType.AddOptions(boardTypeOptions);
        boardType.value = 0;
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Calculate the currently selected board configuration
    /// </summary>
    /// <returns>The currently selected board configuration</returns>
    private BoardConfigurationSet.BoardConfiguration SelectedBoardConfiguration()
    {
        BoardRuleSetting    boardRuleSetting      = (BoardRuleSetting)boardType.options[boardType.value];
        string              selectedBoardResource = boardRuleSetting.boardResource;
        MovementRuleSetting selectedRuleSetting   =
            movementRules.Find(setting => {
            return(setting.GetComponent <Toggle>().isOn);
        });

        foreach (var boardConfiguration in boardConfigurations.configurations)
        {
            bool validMove = boardConfiguration.allowedMoves.Any(
                (movementRule) => { return(movementRule == selectedRuleSetting.movement); });
            bool validResource = boardConfiguration.allowedBoards.Any(
                (resourcePath) => { return(resourcePath == selectedBoardResource); });
            if (validMove && validResource)
            {
                return(boardConfiguration);
            }
        }
        return(null);
    }