Exemplo n.º 1
0
    IEnumerator ExplosionExpansion(float eRadius)
    {
        GameObject g = new GameObject();

        g.name = "Shockwave";
        g.transform.position = this.transform.position;
        g.transform.parent   = null;
        g.AddComponent <KillMe> ();
        GameObject h = Instantiate(Explosion);

        h.AddComponent <KillMe> ();
        h.transform.position = transform.position;
        LineRenderer l = g.AddComponent <LineRenderer>();

        Renderer[] re = GetComponentsInChildren <Renderer> ();
        foreach (Renderer roo in re)
        {
            roo.enabled = false;
        }
//		l.material = new Material (Shader.Find ("Particles/Additive"));
        l.startColor = Color.green;
        if (faction != FAC.PLAYER)
        {
            l.startColor = Color.red;
        }
        Color c     = new Color(l.startColor.r, l.startColor.g, l.startColor.b);
        float f     = .1f;
        float b     = 0f;
        float alpha = 100f;

        while (f < eRadius && b < 3f)
        {
            RenderCircle(l, f);
            f = Mathf.Lerp(f, eRadius, 1f * Time.deltaTime);
            float a = 0f;
            b    += Time.deltaTime;
            alpha = Mathf.Lerp(alpha, 0f, 4f * Time.deltaTime);
            c     = new Color(l.startColor.r, l.startColor.g, l.startColor.b, alpha);
            a    += Time.deltaTime;
            l.SetColors(c, c);
            yield return(null);
        }

        if (Random.Range(0, 5) != 0)
        {
            GameObject life = Instantiate(EscapePod);
            life.transform.position = transform.position;
            life.GetComponent <EscapePod> ().Survivors = shipClass.crew / 5;
            life.name = gameObject.name + " Life Boat";
        }
        else
        {
            foreach (Character m in shipClass.Characters)
            {
                m.Die();
            }
        }
        NameManager.RecycleName(this);
        Destroy(g);
        Agent.Warp(new Vector3(0f, 4000f, 0f));
        Agent.enabled = false;
        Invoke("FinalDestroy", 2f);
    }