Beispiel #1
0
    public void Die()
    {
        if (!isAlive || !canDie)
        {
            return;
        }

        if (!Manager.Instance.hasDoneTorque && Manager.Instance.levelToActivate > 0)
        {
            TutorialDude.Instance.Show("You can also manually control the launch torque from the meter under the cannon.", 0.5f);
        }

        AudioManager.Instance.curMusic.pitch = 0.85f;

        AudioManager.Instance.PlayEffectAt(1, body.transform.position, 1.285f);
        AudioManager.Instance.PlayEffectAt(4, body.transform.position, 1.653f);
        AudioManager.Instance.PlayEffectAt(6, body.transform.position, 1.828f);
        AudioManager.Instance.PlayEffectAt(10, body.transform.position, 1.4f);
        AudioManager.Instance.PlayEffectAt(18, body.transform.position, 0.876f);

        AudioManager.Instance.PlayEffectAt(Random.Range(70, 78), body.transform.position, 1.5f);

        GameManager.Instance.deaths++;

        clicker.SetActive(false);

        ToggleOutline(false);

        launcher.ActivateIfNeeded();

        line.enabled = false;

        cam.BaseEffect(2f);

        isAlive = false;

        UnFollow();

        if (activatedBlocks.Any())
        {
            activatedBlocks.ForEach(b => b.Deactivate());
        }

        EffectManager.Instance.AddEffect(0, body.transform.position);
        EffectManager.Instance.AddEffect(1, body.transform.position);
        EffectManager.Instance.AddEffect(6, body.transform.position);

        grabbers.ForEach(g =>
        {
            g.enabled = false;
            g.DetachMultiBlock();
        });
        joints.ForEach(j => j.enabled = false);
        bodies.ForEach(rb =>
        {
            //rb.gameObject.tag = "BodyPart";
            var dir = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f));
            rb.AddForce(dir * rb.mass * 100f, ForceMode2D.Impulse);
        });
    }