Exemplo n.º 1
0
    void DestroyGem(GameObject gem, GameObject gemEffect, Sprite gemImg)
    {
        Destroy(gem);
        collectedGems++;
        if (collectedGems == totalGems)
        {
            door.SetActive(true);
        }
        Destroy(Instantiate(gemEffect, gem.transform.position, gem.transform.rotation), 5f);

        switch (collectedGems)
        {
        case 0:
            break;

        case 1:
            Gem1.SetActive(true);
            Gem1.GetComponent <Image>().sprite = gemImg;
            break;

        case 2:
            Gem2.SetActive(true);
            Gem2.GetComponent <Image>().sprite = gemImg;
            break;

        case 3:
            Gem3.SetActive(true);
            Gem3.GetComponent <Image>().sprite = gemImg;
            break;
        }
    }
Exemplo n.º 2
0
    void Awake()
    {
        // Set up references
        door          = GameObject.FindGameObjectWithTag("Door");
        groundCheck   = transform.Find("GroundCheck");
        firePoint     = transform.Find("FirePoint");
        body2D        = GetComponent <Rigidbody2D>();
        anim          = GetComponent <Animator>();
        healthManager = GetComponent <PlayerHealth>();
        totalGems     = GameObject.FindGameObjectsWithTag("Gem").Length;
        GemUI         = GameObject.Find("GemUI");
        Gem1          = GameObject.Find("Gem1");
        Gem2          = GameObject.Find("Gem2");
        Gem3          = GameObject.Find("Gem3");

        door.SetActive(false);
        Gem1.SetActive(false);
        Gem2.SetActive(false);
        Gem3.SetActive(false);
    }