Ejemplo n.º 1
0
    protected void Kill(DeathStyle style)
    {
        this.style = style;

        if (isAwake)
        {
            GameLoop.EnemyDead();
        }
        anim.enabled = false;

        foreach (SpriteRenderer renderer in GetComponentsInChildren <SpriteRenderer>())
        {
            renderer.enabled = false;
        }

        sr.enabled = true;

        switch (style)
        {
        case DeathStyle.DECAP:
            sr.sprite = decapSprite;
            break;

        case DeathStyle.SHOT:
            sr.sprite = shotSprite;
            break;

        case DeathStyle.EXPLOSION:
            sr.enabled = false;
            break;
        }

        sr.transform.Rotate(0, 0, 180);

        blood.Play();
        dead = true;
        StartCoroutine(StopBlood(3f));
        rb.simulated = false;
        foreach (Collider2D col in GetComponentsInChildren <Collider2D>())
        {
            col.enabled = false;
        }

        detail.ColorFromPos(Color.HSVToRGB(UnityEngine.Random.Range(0.0f, 1.0f), 1.0f, 1.0f), 40, transform.position);

        if (!beingControlled)
        {
            return;
        }

        beingControlled = false;
        player.GetComponent <PlayerController>().LoseControl();
    }