private IEnumerator RemoveObjectFromPoolCoroutine(PickableUsableObject obj, float lagSeconds) { yield return(new WaitForSeconds(lagSeconds)); obj.AssociatedContainer.UnassignEquipmentUsable(); obj.AssignEquipmentContainer(null); yield return(null); }
public void AddObjectToPool(PickableUsableObject obj, float lagSeconds) { if (_usableContainersOccupiedCount == _usableContainers.Length) { return; } ++_usableContainersOccupiedCount; StartCoroutine(AddObjectToPoolCoroutine(obj, lagSeconds)); if (CurrentMode == EquipmentMode.USABLES) { _currentPanel.GetComponent <PanelGeneric>().Show(false); } obj.gameObject.layer = LayerMask.NameToLayer("UI"); }
public void AssignEquipmentUsable(PickableUsableObject obj) { IsFree = false; AssociatedObject = obj; Sprite spr = AssociatedObject.GetComponent <SpriteRenderer>().sprite; UsableField.UsableImage.sprite = spr; UsableField.UsableImage.enabled = true; if (isActiveAndEnabled) { StartCoroutine(AddObjectToPoolFadeCoroutine(0.6f, 0.0f, 1.0f, true)); } else { UsableField.UsableCanvasGroup.alpha = 1.0f; } }
private IEnumerator AddObjectToPoolCoroutine(PickableUsableObject obj, float lagSeconds) { yield return(new WaitForSeconds(lagSeconds)); UsableContainer container = null; for (int i = 0; i < _usableContainers.Length; ++i) { container = _usableContainers[i]; if (container.IsFree) { break; } } obj.AssignEquipmentContainer(container); container.AssignEquipmentUsable(obj); _usableList.Add(obj); yield return(null); }
private IEnumerator AddObjectToPoolFadeCoroutine(float timeSeconds, float startOpacity, float targetOpacity, bool assign) { float cTime = Time.time; UsableField.UsableCanvasGroup.alpha = startOpacity; while (Time.time - cTime <= timeSeconds) { float lerpValue = (Time.time - cTime) / timeSeconds; float finalOpacity = Mathf.Lerp(startOpacity, targetOpacity, lerpValue); UsableField.UsableCanvasGroup.alpha = finalOpacity; yield return(null); } UsableField.UsableCanvasGroup.alpha = targetOpacity; if (!assign) { AssociatedObject = null; UsableField.UsableImage.enabled = false; } yield return(null); }
public void RemoveObjectFromPool(PickableUsableObject obj, float lagSeconds) { --_usableContainersOccupiedCount; StartCoroutine(RemoveObjectFromPoolCoroutine(obj, lagSeconds)); }