Beispiel #1
0
    public void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Drop")
        {
            int random = Random.Range(1, 4);
            if (random == 1)
            {
                buffs_class.X2(); { buffs_class.x2_b.SetActive(true); }
            }
            else if (random == 2)
            {
                buffs_class.Scale(); buffs_class.scale_b.SetActive(true);
            }
            else if (random == 3)
            {
                buffs_class.Speed(); buffs_class.speed_b.SetActive(true);
            }
        }
        if (collision.gameObject.tag == "1")
        {
            gem_1.SetActive(false);
            gem_2.SetActive(true);
            gem_2.transform.position = new Vector3(Random.Range(2.47f, 5.26f), -5.4f, 0f);
            check             = !check;
            gem              += (1 * kef);
            shop_class.money += (1 * kef);
            GetComponent <AudioSource>().PlayOneShot(pick_audio);
        }

        if (collision.gameObject.tag == "2")
        {
            gem_2.SetActive(false);
            gem_1.SetActive(true);
            gem_1.transform.position = new Vector3(Random.Range(-5.66f, -2.47f), -5.4f, 0f);
            check             = !check;
            gem              += (1 * kef);
            shop_class.money += (1 * kef);
            GetComponent <AudioSource>().PlayOneShot(pick_audio);
        }
        if (collision.gameObject.name == "Shop1")
        {
            PlayerPrefs.SetInt("dead", buttons_class.Dead = 2); speed = 6; check = false; stay = true;
        }
        if (collision.gameObject.name == "Shop2")
        {
            PlayerPrefs.SetInt("dead", buttons_class.Dead = 2); speed = 6; check = true; stay = true;
        }
        if (collision.gameObject.tag == "Tp")
        {
            transform.position = new Vector3(-0.28f, -5.267f, -0.67f); transform.rotation = new Quaternion(0f, 0f, 1f, 0f);
        }
        if (collision.gameObject.tag == "Ground" && stay == true)
        {
            Duuhu.enabled = true; speed = 0; stay = false;
        }
        if (collision.gameObject.tag == "Ground")
        {
            cam_class.enabled = false; gameObject.tag = "Player"; pl1.tag = "Default"; pl2.tag = "Default"; rb.gravityScale = 20;
        }
        if (collision.gameObject)
        {
            buttons_class.y_can_swipe = true;
        }
    }