Beispiel #1
0
    protected virtual void PlayDieEffect()
    {
        GameObject    explosion     = Instantiate(dieEffect, transform.position, Quaternion.identity);
        LoopExplosion loopExplosion = explosion.GetComponent <LoopExplosion>();

        if (loopExplosion)
        {
            loopExplosion.Attach(transform);
        }
    }
Beispiel #2
0
    public void Die()
    {
        if (squadonManager != null)
        {
            squadonManager.OnMemberDestroy(transform.position);
        }

        GameObject    explosion     = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
        LoopExplosion loopExplosion = explosion.GetComponent <LoopExplosion>();

        if (loopExplosion)
        {
            loopExplosion.Attach(transform);
        }

        if (dropPowerUp)
        {
            Instantiate(powerupPrefab, transform.position, Quaternion.identity);
        }

        Destroy(gameObject);
    }
    public void Die()
    {
        if (squadonManager != null)
        {
            squadonManager.OnMenberDestroy(transform.position);
        }
        if (!explosionAttachToPattent)
        {
            Instantiate(explosionPrefab[0], transform.position, Quaternion.identity);
        }
        else
        {
            GameObject explosion = Instantiate(explosionPrefab[1], transform.position, Quaternion.identity);

            explosion.transform.SetParent(transform.parent);
            LoopExplosion loopExplosion = explosion.GetComponent <LoopExplosion>();

            if (loopExplosion)
            {
                float xMax = col2D.bounds.center.x + col2D.bounds.extents.x - transform.position.x;
                float xMin = col2D.bounds.center.x - col2D.bounds.extents.x - transform.position.x;
                float yMax = col2D.bounds.center.y + col2D.bounds.extents.y - transform.position.y;
                float yMin = col2D.bounds.center.y - col2D.bounds.extents.y - transform.position.y;

                loopExplosion.explosionAreaMin = Vector2.right * xMin + Vector2.up * yMin;
                loopExplosion.explosionAreaMax = Vector2.right * xMax + Vector2.up * yMax;
            }
        }


        if (dropPowerUp)
        {
            Instantiate(powerUpPrefab, transform.position, Quaternion.identity);
        }
        Destroy(effect);
        Destroy(gameObject);
    }