Exemple #1
0
    IEnumerator _deleteTileActors(TileModel [] modelsDeleted, float deathTime)
    {
        if (modelsDeleted.Length == 0)
        {
            yield break;
        }

        float timer = 0;

        if (deathTime <= 0)
        {
            deathTime = Mathf.Epsilon;
        }

        while (timer <= deathTime)
        {
            for (int i = 0; i < modelsDeleted.Length; ++i)
            {
                TileActor act = modelsDeleted[i].AttachedTileActor;
                Color     c   = act.getColor();
                act.setColor(new Color(c.r, c.g, c.b, 1 - timer / deathTime));
            }
            timer += Time.deltaTime;
            yield return(null);
        }
        yield return(null);

        //actual deletion
        for (int i = 0; i < modelsDeleted.Length; ++i)
        {
            Assert.IsTrue(modelsDeleted[i].isOffBorad());
            TileActor act = modelsDeleted[i].AttachedTileActor;
            Destroy(act.gameObject);
            modelsDeleted[i].AttachedTileActor = null;
        }
    }