/// <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); }
/// <summary> /// Instantiates the radial button container. /// </summary> /// <returns>The radial button container.</returns> private RadialButtonContainer InstantiateRadialButtonContainer() { RadialButtonContainer instance = Instantiate(_radialButtonContainerPrefab); instance.Initialize(this); return(instance); }
/// <summary> /// Instantiates the item buttons. /// </summary> public void InstantiateItemButtons() { if (_combatController.CurrentRadialButtonContainer != null) { _popupText.text = ""; StartCoroutine(_combatController.CurrentRadialButtonContainer.ScaleButtonsIn()); } RadialButtonContainer radialButtonContainer = InstantiateRadialButtonContainer(); List <Item> items = ItemManager.Instance.GlobalInventory.GetConsumables(); int numberOfButtons = items.Count + 1; for (int index = 0; index < items.Count; index++) { Item item = items [index]; RadialButtonController button = InstantiateButton(radialButtonContainer, numberOfButtons, index, item.IconPath, RadialButtonController.RadialButtonType.ITEM_USE, item.Name); button.Item = item; radialButtonContainer.Add(button); } RadialButtonController cancelButton = InstantiateCancelButton(radialButtonContainer, numberOfButtons, items.Count, _combatOptions [4]); radialButtonContainer.Add(cancelButton); SetRadialButtonContainer(radialButtonContainer); IsRootMenuOpen = false; }
//Finds the buttons that are within this menu private void Start() { _buttons = GetComponentInChildren <RadialButtonContainer>(true); if (_toggleButtonInput != null) { return; } switch (toggleButton) { case EToggleButton.LeftThumbAxis: _buttons.gameObject.SetActive(_isEnabled); _isEnabled = !_isEnabled; _toggleAxisInput = new[] { "VRMM_Horizontal_Left", "VRMM_Vertical_Left" }; break; case EToggleButton.RightThumbAxis: _buttons.gameObject.SetActive(_isEnabled); _isEnabled = !_isEnabled; _toggleAxisInput = new[] { "VRMM_Horizontal_Right", "VRMM_Vertical_Right" }; break; case EToggleButton.LeftTrigger: _toggleButtonInput = "VRMM_Trigger_Left"; break; case EToggleButton.RightTrigger: _toggleButtonInput = "VRMM_Trigger_Right"; break; case EToggleButton.LeftThumbPress: _toggleButtonInput = "VRMM_ThumbPress_Left"; break; case EToggleButton.RightThumbPress: _toggleButtonInput = "VRMM_ThumbPress_Right"; break; case EToggleButton.AButtonOculusOnly: _toggleButtonInput = "VRMM_OculusButton_A"; break; case EToggleButton.BButtonOculusOnly: _toggleButtonInput = "VRMM_OculusButton_B"; break; case EToggleButton.XButtonOculusOnly: _toggleButtonInput = "VRMM_OculusButton_X"; break; case EToggleButton.YButtonOculusOnly: _toggleButtonInput = "VRMM_OculusButton_Y"; break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Instantiates the instance. /// </summary> /// <returns>The instance.</returns> /// <param name="radialButtonContainer">Radial button container.</param> public static RadialButtonController InstantiateInstance(RadialButtonContainer radialButtonContainer) { GameObject instance = Instantiate(Resources.Load <GameObject> (RESOURCE_PATH)); instance.transform.SetParent(radialButtonContainer.transform, false); _radioButtonContainer = radialButtonContainer; return(instance.GetComponent <RadialButtonController> ()); }
/// <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); }
/// <summary> /// Instantiates the ability buttons. /// </summary> public void InstantiateAbilityButtons() { if (_combatController.CurrentRadialButtonContainer != null) { _popupText.text = ""; StartCoroutine(_combatController.CurrentRadialButtonContainer.ScaleButtonsIn()); } RadialButtonContainer radialButtonContainer = InstantiateRadialButtonContainer(); // Get abilities based off of type var abilities = new List <Ability> (); UnitData unitData = _unit.UnitData; if (unitData.AbilityCollection.HasTalent) { abilities = unitData.AbilityCollection.GetTalentAbilities(); } else if (unitData.AbilityCollection.HasMagic) { abilities = unitData.AbilityCollection.GetMagicAbilities(); } int numberOfButtons = abilities.Count + 1; for (int index = 0; index < abilities.Count; index++) { Ability ability = abilities [index]; RadialButtonController button = InstantiateButton(radialButtonContainer, numberOfButtons, index, ability.IconPath, RadialButtonController.RadialButtonType.ABILITY_USE, ability.Name); button.Ability = ability; radialButtonContainer.Add(button); } RadialButtonController cancelButton = InstantiateCancelButton(radialButtonContainer, numberOfButtons, abilities.Count, _combatOptions [4]); radialButtonContainer.Add(cancelButton); SetRadialButtonContainer(radialButtonContainer); IsRootMenuOpen = false; }
/// <summary> /// Sets the radial button container. /// </summary> /// <param name="radialButtonContainer">Radial button container.</param> private void SetRadialButtonContainer(RadialButtonContainer radialButtonContainer) { _combatController.RadialButtonContainers.Add(radialButtonContainer); _combatController.PreviousRadialButtonContainer = _combatController.CurrentRadialButtonContainer; _combatController.CurrentRadialButtonContainer = radialButtonContainer; }