Beispiel #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (!isDead)
        {
            if (collision.collider.tag == "Player")
            {
                collision.collider.GetComponent <Planet>().HurtPlanet();

                Explode();
            }

            if (collision.collider.tag == "Rocket")
            {
                //Destroy(collision.collider.gameObject);
                if (isVisible)
                {
                    collision.collider.gameObject.SetActive(false);


                    p.AddEXP(10);

                    //if (fragments)
                    //{
                    //    Instantiate(masterAsteroid, (Vector2)transform.position + (Vector2)Random.insideUnitCircle * 2, Quaternion.identity);
                    //    Instantiate(masterAsteroid, (Vector2)transform.position + (Vector2)Random.insideUnitCircle * 2, Quaternion.identity);
                    //    Instantiate(masterAsteroid, (Vector2)transform.position + (Vector2)Random.insideUnitCircle * 2, Quaternion.identity);
                    //}
                    //LootChance();
                    LootTable();
                    Explode();
                }
            }



            if (collision.collider.gameObject.layer == LayerMask.NameToLayer("Shield"))
            {
                p.AddEXP(5);
                collision.collider.GetComponent <Damageable>().Damage(1);
                //LootChance();
                LootTable();
                Explode();
            }
        }
    }