public void ReturnToPool(TileSpriteContainer tileSpriteContainer)
 {
     tileSpriteContainer.gameObject.SetActive(false);
     tileSpriteContainer.transform.SetParent(transform);
     tileSpriteContainer.SetRendererAlpha(0);
     TileSpriteContainers.Enqueue(tileSpriteContainer);
 }
Пример #2
0
    public IEnumerator TransformToColourful()
    {
        Sprite colourfulSprite = MazeSpriteManager.Instance.DefaultMazeTileGroundColourful[SpriteNumber - 1];

        TileSpriteContainer transformedSpriteContainer = TileSpriteContainerPool.Instance.Get();

        transformedSpriteContainer.transform.SetParent(transform);
        transformedSpriteContainer.SetSprite(colourfulSprite);
        transformedSpriteContainer.SetSortingOrder(_sortingOrder);
        transformedSpriteContainer.gameObject.SetActive(true);
        transformedSpriteContainer.transform.position = transform.position;

        _tileSpriteContainer.SetSortingOrder(_sortingOrder - 1);

        float fadeSpeed   = 1f;
        float alphaAmount = 0;

        while (alphaAmount < 1)
        {
            alphaAmount = alphaAmount + (fadeSpeed * Time.deltaTime);
            transformedSpriteContainer.SetRendererAlpha(alphaAmount);

            yield return(null);
        }

        TileSpriteContainerPool.Instance.ReturnToPool(_tileSpriteContainer);
        _tileSpriteContainer = transformedSpriteContainer;
    }