Ejemplo n.º 1
0
    private IEnumerator RemoveObjectFromPoolCoroutine(PickableUsableObject obj, float lagSeconds)
    {
        yield return(new WaitForSeconds(lagSeconds));

        obj.AssociatedContainer.UnassignEquipmentUsable();
        obj.AssignEquipmentContainer(null);

        yield return(null);
    }
Ejemplo n.º 2
0
    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;
        }
    }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 6
0
 public void RemoveObjectFromPool(PickableUsableObject obj, float lagSeconds)
 {
     --_usableContainersOccupiedCount;
     StartCoroutine(RemoveObjectFromPoolCoroutine(obj, lagSeconds));
 }