Exemple #1
0
    /// <summary>
    /// Instantiates the cancel button.
    /// </summary>
    /// <returns>The cancel button.</returns>
    /// <param name="container">Container.</param>
    /// <param name="numberOfButtons">Number of buttons.</param>
    /// <param name="index">Index.</param>
    /// <param name="iconPath">Icon path.</param>
    private RadialButtonController InstantiateCancelButton(RadialButtonContainer container, int numberOfButtons, int index, string iconPath)
    {
        RadialButtonController.RadialButtonType radialButtonType = RadialButtonController.RadialButtonType.CANCEL;
        RadialButtonController cancelButton = InstantiateButton(container, numberOfButtons, index, iconPath, radialButtonType, radialButtonType.ToString());

        return(cancelButton);
    }
Exemple #2
0
    /// <summary>
    /// Instantiates the buttons.
    /// </summary>
    public void InstantiateRootButtons()
    {
        RadialButtonContainer radialButtonContainer;

        // If there is already one, use that one
        if (_combatController.CurrentRadialButtonContainer != null)
        {
            radialButtonContainer = _combatController.CurrentRadialButtonContainer;
            radialButtonContainer.gameObject.SetActive(true);
            StartCoroutine(radialButtonContainer.ScaleButtonsOut());
        }
        else
        {
            radialButtonContainer = InstantiateRadialButtonContainer();

            foreach (var combatOption in _combatOptions)
            {
                RadialButtonController.RadialButtonType radialButtonType = (RadialButtonController.RadialButtonType)combatOption.Key;
                string buttonName   = radialButtonType.ToString();
                int    abilityIndex = combatOption.Key;
                string iconPath     = combatOption.Value;

                //TODO: Remove this silly hack for abilities
                if (combatOption.Key == 2)
                {
                    string abilityIcon        = "";
                    string abilityIconPreffix = combatOption.Value;

                    if (_unit.UnitData.AbilityCollection.HasTalent)
                    {
                        abilityIcon = TALENT_ICON;
                        buttonName  = "Talent";
                    }
                    else if (_unit.UnitData.AbilityCollection.HasMagic)
                    {
                        abilityIcon = MAGIC_ICON;
                        buttonName  = "Magic";
                    }

                    abilityIcon = Path.Combine(abilityIconPreffix, abilityIcon);
                    iconPath    = abilityIcon;
                }
                RadialButtonController button = InstantiateButton(radialButtonContainer, _combatOptions.Count, abilityIndex, iconPath, radialButtonType, buttonName);

                //TODO: Another stupid hack to classify attacks as abilities
                if (combatOption.Key == 0)
                {
                    button.Ability = _unit.UnitData.AbilityCollection.GetAttackAbility();
                }

                radialButtonContainer.Add(button);
            }
        }

        SetRadialButtonContainer(radialButtonContainer);

        IsRootMenuOpen = true;
    }
Exemple #3
0
    /// <summary>
    /// Instantiates the button.
    /// </summary>
    /// <returns>The button.</returns>
    /// <param name="radialButtonContainer">Radial button container.</param>
    /// <param name="numberOfButtons">Number of buttons.</param>
    /// <param name="index">Index.</param>
    /// <param name="iconPath">Icon path.</param>
    /// <param name="radialButtonType">Radial button type.</param>
    /// <param name="name">Name.</param>
    private RadialButtonController InstantiateButton(
        RadialButtonContainer radialButtonContainer,
        int numberOfButtons,
        int index,
        string iconPath,
        RadialButtonController.RadialButtonType radialButtonType,
        string name)
    {
        Vector3 buttonPosition = GetButtonPosition(numberOfButtons, index);
        RadialButtonController radialButtonController = RadialButtonController.InstantiateInstance(radialButtonContainer);

        radialButtonController.Initialize(iconPath, radialButtonType, GetFirstLetterToUpper(name), buttonPosition);

        return(radialButtonController);
    }